ELK
使用的是 sebp/elk 具体可以参考
https://hub.docker.com/r/sebp/elk
常见问题
参考 https://elk-docker.readthedocs.io/
安装
拉取
#拉取docker版本详见
https://github.com/spujadas/elk-docker
https://hub.docker.com/r/sebp/elk
#这里使用最新的版本
docker pull sebp/elk
# 或者目前最新版本是740
docker pull sebp/elk:740
##############################
#编辑 /etc/sysctl.conf
vi /etc/sysctl.conf
#注意编辑/etc/sysctl.conf加入下行 如不加入会造成容器无法启动
vm.max_map_count=262144
##############################
启动容器
docker run -p 5601:5601 -p 9200:9200 -p 9300:9300 -p 5044:5044 -e ES_MIN_MEM=128m -e ES_MAX_MEM=1024m -itd -v elk-data:/opt/elasticsearch/data --restart=always --name elk sebp/elk:740
防火墙列外
firewall-cmd --permanent --zone=public --add-port=5601/tcp
firewall-cmd --permanent --zone=public --add-port=9200/tcp
firewall-cmd --permanent --zone=public --add-port=5044/tcp
firewall-cmd --permanent --zone=public --add-port=9300/tcp
firewall-cmd --permanent --zone=public --add-port=9100/tcp
#防火墙重新启动
firewall-cmd --reload
访问测试
#es
curl http://127.0.0.1:9200/
#Kibana
curl http://127.0.0.1:5601/
查找文件
#进入docker容器
docker exec -it elk /bin/bash
#查找elasticsearch.yml 找到的结果有2个 测试的时候好像两个都必须修改
find / -name elasticsearch.yml
vi /etc/elasticsearch/elasticsearch.yml
vim /opt/elasticsearch/config/elasticsearch.yml
########配置重加入跨域####### 就两行
http.cors.enabled: true
http.cors.allow-origin: "*"
########配置重加入跨域#######
#复制文件
cp /opt/elasticsearch/config/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml
docker restart elk
#复制yml文件
docker cp /etc/elk/elasticsearch.yml elk:/opt/elasticsearch/config/elasticsearch.yml
docker cp /etc/elk/elasticsearch.yml elk:/etc/elasticsearch/elasticsearch.yml
docker restart elk
head
#拉取镜像
docker pull mobz/elasticsearch-head:5
#创建运行容器
docker run -d -p 9100:9100 --restart=always --name es-head docker.io/mobz/elasticsearch-head:5
#查看
curl http://127.0.0.1:9100/
完整集群 elasticsearch.yml 配置文件
docker 不建议配置集群,es本身就消耗资源多。docker本身的一大作用是用来压榨剩余服务器资源的。注意:docker的这个镜像貌似不能加入docker的集群不知道咋回事,坑了我半天。后来我配置的非docker的集群,也只能自动加入一个docker节点。
cluster.name: cluster-es
node.name: node-1
network.host: 0.0.0.0
network.publish_host: 192.168.100.100
#是否有资格选举成master
#node.master: true
#node.data: true
discovery.seed_hosts: ["192.168.100.100:9300","192.168.100.101:9300","192.168.100.102:9300"]
#cluster.initial_master_nodes: ["node-1","node-2","node-3"]
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
#discovery.zen.minimum_master_nodes: 2
#cluster.remote.connect: true
http.cors.enabled: true
http.cors.allow-origin: "*"