docker-日志收集

[root@linux-node5 ~]# sysctl vm.max_map_count=262144 修改系统参数
[root@linux-node5 ~]# docker run -p 5601:5601 -p 9200:9200 -p 5044:5044 -it --rm --name elk sebp/elk 起额elk镜像

打开网页,测试下
在这里插入图片描述
安装一个filebeat (我已经有了)
[root@linux-node3 ~]# vim /etc/filebeat/filebeat.yml
enabled: true

  • /var/lib/docker/containers/./*.log -增加
    #output.elasticsearch:

    Array of hosts to connect to.

    hosts: [“10.0.0.19:9200”]

[root@linux-node3 containers]# docker rm -f docker ps -a | awk '{print $1}' | grep -v 5930f740d83d | grep -v CONTAINER —删除多余的镜像

[root@linux-node3 ~]# /etc/init.d/filebeat start
Starting filebeat (via systemctl): [ OK ]

[root@linux-node3 ~]# for i in {1…10};do curl 127.0.0.1;done 产生日志
在这里插入图片描述
成功!

[root@linux-node5 ~]#docker run -d -p 24224:24224 -p 24224:24224/udp -v /fluentd_log:/fluentd_log fluent/fluentd 把本地的目录挂载到镜像里

改变docker 日志驱动

1.全局模式
[root@linux-node3 ~]# vim /etc/docker/daemon.json
{
“registry-mirrors”: [“https://mmdl1uza.mirror.aliyuncs.com”],
“cluster-store”: “consul://10.0.0.19:8500”,
“cluster-advertise”: “10.0.0.17:2375”,
“dns”: [“10.0.0.2”,“8.8.8.8”],
“log-driver”: “fluentd”, --添加这里
“log-opts”: { --添加以下
“fluentd-address”:“10.0.0.19:24224”,
“tag”: “linux-node5.example.com”
}

}

[root@linux-node3 ~]# systemctl daemon-reload
[root@linux-node3 ~]# systemctl restart docker.service

[root@linux-node3 ~]# /etc/init.d/filebeat stop

[root@linux-node5 ~]# rpm -vih filebeat-5.6.5-x86_64.rpm
[root@linux-node5 ~]# vim /etc/filebeat/filebeat.yml

  • /fluentd_log/*.log

[root@linux-node5 ~]# /etc/init.d/filebeat start
Starting filebeat (via systemctl): [ OK ]

[root@linux-node3 ~]# docker run -it -p 80:80 nginx

[root@linux-node5 ~]# for i in {1…10};do curl 10.0.0.17;done 模拟日志输出

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值