欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ElasticSearch基础——ElasticSearch6.x集群模式部署安装

程序员文章站 2022-06-01 12:45:13
...


之前我们进行了ElasticSearch的单节点安装部署,具体可以参考
ElasticSearch基础——ElasticSearch6.x单节点部署安装
这里我们在此基础之上进行集群模式部署安装。

节点规划

节点 角色
master(192.168.124.11) Elasticsearch、Kibana
slave1(192.168.124.12) Elasticsearch

解压文件

之前我们已经在master上安装ElasticSearch,这里我们在slave1上做相同操作。

## 解压文件
[[email protected] opt]# tar -zxvf elasticsearch-6.6.0.tar.gz -C /opt/
## 新建es用户
[[email protected] opt]# useradd es
## 设置密码
[[email protected] opt]# passwd es
## 给es用户赋权
[[email protected] opt]# chown -R es elasticsearch-6.6.0

修改ElasticSearch配置文件

这里我们分别对master和slave1节点上的配置文件elasticsearch.yml进行修改,这里以master配置文件为例。

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
# 集群名称,同一集群所有节点配置集群名称应该相同
cluster.name: bigdata-demo
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# 集群内各自节点名称唯一,这里我们master配置node-1,slave1配置node-2
node.name: node-1
...
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
# 这里可以分别设置为各自的IP或者都设置成0.0.0.0,表示不限制任何IP访问。
network.host: 192.168.124.11
#
# 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]"]
# 在master上配置其它节点(这里只有slave1)IP,在slave1上配置其它节点(这里只有master)IP,以此类推。
discovery.zen.ping.unicast.hosts: ["192.168.124.12"]

修改Kibana配置文件

# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
# 这里可以设置成master的IP(Kibana和master部署在同一个节点上),或者直接使用0.0.0.0
server.host: "192.168.124.11"

# The Kibana server's name.  This is used for display purposes.
# 这里设置为集群名称,即master和slave1配置文件中的cluster.name
server.name: "bigdata-demo"

# The URLs of the Elasticsearch instances to use for all your queries.
# 这里配置各个节点
elasticsearch.hosts: ["http://192.168.124.11:9200","http://192.168.124.12:9200"]

启动并查看集群状态

分别启动master和slave1上的ElasticSearch服务,然后启动Kibana,访问Web UI界面:http://192.168.124.11:5601
可以在Kibana上通过执行GET /_cluster/health查看集群健康状态

{
  "cluster_name" : "bigdata-demo",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 2,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}