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
























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