在單臺服務器上部署多個節點,一般主要針對的是學習階段,正式環境一臺服務器只會部署一個節點,以實現分布式效果。下面是在單臺服務器部署兩個節點的方法。
1、將安裝好的elasticsearch-5.5.1文件夾在復制一份
cp -R elasticsearch-5.5.1
elasticsearch-5.5.1-node-2 #復制一份node-2ls -l #查看屬于哪個用戶哪個組,若和第一份不屬于同一個用戶和同一個組請更改
sudo chown elasticsearch:es
elasticsearch-5.5.1-node-2 #更改所屬用戶和組
2、修改配置文件(其實主要工作便是修改配置文件)
vim config/elasticsearch.yml #打開配置文件
cluster.name: dealerapi-Application #保持相同,不用改變
node.name: node-2 # 將node-1修改為 node-2
http.port: 9200 #http 訪問端口
transport.tcp.port: 9300 #內部通訊訪問接口
discovery.zen.ping.unicast.hosts: ["10.22.33.10:9300", "10.22.33.10:9301"] #配置多節點
3、分別開啟兩個節點
./bin/elasticsearch
4、查看是否配置成功
瀏覽器訪問:http://10.22.33.10:9200/_cluster/health?pretty 或者 http://10.22.33.10:9201/_cluster/health?pretty
cluster_name "dealerapi-application"
status "green"
timed_out false
number_of_nodes 2 #出現節點2
number_of_data_nodes 2
active_primary_shards 18
active_shards 36
relocating_shards 0
initializing_shards 0
unassigned_shards 0
delayed_unassigned_shards 0
number_of_pending_tasks 0
number_of_in_flight_fetch 0
task_max_waiting_in_queue_millis 0
active_shards_percent_as_number 100
看到:number_of_nodes 和number_of_data_nodes 數值為2,代表成功。






