ElasticSearch cloud docker部署
- docker-compose.yml
version: '2'
services:
es:
image: harbor.kukagroup.com/library/elasticsearch:6.5.3
container_name: es
environment:
- "ES_JAVA_OPTS=-Xms2g -Xmx2g"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 131072
ports:
- 9200:9200
- 9300:9300
volumes:
- ./config/es.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
- /data/es-cluster/es/data:/usr/share/elasticsearch/data
command: elasticsearch
restart: always
es1:
image: harbor.kukagroup.com/library/elasticsearch:6.5.3
container_name: es1
environment:
- "ES_JAVA_OPTS=-Xms2g -Xmx2g"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 131072
ports:
- 9201:9200
- 9301:9300
volumes:
- ./config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
- /data/es-cluster/es1/data:/usr/share/elasticsearch/data
command: elasticsearch
restart: always
es2:
image: harbor.kukagroup.com/library/elasticsearch:6.5.3
container_name: es2
environment:
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 131072
ports:
- 9202:9200
- 9302:9300
volumes:
- ./config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
- /data/es-cluster/es2/data:/usr/share/elasticsearch/data
command: elasticsearch
restart: always
es3:
image: harbor.kukagroup.com/library/elasticsearch:6.5.3
container_name: es3
environment:
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 131072
ports:
- 9203:9200
- 9303:9300
volumes:
- ./config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
- /data/es-cluster/es3/data:/usr/share/elasticsearch/data
command: elasticsearch
restart: always
kibana:
image: harbor.kukagroup.com/library/kibana:6.5.3
container_name: kibana
environment:
- SERVER_NAME=kibana
- ELASTICSEARCH_URL=http://es:9200
- XPACK_MONITORING_ENABLED=true
ports:
- 5601:5601
depends_on:
- es
- es1
- es2
- es3
external_links:
- es
- es1
- es2
- es3
networks:
default:
external:
name: br0
- config - es.yml
cluster.name: elastic-cluster
node.name: es
node.master: true
node.data: true
network.host: 0.0.0.0
transport.host: es
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["es:9300", "es1:9300", "es2:9300", "es3:9300"]
discovery.zen.minimum_master_nodes: 3
discovery.zen.ping_timeout: 5s
bootstrap.memory_lock: true
action.destructive_requires_name: true
- config - es1.yml
cluster.name: elastic-cluster
node.name: es1
node.master: true
node.data: true
network.host: 0.0.0.0
transport.host: es1
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["es:9300", "es1:9300", "es2:9300", "es3:9300"]
discovery.zen.minimum_master_nodes: 3
discovery.zen.ping_timeout: 5s
bootstrap.memory_lock: true
action.destructive_requires_name: true
- config - es2.yml
cluster.name: elastic-cluster
node.name: es2
node.master: true
node.data: true
network.host: 0.0.0.0
transport.host: es2
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["es:9300", "es1:9300", "es2:9300", "es3:9300"]
discovery.zen.minimum_master_nodes: 3
discovery.zen.ping_timeout: 5s
bootstrap.memory_lock: true
action.destructive_requires_name: true
- config - es3.yml
cluster.name: elastic-cluster
node.name: es3
node.master: false
node.data: true
network.host: 0.0.0.0
transport.host: es3
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["es:9300", "es1:9300", "es2:9300", "es3:9300"]
discovery.zen.minimum_master_nodes: 3
discovery.zen.ping_timeout: 5s
bootstrap.memory_lock: true
action.destructive_requires_name: true
FAQ
- start error
bootstrap checks failed
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- 解决方案(docker安装):宿主机上执行
sysctl -w vm.max_map_count=262144
- 解决方案(本机安装): 编辑 /etc/sysctl.conf,追加一行以下内容:
vm.max_map_count=262144
保存后重新启动es 即可