文件目錄:javascript
version: '3' services: es-master: image: elasticsearch:6.4.3 container_name: es-master restart: always volumes: - ./master/data:/usr/share/elasticsearch/data:rw - ./master/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./master/logs:/user/share/elasticsearch/logs:rw ports: - "9200:9200" - "9300:9300" es-node1: image: elasticsearch:6.4.3 container_name: es-node1 restart: always volumes: - ./node1/data:/usr/share/elasticsearch/data:rw - ./node1/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./node1/logs:/user/share/elasticsearch/logs:rw es-node2: image: elasticsearch:6.4.3 container_name: es-node2 restart: always volumes: - ./node2/data:/usr/share/elasticsearch/data:rw - ./node2/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./node2/logs:/user/share/elasticsearch/logs:rw es-head: image: tobias74/elasticsearch-head:6 container_name: es-head restart: always ports: - "9100:9100"
es-master:master節點,肯定分片位置,索引的新增、刪除請求分配java
es-node1:分片的 CRUD,以及搜索和整合操做
node
es-node2:分片的 CRUD,以及搜索和整合操做mysql
es-head:es的一個插件,目前官方版本只支持5.0。能夠瀏覽和查看數據,能夠類比於navcate相對於mysql的做用。sql
bootstrap.memory_lock: false cluster.name: "es-cluster" node.name: es-master node.master: true node.data: false network.host: 0.0.0.0 http.port: 9200 transport.tcp.port: 9300 discovery.zen.ping.unicast.hosts: *.*.*.*:9300, *.*.*.*:9301, *.*.*.*:9302 discovery.zen.minimum_master_nodes: 1 path.logs: /usr/share/elasticsearch/logs http.cors.enabled: true http.cors.allow-origin: "*" xpack.security.audit.enabled: true
http.cors.enabled: true http.cors.allow-origin: "*"
上面的配置是爲了使es-head能鏈接到es集羣
cluster.name: "es-cluster" node.name: node2 node.master: false node.data: true network.host: 0.0.0.0 http.port: 9202 transport.tcp.port: 9302 discovery.zen.ping.unicast.hosts: *.*.*.*:9300, *.*.*.*:9301, *.*.*.*:9302 path.logs: /usr/share/elasticsearch/logs
node1 的配置和node2的配置基本一致docker
docker-compose up
實線部分爲主分片,虛線部分爲副本分片。 上圖5個主分片和5個副本分片。 建立索引時候能夠制定主分片和副本分片的個數, 默認狀況下 5個主分片。1個副本分片(即每一個主分片一個副本分片)bootstrap
相關目錄上執行 chown 1000:1000 datacors
對應機器上執行 sudo sysctl -w vm.max_map_count=262144
elasticsearch