1.docker拉取elasticsearch镜像
https://blog.csdn.net/qq_41383176/article/details/100543841
2.配置elasticsearch.yml文件,我这里使用的一台服务器,配置一主两从
所以需要3个yml文件
es1.yml:
cluster.name: es
node.name: es1
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
cluster.initial_master_nodes: ["es1"]
discovery.zen.ping.unicast.hosts: ["自己的ip:9300","自己的ip:9301","自己的ip:9302"]
discovery.zen.minimum_master_nodes: 2
es2.yml
cluster.name: es
node.name: es2
network.host: 0.0.0.0
http.port: 9201
transport.tcp.port: 9301
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
cluster.initial_master_nodes: ["es1"]
discovery.zen.ping.unicast.hosts: ["自己的ip:9300","自己的ip:9301","自己的ip:9302"]
discovery.zen.minimum_master_nodes: 2
es2.yml
cluster.name: es
node.name: es3
network.host: 0.0.0.0
http.port: 9202
transport.tcp.port: 9302
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
cluster.initial_master_nodes: ["es1"]
discovery.zen.ping.unicast.hosts: ["自己的ip:9300","自己的ip:9301","自己的ip:9302"]
discovery.zen.minimum_master_nodes: 2
3.分别创建3个容器
docker run -di --name=es1 -e ES_JAVA_POTS="-Xms256m -Xmx256m" -p 9203:9200 -p 9303:9300 -v /usr/local/es/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.io/elasticsearch:7.3.1
docker run -di --name=es2 -e ES_JAVA_POTS="-Xms256m -Xmx256m" -p 9203:9200 -p 9303:9300 -v /usr/local/es/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.io/elasticsearch:7.3.1
docker run -di --name=es3 -e ES_JAVA_POTS="-Xms256m -Xmx256m" -p 9203:9200 -p 9303:9300 -v /usr/local/es/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.io/elasticsearch:7.3.1
4.查看是否创建成功
http://自己的ip:9200/_cat/nodes
或者 在服务器内
https://blog.csdn.net/u014078154/article/details/80094276
安装ik分词器
找到对应的ik分词器版本
进入容器内部
docker exec -it es1 /bin/bash
进入安装目录我的默认是在 /usr/share/elasticsearch
进入 bin 目录执行
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.3.1/elasticsearch-analysis-ik-7.3.1.zip
依次进入其他容器执行就行了
依次重启服务