• docker 安装ELK


    参考文档:

    Docker ELK使用文档:http://elk-docker.readthedocs.io/

    1.拉取镜像

    查看 Docker Hub 的镜像

    docker search elk

    拉取镜像

    sudo docker pull sebp/elk

     

    2.启动容器

    docker run -p 5601:5601 -p 9200:9200 -p 5044:5044 -p 4560:4560  -v /etc/localtime:/etc/localtime  -it --name elk sebp/elk

    elasticsearch用户拥有的内存权限太小,至少需要262144

    切换到root用户

    执行命令:

    sysctl -w vm.max_map_count=262144

    查看结果:

    sysctl -a|grep vm.max_map_count

    显示:

    vm.max_map_count = 262144

    上述方法修改之后,如果重启虚拟机将失效,所以:

    解决办法:

    在   /etc/sysctl.conf文件最后添加一行

    vm.max_map_count=262144

    即可永久修改

     重新启动容器

    3.开放端口

    5601,9200,5044

    firewall-cmd --zone=public  --permanent --add-port=5601/tcp

    firewall-cmd --zone=public  --permanent --add-port=9200/tcp

    firewall-cmd --zone=public  --permanent --add-port=5044/tcp

    firewall-cmd --zone=public  --permanent --add-port=4560/tcp

    4.查看是否启动成功

    http://localhost:5601

    5.设置容器开机启动

    docker update --restart=always elk

    6.配置

    input {
            tcp {
                    port => 4560
                    codec => json_lines
            }
    }
    
    filter {
            json {
                    source => "message"
            }
            mutate {
                    remove_field => "level_value"
                    remove_field => "port"
                    remove_field => "host"
                    remove_field => "appName"
                    remove_field => "@version"
                    remove_field => "logger_name"
                    remove_field => "thread_name"
                    remove_field => "createTime"
            }
    
    }
    
    output {
            if [appId] {
                            elasticsearch {
                            hosts => ["localhost"]
                            index => "app_%{appId}"
                            document_type => "appLog"
                    }
            }
    }

     进入elk容器,进入/etc/logstash/conf.d,删除所有配置文件,然后 vi /etc/logstash/conf.d/logstash.conf  添加新的配置文件

    添加下面配置,保存退出。将其它配置删掉。一定要注意配置文件格式为utf-8,格式需要缩进,否则启动会报错 重新启动docker

    常见问题解决:

    If Elasticsearch isn't starting...

    If the suggestions listed in Frequently encountered issues don't help, then an additional way of working out why Elasticsearch isn't starting is to:

    • Start a container with the bash command:

      $ sudo docker run -it sebp/elk bash
      
    • Start Elasticsearch manually to look at what it outputs:

    $ gosu elasticsearch /opt/elasticsearch/bin/elasticsearch

    $ gosu kibana /opt/kibana/bin/kibana

  • 相关阅读:
    【原创】go语言学习(十六)接口
    【原创】go语言学习(十五)IO操作2
    【原创】go语言学习(十四)IO操作1
    【原创】go语言学习(十三)struct介绍2
    【原创】go语言学习(十二)struct介绍1
    【原创】go语言学习(十一)package简介
    【原创】sed正则表达式替换
    【原创】go语言学习(十)Map类型
    【原创】go语言学习(九)指针类型
    【原创】go语言学习(八)切片
  • 原文地址:https://www.cnblogs.com/provence666/p/10665575.html
Copyright © 2020-2023  润新知