搭建 ElasticSearch 6.1.3分散式叢集

weixin_34365417發表於2018-02-07

ELasticsearch 6.1.3要求JDK版本最低為1.8

mac上的本機ip為192.168.1.111,設為master節點,配置如下:

cluster.name: my-application
node.name: node-111

network.host: 192.168.1.111
http.port: 9200

http.cors.enabled: true
http.cors.allow-origin: "*"

node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.1.111"]

Ubuntu機器的ip位192.168.1.102,配置如下:

cluster.name: my-application
node.name: node-102

network.host: 192.168.1.102
http.port: 9200

http.cors.enabled: true
http.cors.allow-origin: "*"

node.master: false
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.1.111"]

先啟動mac上的master,再啟動Ubuntu上的slave節點,觀察輸出,會有一個node-102探測到master節點的提示:

2017-06-07T11:33:39,369][INFO ][o.e.c.s.ClusterService   ] [node-102] detected_master {node-111}{3dQd1RRVTMiKdTckM68nPQ}{H6Zu7PAQRWewUBcllsQWTQ}{192.168.1.111}{192.168.1.111:9300}, added {{node-111}{3dQd1RRVTMiKdTckM68nPQ}{H6Zu7PAQRWewUBcllsQWTQ}{192.168.1.111}{192.168.1.111:9300},}, reason: zen-disco-receive(from master [master {node-111}{3dQd1RRVTMiKdTckM68nPQ}{H6Zu7PAQRWewUBcllsQWTQ}{192.168.1.111}{192.168.1.111:9300} committed version [8]])'

訪問head,一個master一個slave組成叢集,介面如下:

2743275-72a9f7da67487398
這裡寫圖片描述

單機多節點叢集配置

如果想要在一臺機器上啟動多個節點,步驟如下:

1、複製一份ELasticsearch的安裝包
2、修改埠,比如一個是9200,一個是9205
3、刪除data目錄下的資料(如果是新解壓的安裝包就不必了)

相關文章