linux搭建elasticsearch集群

我这里使用了两台服务器,其中一台服务器部署了一个es,另一台部署了两个。(如果有3台更好了)
比如:准备在39.100.113.100上安装一个,在39.100.113.101上安装两个。

elasticsearch的安装,安装参见:Linux安装elasticsearch6.2.4

  1. 安装好之后,修改配置文件elasticsearch.yml

39.100.113.100的配置:

#集群名称相同
cluster.name: es-cluster
#节点名不同
node.name: ali
discovery.zen.ping.unicast.hosts: ["39.100.113.101:9512", "39.100.113.101:9513", "39.100.113.100:9512"]
#参与主节点选举
node.master: true
#作为数据节点
node.data: true
network.host: 0.0.0.0
network.publish_host: 39.100.113.100
http.port: 9511
http.cors.enabled: true
http.cors.allow-origin: "*"
transport.tcp.port: 9512
cluster.routing.allocation.disk.threshold_enabled: false

39.100.113.101的配置:

#集群名称相同
cluster.name: es-cluster
#节点名不同
node.name: ali2
discovery.zen.ping.unicast.hosts: ["39.100.113.101:9512", "39.100.113.101:9513", "39.100.113.100:9512"]
#参与主节点选举
node.master: true
#作为数据节点
node.data: true
network.host: 0.0.0.0
network.publish_host: 39.100.113.101
http.port: 9511
http.cors.enabled: true
http.cors.allow-origin: "*"
transport.tcp.port: 9512
cluster.routing.allocation.disk.threshold_enabled: false
#集群名称相同
cluster.name: es-cluster
#节点名不同
node.name: ali3
discovery.zen.ping.unicast.hosts: ["39.100.113.101:9512", "39.100.113.101:9513", "39.100.113.100:9512"]
#不参与主节点选举
node.master: false
#不作为数据节点
node.data: false
network.host: 0.0.0.0
network.publish_host: 39.100.113.101
http.port: 9510
http.cors.enabled: true
http.cors.allow-origin: "*"
transport.tcp.port: 9513
cluster.routing.allocation.disk.threshold_enabled: false
  1. 重新启动3个es
  2. 输入命令 curl http://39.100.113.101:9511/_cat/nodes?v查看列表是否显示三台服务

你可能感兴趣的:(elasticsearch)