标签:分配 cas war ubuntu 界面 soft 并且 gravity 一个
多机集群中的节点可以分为master nodes和data nodes,在配置文件中使用Zen发现(Zen discovery)机制来管理不同节点。Zen发现是ES自带的默认发现机制,使用多播发现其它节点。只要启动一个新的ES节点并设置和集群相同的名称这个节点就会被加入到集群中。
Elasticsearch集群中有的节点一般有三种角色:master node、data node和client node。
选取10.90.4.9这台机器做为client node,elasticsearch.yml中的配置如下:
cluster.name: ucas node.name: node-09 node.master: true node.data: false network.host: 0.0.0.0 discovery.zen.ping.unicast.hosts: ["10.90.4.9"] discovery.zen.ping.multicast.enabled: true
注意端口不是9200,而是9300。也可以不写端口。
启动10.90.4.9上的es服务器,现在只是一个单机集群。
在10.90.4.8这台机器上配置好同样的ES作为master node,elasticsearch.yml中的配置如下:
cluster.name: ucas node.name: node-08 node.master: true node.data: true network.host: 0.0.0.0 discovery.zen.ping.unicast.hosts: ["10.90.4.9"] discovery.zen.ping.multicast.enabled: true
10.90.4.7作为data node,配置如下:
cluster.name: ucas node.name: node-07 node.master: false node.data: true network.host: 0.0.0.0 discovery.zen.ping.unicast.hosts: ["10.90.4.9"] discovery.zen.ping.multicast.enabled: true
访问http://10.90.4.9:9200/_plugin/head/
如图,node-09为client节点,不存储数据。
ELasticsearch 5.4要求JDK版本最低为1.8,由于服务器上的JDK版本为1.7并且Java环境变量写在/etc/profile里面,改JDK会影响其他程序,这次基于5.4在我的mac和另外一台Ubuntu 做测试。
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组成集群,界面如下:
如果想要在一台机器上启动多个节点,步骤如下:
master配置文件:
cluster.name: myelasticsearch
node.name: node-1
network.host: 192.168.253.6
http.port: 9201
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master:true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.253.6"]
data配置文件:
cluster.name: myelasticsearch
node.name: node-2
network.host: 192.168.253.6
http.port: 9201
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master:true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.253.6"]
参考文献:
http://blog.csdn.net/napoay/article/details/52202877
mac 下搭建Elasticsearch 5.4.3分布式集群
标签:分配 cas war ubuntu 界面 soft 并且 gravity 一个
原文地址:http://www.cnblogs.com/wangchuanfu/p/7426944.html