前提是已经安装完docker
1.拉取镜像
docker pull elasticsearch:7.9.2
2.创建相关配置文件路径和数据路径
分别创建data1,data2,data3
/home/peiyajie/elasticsearch/data/data1
/home/peiyajie/elasticsearch/log/log1
/home/peiyajie/elasticsearch/config
touch elasticsearch1.yml
cluster.name: my-es
node.name: node-3
node.master: true
node.data: true
node.max_local_storage_nodes: 3
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/log
network.host: 0.0.0.0
network.publish_host: 10.202.252.209
http.port: 9202
transport.tcp.port: 9302
discovery.seed_hosts: ["10.202.252.209:9300","10.202.252.209:9301","10.202.252.209:9302"]
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
gateway.recover_after_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"
network.publish_host:不是docker得ip
3.数据文件授权
chmod 777 data1 data2 data3
4.创建网络
docker network create --driver bridge --subnet 192.168.0.0/16 --gateway 192.168.0.1 mynet
5.启动
docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" --network es-net -d -p 9200:9200 -p 9300:9300 -v /home/peiyajie/elasticsearch/config/elasticsearch1.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/peiyajie/elasticsearch/plugins/plugins1:/usr/share/elasticsearch/plugins -v /home/peiyajie/elasticsearch/data/data1:/usr/share/elasticsearch/data -v /home/peiyajie/elasticsearch/log/log1:/usr/share/elasticsearch/log --name es1 elasticsearch:7.9.2
docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" --network es-net -d -p 9201:9201 -p 9301:9301 -v /home/peiyajie/elasticsearch/config/elasticsearch2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/peiyajie/elasticsearch/plugins/plugins2:/usr/share/elasticsearch/plugins -v /home/peiyajie/elasticsearch/data/data2:/usr/share/elasticsearch/data -v /home/peiyajie/elasticsearch/log/log2:/usr/share/elasticsearch/log --name es2 elasticsearch:7.9.2
docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" --network es-net -d -p 9202:9202 -p 9302:9302 -v /home/peiyajie/elasticsearch/config/elasticsearch3.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/peiyajie/elasticsearch/plugins/plugins3:/usr/share/elasticsearch/plugins -v /home/peiyajie/elasticsearch/data/data3:/usr/share/elasticsearch/data -v /home/peiyajie/elasticsearch/log/log3:/usr/share/elasticsearch/log --name es3 elasticsearch:7.9.2
如果出现:ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/usr/share/elasticsearch/data/nodes]
操作:chmod 777 /home/peiyajie/elasticsearch/data/ -R
6.查看是否安装好
访问连接:http://10.202.252.209:9200/_cat/nodes?pretty
则是安装好的
参照:https://blog.csdn.net/belonghuang157405/article/details/83301937
7.kinna的挂载
touch kibana.yml
server.port: 5601
server.host: "0.0.0.0"
server.name: "kibana-10.202.252.209"
elasticsearch.hosts: ["http://10.202.252.209:9200","http://10.202.252.209:9201","http://10.202.252.209:9202"]
i18n.locale: "zh-CN"
xpack.monitoring.ui.container.elasticsearch.enabled: true
8.kinna启动及验证安装是否成功
docker run -d -p 5601:5601 -v /home/peiyajie/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml --network es-net --name kibana kibana:7.6.0
访问链接
http://10.202.252.209:5601