6.1.elasticsearch7.0.1多机集群配置(2019-05-15)

ELasticsearch 7.0.1 要求JDK版本最低为1.8,但是ELasticsearch 7.0.1已经在项目里面自带JDK,所以不用额外安装JDK了;

配置集群之前 ,先要把加入集群节点里的data目录下的Node目录 删除,否则集群建立会失败。

我这边虚拟机配置了两台centos,IP分别是 192.168.75.206(head安装在此节点)和 192.168.75.128 ;

分别配置下elasticsearch.yml配置文件:
1.206机器(作为master服务器):
[root@bogon es]# vim /home/es/elasticsearch/config/elasticsearch.yml
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /home/es/elasticsearch/data
#
# Path to log files:
#
path.logs: /home/es/elasticsearch/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.75.206
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["192.168.75.206"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
cluster.initial_master_nodes: ["192.168.75.206"]
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true 
#只有head节点需要配置,其他非head节点不要配置,不然建不起集群
http.cors.enabled: true
http.cors.allow-origin: "*"

 

2.128机器:
[root@bogon es]# vim /home/es/elasticsearch/config/elasticsearch.yml
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-2
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /home/es/elasticsearch/data
#
# Path to log files:
#
path.logs: /home/es/elasticsearch/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.75.128
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["192.168.75.206"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
cluster.initial_master_nodes: ["192.168.75.206"]
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true 


3.规则说明:
cluster.name:这里两台机器的此配置必须一致 这样才算一个集群
node.name:节点名称每台取不同的名称,用来表示不同的集群节点
network.host:配置成自己的局域网IP
http.port:端口默认是9200
discovery.seed_hosts:主动发现节点我们都配置成206节点IP
cluster.initial_master_nodes:初始化master节点IP,我们配置成206节点IP

 

4.配置完后 重启es服务(建议先启master):
[root@bogon root]# ps -ef | grep elasticsearch  #找到进程号
[root@bogon root]# kill -9 进程号
[root@bogon root]# su elastic
[elastic@bogon root]$ ES_PATH_CONF=/home/es/elasticsearch/config sh /home/es/elasticsearch-7.0.1/bin/elasticsearch -d 
然后在head插件我们查看下:

说明集群配置OK 。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值