標籤:

elastic search集群配置

通過docker配置基於 elastic search的兩個node的集群,熟悉elastic search配置和了解shards replicas。

docker環境

通過docker可以快速在一個host上面,搭建多節點cluster 環境。 創建如下兩個節點

docker pull elasticsearchdocker run -d --name es-node2 -p 9200:9200 -v ~/docker/es-node2:/home/alex elasticsearchdocker run -d --name es-node3 --link es-node2 -v ~/docker/es-node3:/home/alex elasticsearch

es-node2作為主node,es-node3作為從node

? ~ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fa8816f65854 elasticsearch "/docker-entrypoint.s" 34 minutes ago Up 3 seconds 9200/tcp, 9300/tcp es-node3 44a8cfc9fce1 elasticsearch "/docker-entrypoint.s" 36 minutes ago Up 5 seconds 0.0.0.0:9200->9200/tcp, 9300/tcp es-node2

配置elasticsearch.yml

進去Mac主機的映射目錄,配置elasticsearch.yml

? ~ cd es-node2 ? ~ cat elasticsearch.yml 加入cluster.name: "cluster" node.name: node-2 node.master: true node.data: true network.host: 0.0.0.0 discovery.zen.ping.multicast.enabled: false discovery.zen.ping.unicast.hosts: ["172.17.0.2", "172.17.0.3"] discovery.zen.minimum_master_nodes: 1 discovery.zen.ping.timeout: 3s? ~ cd es-node3? ~ cat elasticsearch.yml 加入cluster.name: "cluster" node.name: node-3 node.master: true node.data: true network.host: 0.0.0.0 discovery.zen.ping.multicast.enabled: false discovery.zen.ping.unicast.hosts: ["172.17.0.2", "172.17.0.3"] discovery.zen.minimum_master_nodes: 1 discovery.zen.ping.timeout: 3s

拷貝配置文件:

進入es-node2? ~ bash -c "clear && DOCKER_HOST=tcp://192.168.99.100:2376 DOCKER_CERT_PATH=/Users/alex/.docker/machine/machines/default DOCKER_TLS_VERIFY=1 docker exec -it es-node2 sh"# cp /home/alex/elasticsearch.yml /usr/share/elasticsearch/config進入es-node3? ~ bash -c "clear && DOCKER_HOST=tcp://192.168.99.100:2376 DOCKER_CERT_PATH=/Users/alex/.docker/machine/machines/default DOCKER_TLS_VERIFY=1 docker exec -it es-node3 sh"# cp /home/alex/elasticsearch.yml /usr/share/elasticsearch/config

重啟服務:

? ~ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e964e232c2d1 elasticsearch "/docker-entrypoint.s" 54 minutes ago Up 6 minutes 9200/tcp, 9300/tcp es-node3 18b936f6b729 elasticsearch "/docker-entrypoint.s" 54 minutes ago Up 6 minutes 0.0.0.0:9200->9200/tcp, 9300/tcp es-node2分別重啟container? ~ docker restart 18b936f6b729? ~ docker restart e964e232c2d1

訪問測試頁面

192.168.99.100:9200/_cl

可以看到如下信息: 兩個node,作為data_nodes

"number_of_nodes" : 2, "number_of_data_nodes" : 2,

安裝插件

進入兩個node,通過如下命令安裝kopf插件,

root@44a8cfc9fce1:/# /usr/share/elasticsearch/bin/plugin install lmenezes/elasticsearch-kopf/v2.0.1

未完...

推薦閱讀:

日誌分析的模式發現功能實現(1)
Elasticsearch到底能玩多大的數據量?
ElasticSearch優化系列三:索引過程
Elasticsearch 5:集群設置與管理(第二篇)

TAG:Elasticsearch |