创建服务器中的docker-elasticsearch容器
1,配置环境
cd /home
vi elasticsearch.yml
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.name: "docker-cluster"
network.host: 172.17.0.4
# minimum_master_nodes need to be explicitly set when bound on a public IP
# set to 1 to allow single node clusters
# Details: https://github.com/elastic/elasticsearch/pull/17288
discovery.zen.minimum_master_nodes: 1
增加用户组 elasticsearch >授权Centos创建用户并授权
切换用户 su elasticsearch
sudo docker run -d --name=esNode1 -p 9200:9200 -p 9300:9300 -v /etc/localtime:/etc/localtime -v /home/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/data/esdata:/usr/share/elasticsearch/data/ -v /home/data/esplus/ik:/usr/share/elasticsearch/plugins/ik -e ES_JAVA_OPTS="-Xms1g -Xmx1g" --restart=always elasticsearch:6.4.3
记住6.6.0有bug,别用,就好!
vi kibana.yml
server.name: kibana
server.host: "172.17.0.5"
server.port: 5601
elasticsearch.url: http://172.17.0.4:9200
xpack.monitoring.ui.container.elasticsearch.enabled: true
当你查看docker logs -f xxxxxxxx
出现
讲讲内存bug
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
描述:docker 启动elasticsearch 的时候会出这个 报错
解决报错:
1,在宿主机执行:>sudo sysctl -w vm.max_map_count=262144
2,docker 命令增加参数:> -e ES_JAVA_OPTS="-Xms1g -Xmx1g"
永久解决方案:
切换到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
即可永久修改
----- 履霜坚冰至,半醒人!
下一篇讲讲elasticsearch 的jpa