//sysctl.conf 增加
vm.max_map_count = 655360
sysctl -p #生效
// 每台机器增加目录配置文件
mkdir -p /home/es/config
mkdir -p /home/es/data
mkdir -p /home/es/plugins/ik
mkdir -p /home/es/logs
chmod 777 /home/es* -R
// 下载镜像
docker pull elasticsearch:7.6.2
docker pull kibana:7.6.2
// 下载分词器
mkdir -p /home/es/plugins/ik
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.2/elasticsearch-analysis-ik-7.6.2.zip
// 解压
unzip elasticsearch-analysis-ik-7.6.2.zip
rm -rf elasticsearch-analysis-ik-7.6.2.zip
每台机器增加配置文件
vi /home/es/config/elasticsearch.yml
network.host: 0.0.0.0
http.cors.enabled: true # 设置跨域,主要用于head插件访问es
http.cors.allow-origin: "*" # 允许所有域名访问
增加一个节点就行
[root@es01 kibana]# cat /home/es/kibana/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
server.name: "kibana-192.168.10.70"
elasticsearch.hosts: ["http://192.168.10.70:9200","http://192.168.10.71:9200","http://192.168.10.72:9200"]
[root@es01 es01]# cat docker-compose.yml
version: '3.3'
services:
es01:
image: elasticsearch:7.6.2
container_name: es01
restart: always
environment:
- node.name=es01
- network.publish_host=192.168.10.70
- discovery.seed_hosts=192.168.10.71,192.168.10.72
- cluster.initial_master_nodes=192.168.10.70,192.168.10.71,192.168.10.72
- cluster.name=es-docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms8196m -Xmx8196m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /home/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- /home/es/data:/usr/share/elasticsearch/data
- /home/es/plugins:/usr/share/elasticsearch/plugins
- /home/es/logs:/usr/share/elasticsearch/logs
ports:
- 9200:9200
- 9300:9300
kib01:
depends_on:
- es01
image: kibana:7.6.2
container_name: kib01
ports:
- 5601:5601
environment:
ELASTICSEARCH_URL: http://es01:9200
ELASTICSEARCH_HOSTS: http://es01:9200
volumes:
- /home/es/kibana/kibana.yml:/usr/share/kibana/config/kibana.yml
[root@es02 es02]# cat docker-compose.yml
version: '3.3'
services:
es02:
image: elasticsearch:7.6.2
container_name: es02
restart: always
environment:
- node.name=es02
- network.publish_host=192.168.10.71
- discovery.seed_hosts=192.168.10.70,192.168.10.72
- cluster.initial_master_nodes=192.168.10.70,192.168.10.71,192.168.10.72
- cluster.name=es-docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms8196m -Xmx8196m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /home/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- /home/es/data:/usr/share/elasticsearch/data
- /home/es/plugins:/usr/share/elasticsearch/plugins
- /home/es/logs:/usr/share/elasticsearch/logs
ports:
- 9200:9200
- 9300:9300
[root@es03 es03]# cat docker-compose.yml
version: '3'
services:
es03:
image: elasticsearch:7.6.2
container_name: es03
restart: always
environment:
- node.name=es03
- network.publish_host=192.168.10.72
- discovery.seed_hosts=192.168.10.70,192.168.10.71
- cluster.initial_master_nodes=192.168.10.70,192.168.10.71,192.168.10.72
- cluster.name=es-docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms8196m -Xmx8196m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /home/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- /home/es/data:/usr/share/elasticsearch/data
- /home/es/plugins:/usr/share/elasticsearch/plugins
- /home/es/logs:/usr/share/elasticsearch/logs
ports:
- 9200:9200
- 9300:9300
集群验证:
http://192.168.10.70:9200/_cat/nodes?pretty
查看分片:
curl 192.168.10.71:9200/_cat/shards