页面“Alpine”与“Filebeat nginx log”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
 
 
第1行: 第1行:
=NOTE=
+
[[category:ops]]
 
 
一般一个软件官方用什么os作容器就用他,不一定是alpine才是最好的 例如 mysql  python就可能不是
 
 
 
[https://www.infoq.cn/article/VODLe9FsiBkQdlcxJZZj 用Alpine会让Python Docker的构建慢50倍]
 
 
 
=pre=
 
占用内存仅仅 37M ,非常的小巧。适合用在树莓派或者其他低内存设备上。
 
[https://liyin.date/2017/03/18/alpine-linux-setup/index.html Alpine Linux 折腾记]
 
=download =
 
 
 
==x86==
 
https://alpinelinux.org/downloads/
 
https://mirrors.aliyun.com/alpine/v3.10/releases/x86_64/alpine-standard-3.10.3-x86_64.iso
 
http://dl-cdn.alpinelinux.org/alpine/v3.10/releases/x86_64/alpine-standard-3.10.1-x86_64.iso
 
 
 
==Raspberry Pi==
 
 
 
AArch64是ARMv8 架构的一种执行状态 so 下载这个  拿回来试一下
 
http://mirrors.ustc.edu.cn/alpine/v3.8/releases/aarch64/alpine-rpi-3.8.1-aarch64.tar.gz
 
 
 
http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/aarch64/alpine-rpi-3.8.1-aarch64.tar.gz
 
 
 
http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/armhf/alpine-rpi-3.8.1-armhf.tar.gz
 
 
 
国内的mirrors  有时比较同步比较慢
 
https://mirrors.alpinelinux.org/
 
  
===install on pi===
+
=ins and config=
[https://wiki.alpinelinux.org/wiki/Classic_install_or_sys_mode_on_Raspberry_Pi 要看 ]
+
==Download and install Filebeat==
 
 
https://wiki.alpinelinux.org/wiki/Raspberry_Pi
 
 
 
[https://wiki.alpinelinux.org/wiki/Create_a_Bootable_USB Create a Bootable USB]
 
 
 
https://my.oschina.net/u/2306127/blog/1587585
 
 
 
https://wiki.alpinelinux.org/wiki/Create_a_Bootable_USB
 
 
 
[https://xts.so/linux/install-the-alpine-linux-on-raspberry-pi-zero-w.html 在树莓派Zero W上安装alpine linux系统]
 
 
 
=安装过程=
 
 
 
输入root 没有密码 直接回车 如果是内网机器  记得打开 root login ssh
 
 
 
 
 
13-选择 sys 方式使用磁盘,将系统安装到本地硬盘-格式化硬盘-完成硬盘安装
 
sys
 
 
 
[https://blog.csdn.net/CSDN_duomaomao/article/details/76053229 Alpine linux硬盘安装]
 
 
 
=configure=
 
 
<pre>
 
<pre>
国内源
 
  
a. 编辑 /etc/apk/repositories
 
b. 将里面 dl-cdn.alpinelinux.org 的 改成 mirrors.aliyun.com ; 保存退出即可
 
  
cat  /etc/apk/repositories
+
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.12.0-amd64.deb
#/media/cdrom/apks
+
sudo dpkg -i filebeat-7.12.0-amd64.deb
http://mirrors.aliyun.com/alpine/v3.10/main
 
 
 
http://mirrors.aliyun.com/alpine/v3.10/community
 
#http://mirror.xtom.com.hk/alpine/v3.10/main
 
#http://mirror.xtom.com.hk/alpine/v3.10/community
 
#http://mirror.xtom.com.hk/alpine/edge/main
 
#http://mirror.xtom.com.hk/alpine/edge/community
 
#http://mirror.xtom.com.hk/alpine/edge/testing
 
 
 
apk update
 
 
 
 
 
alpine:~# cat /etc/apk/repositories
 
#/media/cdrom/apks
 
http://mirrors.ustc.edu.cn/alpine/v3.8/main
 
http://mirrors.ustc.edu.cn/alpine/v3.8/community
 
cp /etc/apk/repositories /etc/apk/repositories.bak
 
 
</pre>
 
</pre>
 
+
==Edit the configuration ==
=软件包管理工具apk的基本使用=
 
 
<pre>
 
<pre>
可以方便地安装、删除、更新软件。
+
Modify /etc/filebeat/filebeat.yml to set the connection information:
 
 
#查询openssh相关的软件包
 
 
 
apk search  openssh 
 
 
 
#安装一个软件包
 
 
 
apk add  xxx 
 
 
 
#删除已安装的xxx软件包
 
 
 
apk del  xxx 
 
 
 
#获取更多apk包管理的命令参数
 
 
 
apk --help 
 
 
 
 
 
 
#比如安装常用的网络相关工具:
 
 
 
#更新软件包索引文件
 
  
apk update   
+
output.elasticsearch:
 +
  hosts: ["<es_url>"]
 +
  username: "elastic"
 +
  password: "<password>"
 +
setup.kibana:
 +
  host: "<kibana_url>"
  
#用于文本方式查看网页,用于测试http协议
+
Where <password> is the password of the elastic user, <es_url> is the URL of Elasticsearch, and <kibana_url> is the URL of Kibana.
  
apk add curl 
 
 
#提供了查看网络连接的协议端口的命令ss,可以替代netstat命令
 
 
apk add iproute2 
 
 
#drill 命令可以替代dig和nslookup DNS查询命令
 
 
apk add drill 
 
 
alpine:~# df -h
 
Filesystem                Size      Used Available Use% Mounted on
 
devtmpfs                10.0M        0    10.0M  0% /dev
 
shm                    245.0M        0    245.0M  0% /dev/shm
 
/dev/sda3                29.4G    576.7M    27.3G  2% /
 
tmpfs                    49.0M    108.0K    48.9M  0% /run
 
/dev/sda1                92.8M    19.1M    66.8M  22% /boot
 
 
</pre>
 
</pre>
=Alpine Linux 包管理=
 
 
<pre>
 
  
5.apk info
+
==Enable and configure the nginx module ==
$ apk info #列出所有已安装的软件包
 
$ apk info -a zlib #显示完整的软件包信息
 
$ apk info --who-owns /sbin/lbu #显示指定文件属于的包
 
</pre>
 
  
 
=on vps =
 
my.vultr.com  ISO Library  has apline 3.8
 
也可以自己上传
 
 
[https://wiki.alpinelinux.org/wiki/Bootstrapping_Alpine_Linux Bootstrapping Alpine Linux - Alpine Linux]
 
 
[https://discuss.vultr.com/discussion/1033/custom-iso-alpinelinux custom-iso-alpinelinux]
 
 
[https://www.linode.com/docs/tools-reference/custom-kernels-distros/install-alpine-linux-on-your-linode/ Install Alpine Linux on your Linode]
 
 
=docker=
 
 
<pre>
 
<pre>
cat  /etc/apk/repositories
+
sudo filebeat modules enable nginx
 
 
http://mirrors.aliyun.com/alpine/v3.10/main
 
http://mirrors.aliyun.com/alpine/v3.10/community
 
 
 
 
 
apk add docker
 
 
 
rc-update add docker boot
 
 
 
service docker start
 
 
 
apk add py-pip
 
apk add python-dev libffi-dev openssl-dev gcc libc-dev make
 
 
 
 
 
mkdir -p ~/.pip
 
 
 
#vim  ~/.pip/pip.conf
 
cat >>~/.pip/pip.conf<<EOF
 
[global]
 
index-url = http://mirrors.aliyun.com/pypi/simple/
 
 
[install]
 
trusted-host=mirrors.aliyun.com
 
EOF
 
 
 
pip install more-itertools==5.0.0 #3.10.3
 
 
 
pip install docker-compose
 
 
 
 
 
#err 
 
  
100% |████████████████████████████████| 81kB 1.2MB/s
+
Modify the settings in the /etc/filebeat/modules.d/nginx.yml file.
more-itertools requires Python '>=3.5' but the running Python is 2.7.16
 
  
</pre>
 
==nodejs yarn etc==
 
<pre>
 
#换源 然后
 
apk add  --no-cache  nodejs yarn python
 
 
</pre>
 
</pre>
  
https://wiki.alpinelinux.org/wiki/Docker
+
== Start Filebeat==
  
=alpine docker php=
 
github 有个php-worker 搞了一关的 可以参考
 
 
[https://blog.csdn.net/liyyzz33/article/details/97265262    Alpine安装php各种扩展]
 
 
[https://blog.csdn.net/u010953609/article/details/89309712  Dockerfile 学习:Docker Alpine PHP 安装扩展]
 
 
[https://blog.csdn.net/qw_xingzhe/article/details/80161109  docker官方alpine/php镜像下安装php扩展]
 
 
[http://www.zzfly.net/alpine-linux-php-mysql/ Alpine Linux 初上手与安装 PHP7 / MySQL 环境]
 
 
=trouble shooting=
 
==alpine镜像crontab无法运行问题 ==
 
 
<pre>
 
<pre>
alpine镜像 普通用户 crontab无法运行问题
+
The setup command loads the Kibana dashboards. If the dashboards are already set up, omit this command.
 
 
crond 服务用 root用户启动  or on ci  docker-compose exec -u  root  -T php-worker  sh -c "crond"
 
 
 
如果用官方提供alpine镜像是不自动启动crond的,得手动起
 
每个用户有单独的文件在/etc/crontabs文件夹
 
可以用supervisor启动crond,但要用root用户去启动crond,运行其他用户的定时任务
 
 
 
cron itself should run as root, regardless of which user you want to use to run the jobs.
 
 
 
This will install a crontab for user robuser. When cron executes jobs from this particular crontab, it will automatically switch users to robuser. However, cron can’t switch users like that if it’s not running as root, which is why you need to be running cron as root.
 
 
 
crontab  -l
 
crontab: must be suid to work properly
 
 
 
apk add --update busybox-suid
 
  
 +
sudo filebeat setup
 +
sudo service filebeat start
 
</pre>
 
</pre>
  
[https://blog.csdn.net/gsying1474/article/details/68946455  alpine linux中如何使用crontab执行定时任务]
+
== Module status==
 
+
<pre>
[https://stackoverflow.com/questions/36453787/failed-to-edit-crontab-linux-alpine Failed to edit crontab (linux Alpine)]
+
Module status  右边的 check data 按键  -- > Nginx logs dashboard
 
 
[https://blog.csdn.net/weixin_43086579/article/details/84901497?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase Alpine容器启动Crontab任务]
 
 
 
 
 
 
 
[https://devopsheaven.com/cron/docker/alpine/linux/2017/10/30/run-cron-docker-alpine.html Running cron jobs in a Docker Alpine container]
 
 
 
=ops=
 
 
 
[[Alpine 修改docker的时区及安装telnet]]
 
  
<pre>
 
apk  add rsync
 
 
</pre>
 
</pre>
 
+
systemctl daemon-reload
=desktop=
 
暂时没有中文输入法
 
 
 
[https://www.cnblogs.com/jinzhenshui/p/8418281.html Alpine Linux:如何配置GUI的图形桌面环境:x Desktop Environment]
 
 
 
[https://blog.csdn.net/weixin_30590285/article/details/95415847 Alpine Linux:如何配置GUI的图形桌面环境:x Desktop Environment]
 
 
 
[https://wiki.alpinelinux.org/wiki/MATE MATE 桌面]
 
 
 
[https://wiki.alpinelinux.org/wiki/Awesome(wm)_Setup Awesome桌面]
 
 
 
[https://liyin.date/2017/03/18/alpine-linux-setup/ 折腾记]
 
 
 
 
 
[https://icoolworld.github.io/alpine/alpine-%E4%B8%AD%E6%96%87%E6%88%AA%E5%9B%BE%E4%B9%B1%E7%A0%81%E9%97%AE%E9%A2%98.html alpine-中文截图乱码问题]
 
 
 
=问题=
 
Alpine Linux使用了musl,可能和其他Linux发行版使用的glibc实现会有所不同。在容器化中最可能遇到的是DNS问题,即musl实现的DNS服务不会使用resolv.conf文件中的search和domain两个配置,这对于一些通过DNS来进行服务发现的框架可能会遇到问题
 
 
 
[https://www.wencst.com/2017/11/23/docker-alpine%E7%89%88%E6%9C%AC%E6%9C%8D%E5%8A%A1%E4%B8%AD%E6%98%BE%E7%A4%BA%E4%B8%AD%E6%96%87/ docker alpine版本服务中显示中文]
 
  
 
=see also=
 
=see also=
  
[https://blog.csdn.net/diyiday/article/details/91439151  alpine之创建最小docker镜像]
+
https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-nginx.html
  
[https://www.cnblogs.com/jackadam/p/9290366.html Alpine Linux常用命令]
 
  
[https://blog.csdn.net/CSDN_duomaomao/article/details/76053229 Alpine linux硬盘安装]
+
[https://www.cnblogs.com/kuku0223/p/8317965.html ELK--filebeat nginx模块]
 
 
[https://blog.csdn.net/CSDN_duomaomao/article/details/76152416 Alpine Linux 使用]
 
 
 
[http://mirrors.ustc.edu.cn/help/alpine.html Alpine Linux 源使用帮助]
 
 
 
[http://www.10tiao.com/html/357/201702/2247484888/1.html Alpine Linux配置使用技巧]
 
 
 
[http://blog.csdn.net/csdn_duomaomao/article/details/76053229 Alpine linux硬盘安装]
 
 
 
[https://zh.wikipedia.org/wiki/BusyBox BusyBox]
 
 
 
 
 
==Raspberry Pi==
 
[https://a-delacruz.github.io/alpine/alpine-linux.html Raspberry Pi 3 Alpine Linux arm64]
 
 
 
[https://wiki.alpinelinux.org/wiki/Raspberry_Pi Raspberry Pi]
 
==other==
 
[https://blog.csdn.net/diyiday/article/details/78332924 alpine linux填坑之路安装php-bcmath]
 
 
 
[https://blog.csdn.net/freewebsys/article/details/53816615 docker(13):alpinelinux安装jenkins]
 
 
 
[http://www.infoq.com/cn/news/2016/01/Alpine-Linux-5M-Docker Alpine Linux,一个只有5M的Docker镜像]
 
 
 
[https://www.cnblogs.com/xy14/p/11980272.html Python - 安装 - 在 Alpine Linux 下安装 Python2 ]
 
 
 
[[category:ops]]
 

2021年4月27日 (二) 09:25的版本


ins and config

Download and install Filebeat



curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.12.0-amd64.deb
sudo dpkg -i filebeat-7.12.0-amd64.deb

Edit the configuration

Modify /etc/filebeat/filebeat.yml to set the connection information:

output.elasticsearch:
  hosts: ["<es_url>"]
  username: "elastic"
  password: "<password>"
setup.kibana:
  host: "<kibana_url>"

Where <password> is the password of the elastic user, <es_url> is the URL of Elasticsearch, and <kibana_url> is the URL of Kibana.

Enable and configure the nginx module

sudo filebeat modules enable nginx

Modify the settings in the /etc/filebeat/modules.d/nginx.yml file.

Start Filebeat

The setup command loads the Kibana dashboards. If the dashboards are already set up, omit this command.

sudo filebeat setup
sudo service filebeat start

Module status

Module status  右边的 check data 按键  -- > Nginx logs dashboard

systemctl daemon-reload

see also

https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-nginx.html


ELK--filebeat nginx模块