您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“Dockercompose如何建立ELK集群”,感興趣的朋友不妨來看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“Dockercompose如何建立ELK集群”吧!
規(guī)劃
計(jì)劃創(chuàng)建3個(gè)es實(shí)例組成一個(gè)集群,同時(shí)創(chuàng)建一個(gè)kibana實(shí)例連接該集群。每個(gè)es實(shí)例使用本地配置文件,方便配置文件的保存和版本管理。kibana的配置文件也放在本地,通過文件映射的方式掛載到容器內(nèi)。
總的目錄結(jié)構(gòu)如下:
$ tree . ├── docker-compose.yml ├── kibana.yml ├── node1 │ └── es1.yml ├── node2 │ └── es2.yml └── node3 └── es3.yml 3 directories, 5 files
編排文件
主要的編排文件是 docker-compose.yml
version: "2.1" services: es-node1: image: docker.elastic.co/elasticsearch/elasticsearch:6.7.0 hostname: es-node1 expose: #不會(huì)將端口暴露給容器外應(yīng)用 - "9001" ports: #將端口暴露到宿主機(jī)中 - "9200:9200" - "9300:9300" volumes: - ~/projects/sh-valley/docker-conf/elasticstack/cluster/node1/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml environment: - cluster.name=es-cluster - bootstrap.memory_lock=true - "es_java_opts=-xms256m -xmx256m" ulimits: memlock: soft: -1 hard: -1 networks: es-cluster-network: ipv4_address: 172.21.0.10 es-node2: image: docker.elastic.co/elasticsearch/elasticsearch:6.7.0 hostname: es-node2 expose: #不會(huì)將端口暴露給容器外應(yīng)用 - "9002" ports: #將端口暴露到宿主機(jī)中 - "9201:9201" - "9301:9301" volumes: - ~/projects/sh-valley/docker-conf/elasticstack/cluster/node2/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml environment: - cluster.name=es-cluster - bootstrap.memory_lock=true - "es_java_opts=-xms256m -xmx256m" ulimits: memlock: soft: -1 hard: -1 networks: es-cluster-network: ipv4_address: 172.21.0.11 es-node3: image: docker.elastic.co/elasticsearch/elasticsearch:6.7.0 hostname: es-node3 expose: #不會(huì)將端口暴露給容器外應(yīng)用 - "9003" ports: #將端口暴露到宿主機(jī)中 - "9202:9202" - "9302:9302" volumes: - ~/projects/sh-valley/docker-conf/elasticstack/cluster/node3/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml environment: - cluster.name=es-cluster - bootstrap.memory_lock=true - "es_java_opts=-xms256m -xmx256m" ulimits: memlock: soft: -1 hard: -1 networks: es-cluster-network: ipv4_address: 172.21.0.12 kibana: image: docker.elastic.co/kibana/kibana:6.7.0 ports: - "5601:5601" volumes: - ~/projects/sh-valley/docker-conf/elasticstack/cluster/kibana.yml:/usr/share/kibana/config/kibana.yml environment: - elasticsearch_url=http://es-node1:9200 networks: - es-cluster-network networks: es-cluster-network: driver: bridge ipam: driver: default config: - subnet: 172.21.0.0/16 gateway: 172.21.0.1
es配置文件只選取了一個(gè)示例如下:
cluster.name: elasticsearch-cluster node.name: es-node1 network.bind_host: 0.0.0.0 network.publish_host: 172.21.0.10 http.port: 9200 transport.tcp.port: 9300 http.cors.enabled: true http.cors.allow-origin: "*" node.master: true node.data: true discovery.zen.ping.unicast.hosts: ["172.21.0.10:9300","172.21.0.11:9301","172.21.0.12:9302"] discovery.zen.minimum_master_nodes: 2
kibana的配置文件如下
server.name: kibana server.host: "0" elasticsearch.hosts: [ "http://es-node1:9200", "http://es-node2:9201", "http://es-node3:9202" ] xpack.monitoring.ui.container.elasticsearch.enabled: false
啟動(dòng)命令
配置文件準(zhǔn)備好之后,就可以啟動(dòng)集群了
$ docker-compose up -d
啟動(dòng)過程可能會(huì)比較慢,通過命令行可以看到集群節(jié)點(diǎn)
$ curl http://localhost:9200/_cat/nodes 172.21.0.12 51 96 29 6.53 6.43 3.72 md - es-node3 172.21.0.11 47 96 30 6.53 6.43 3.72 mdi - es-node2 172.21.0.10 49 96 30 6.53 6.43 3.72 mdi * es-node1
后續(xù)使用過程中可以通過 docker-compose 命令啟動(dòng)、停止服務(wù),如果不想保留相關(guān)的實(shí)例,可以使用 docker-compose down 關(guān)閉并刪除容器。
到此,相信大家對(duì)“Dockercompose如何建立ELK集群”有了更深的了解,不妨來實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。