elasticsearch集羣的部署

elasticsearch集羣的部署
1.部署4個節點的elasticsearch
10.41.2.84     es2
10.41.2.85     es3
10.41.2.86     es4

2.集羣配置

2.1配置10.41.2.84上的es
vi   /usr/local/search/elasticsearch-1.3.1/config/elasticsearch.yml


cluster.name: escluster            #集羣的名稱,同一個集羣該值必須設置成相同的
node.name: "es2"                   #該節點的名字
node.master: true                  #該節點有機會成爲master節點
node.data: true                     #該節點可以存儲數據
node.rack: rack2                   #該節點所屬的機架
index.number_of_shards: 5             #shard的數目
index.number_of_replicas: 3           #數據副本的數目
network.bind_host: 0.0.0.0              #設置綁定的IP地址,可以是IPV4或者IPV6
network.publish_host: 10.41.2.84         #設置其他節點與該節點交互的IP地址
network.host: 10.41.2.84                       #該參數用於同時設置bind_host和publish_host
transport.tcp.port: 9300                        #設置節點之間交互的端口號
transport.tcp.compress: true                #設置是否壓縮tcp上交互傳輸的數據  
http.port: 9200                                    #設置對外服務的http 端口號   
http.max_content_length: 100mb       #設置http內容的最大大小
http.enabled: true                               #是否開啓http服務對外提供服務
discovery.zen.minimum_master_nodes: 2  #設置這個參數來保證集羣中的節點可以知道其它N個有master資格的節點。默認爲1,對於大的集羣來說,可以設置大一點的值(2-4)
discovery.zen.ping.timeout: 120s                    #設置集羣中自動發現其他節點時ping連接的超時時間
discovery.zen.ping.multicast.enabled: true      #設置是否打開多播發現節點
discovery.zen.ping.unicast.hosts: ["10.41.2.84:9300","10.41.2.85:9300", "10.41.2.86:9300"]           #設置集羣中的Master節點的初始列表,可以通過這些節點來自動發現其他新加入集羣的節點





2.2配置10.41.2.85上的es

vi   /usr/local/search/elasticsearch-1.3.1/config/elasticsearch.yml

cluster.name: escluster            #集羣的名稱,同一個集羣該值必須設置成相同的
node.name: "es3"                   #該節點的名字
node.master: true                  #該節點有機會成爲master節點
node.data: true                     #該節點可以存儲數據
node.rack: rack3                   #該節點所屬的機架
index.number_of_shards: 5             #shard的數目
index.number_of_replicas: 3           #數據副本的數目
network.bind_host: 0.0.0.0              #設置綁定的IP地址,可以是IPV4或者IPV6
network.publish_host: 10.41.2.85         #設置其他節點與該節點交互的IP地址
network.host: 10.41.2.85                       #該參數用於同時設置bind_host和publish_host
transport.tcp.port: 9300                        #設置節點之間交互的端口號
transport.tcp.compress: true                #設置是否壓縮tcp上交互傳輸的數據  
http.port: 9200                                    #設置對外服務的http 端口號   
http.max_content_length: 100mb       #設置http內容的最大大小
http.enabled: true                               #是否開啓http服務對外提供服務
discovery.zen.minimum_master_nodes: 2  #設置這個參數來保證集羣中的節點可以知道其它N個有master資格的節點。默認爲1,對於大的集羣來說,可以設置大一點的值(2-4)
discovery.zen.ping.timeout: 120s                    #設置集羣中自動發現其他節點時ping連接的超時時間
discovery.zen.ping.multicast.enabled: true      #設置是否打開多播發現節點
discovery.zen.ping.unicast.hosts: ["10.41.2.84:9300","10.41.2.85:9300", "10.41.2.86:9300"]           #設置集羣中的Master節點的初始列表,可以通過這些節點來自動發現其他新加入集羣的節點













2.3配置10.41.2.86上的es

vi   /usr/local/search/elasticsearch-1.3.1/config/elasticsearch.yml


cluster.name: escluster            #集羣的名稱,同一個集羣該值必須設置成相同的
node.name: "es4"                   #該節點的名字
node.master: true                  #該節點有機會成爲master節點
node.data: true                     #該節點可以存儲數據
node.rack: rack4                   #該節點所屬的機架
index.number_of_shards: 5             #shard的數目
index.number_of_replicas: 3           #數據副本的數目
network.bind_host: 0.0.0.0              #設置綁定的IP地址,可以是IPV4或者IPV6
network.publish_host: 10.41.2.86         #設置其他節點與該節點交互的IP地址
network.host: 10.41.2.86                       #該參數用於同時設置bind_host和publish_host
transport.tcp.port: 9300                        #設置節點之間交互的端口號
transport.tcp.compress: true                #設置是否壓縮tcp上交互傳輸的數據  
http.port: 9200                                    #設置對外服務的http 端口號   
http.max_content_length: 100mb       #設置http內容的最大大小
http.enabled: true                               #是否開啓http服務對外提供服務
discovery.zen.minimum_master_nodes: 2  #設置這個參數來保證集羣中的節點可以知道其它N個有master資格的節點。默認爲1,對於大的集羣來說,可以設置大一點的值(2-4)
discovery.zen.ping.timeout: 120s                    #設置集羣中自動發現其他節點時ping連接的超時時間
discovery.zen.ping.multicast.enabled: true      #設置是否打開多播發現節點
discovery.zen.ping.unicast.hosts: ["10.41.2.84:9300","10.41.2.85:9300", "10.41.2.86:9300"]           #設置集羣中的Master節點的初始列表,可以通過這些節點來自動發現其他新加入集羣的節點




3.啓停
3.1啓動
/usr/local/search/elasticsearch-1.3.1/bin/service/elasticsearch   start    

3.2停止
/usr/local/search/elasticsearch-1.3.1/bin/service/elasticsearch   start    


4.測試
4.1Web-UI

Cluster Health API :http://10.41.2.85:9200/_cluster/health

Node Info API:http://10.41.2.85:9200/_nodes

the Index Status API:http://10.41.2.85:9200/A/_status











4.2restful
  •  curl -X GET http://10.41.2.85:9200/

  •  curl -X GET http://10.41.2.84:9200/

  •  curl -X GET http://10.41.2.86:9200/


5.添加刪除節點

5.1添加節點
節點配置如下:


vi   /usr/local/search/elasticsearch-1.3.1/config/elasticsearch.yml


cluster.name: escluster            #集羣的名稱,同一個集羣該值必須設置成相同的
node.name: "es1"                   #該節點的名字
node.master: false                  #該節點沒有機會成爲master節點
node.data: true                     #該節點可以存儲數據
node.rack: rack4                   #該節點所屬的機架
index.number_of_shards: 5             #shard的數目
index.number_of_replicas: 3           #數據副本的數目
network.bind_host: 0.0.0.0              #設置綁定的IP地址,可以是IPV4或者IPV6
network.publish_host: 10.41.2.83         #設置其他節點與該節點交互的IP地址
network.host: 10.41.2.83                       #該參數用於同時設置bind_host和publish_host
transport.tcp.port: 9300                        #設置節點之間交互的端口號
transport.tcp.compress: true                #設置是否壓縮tcp上交互傳輸的數據  
http.port: 9200                                    #設置對外服務的http 端口號   
http.max_content_length: 100mb       #設置http內容的最大大小
http.enabled: true                               #是否開啓http服務對外提供服務
discovery.zen.minimum_master_nodes: 2  #設置這個參數來保證集羣中的節點可以知道其它N個有master資格的節點。默認爲1,對於大的集羣來說,可以設置大一點的值(2-4)
discovery.zen.ping.timeout: 120s                    #設置集羣中自動發現其他節點時ping連接的超時時間
discovery.zen.ping.multicast.enabled: true      #設置是否打開多播發現節點
discovery.zen.ping.unicast.hosts: ["10.41.2.84:9300","10.41.2.85:9300", "10.41.2.86:9300"]           #設置集羣中的Master節點的初始列表,可以通過這些節點來自動發現其他新加入集羣的節點






啓動該節點:

/usr/local/search/elasticsearch-1.3.1/bin/service/elasticsearch   start    


查看集羣的狀態:

elasticsearch採用廣播的方式自動發現節點,需要等待一段時間才能發現新的節點:
耐心等待。。。





可以看到新的節點es1:10.41.2.83已經加入到集羣escluster中了。



5.2刪除節點

停止一個節點(10.41.2.86)

/usr/local/search/elasticsearch-1.3.1/bin/service/elasticsearch   stop


查看集羣的狀態:
耐心等待。。。。




可以看出集羣escluster中已經沒有節點es4:10.41.2.86
























發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章