ElasticSearch搭建冷热架构的集群(5台)

准备工作和配置文件

准备5个ES安装包(linux环境)
在这里插入图片描述
1.ES9300:

#es会自动发现在同一网段下的es,所有节点都要填他
cluster.name: test
#节点名称,要唯一
node.name: test01
node.master: true
node.data: true
#节点的ip,填了这个也可以使用外网访问
network.host: 192.168.135.237
http.port: 9201
transport.tcp.port: 9301
#集群的ip+端口
discovery.zen.ping.unicast.hosts: ["192.168.135.237:9301","192.168.135.237:9302", "192.168.135.237:9303","192.168.135.237:9304","192.168.135.237:9305"]
discovery.zen.minimum_master_nodes: 1
node.attr.temperature: hot

2.ES9301:

#es会自动发现在同一网段下的es,所有节点都要填他
cluster.name: test
#节点名称,要唯一
node.name: test02
node.master: false
node.data: true
#节点的ip,填了这个也可以使用外网访问
network.host: 192.168.135.237
http.port: 9202
transport.tcp.port: 9302
#集群的ip+端口
discovery.zen.ping.unicast.hosts: ["192.168.135.237:9301","192.168.135.237:9302", "192.168.135.237:9303","192.168.135.237:9304","192.168.135.237:9305"]
discovery.zen.minimum_master_nodes: 1
node.attr.temperature: warm

3.ES9302:

#es会自动发现在同一网段下的es,所有节点都要填他
cluster.name: test
#节点名称,要唯一
node.name: test03
node.master: false
node.data: true
#节点的ip,填了这个也可以使用外网访问
network.host: 192.168.135.237
http.port: 9203
transport.tcp.port: 9303
#集群的ip+端口
discovery.zen.ping.unicast.hosts: ["192.168.135.237:9301","192.168.135.237:9302", "192.168.135.237:9303","192.168.135.237:9304","192.168.135.237:9305"]
discovery.zen.minimum_master_nodes: 1
node.attr.temperature: warm

4.ES9303:

#es会自动发现在同一网段下的es,所有节点都要填他
cluster.name: test
#节点名称,要唯一
node.name: test04
node.master: false
node.data: true
#节点的ip,填了这个也可以使用外网访问
network.host: 192.168.135.237
http.port: 9204
transport.tcp.port: 9304
#集群的ip+端口
discovery.zen.ping.unicast.hosts: ["192.168.135.237:9301","192.168.135.237:9302", "192.168.135.237:9303","192.168.135.237:9304","192.168.135.237:9305"]
discovery.zen.minimum_master_nodes: 1
node.attr.temperature: hot

5.ES9304:

#es会自动发现在同一网段下的es,所有节点都要填他
cluster.name: test
#节点名称,要唯一
node.name: test05
node.master: false
node.data: true
#节点的ip,填了这个也可以使用外网访问
network.host: 192.168.135.237
http.port: 9205
transport.tcp.port: 9305
#集群的ip+端口
discovery.zen.ping.unicast.hosts: ["192.168.135.237:9301","192.168.135.237:9302", "192.168.135.237:9303","192.168.135.237:9304","192.168.135.237:9305"]
discovery.zen.minimum_master_nodes: 1
node.attr.temperature: hot

总共配置概览:
热接点:test01,04,05
冷节点:test02,03

启动和停止集群脚本

启动脚本

前面路径只要换成自己的安装路径即可,这里是后台启动

#!/bin/bash
/opt/local_software/elasticsearch/es9300/bin/elasticsearch -d -p pid
/opt/local_software/elasticsearch/es9301/bin/elasticsearch -d -p pid
/opt/local_software/elasticsearch/es9302/bin/elasticsearch -d -p pid
/opt/local_software/elasticsearch/es9303/bin/elasticsearch -d -p pid
/opt/local_software/elasticsearch/es9304/bin/elasticsearch -d -p pid

停止脚本

#!/bin/bash
ps -aux | grep elasticsearch | grep -v grep | awk '{print $2}' | xargs kill -9 

验证集群状态

1.在地址栏中输入:

http://192.168.135.237:9201/_cat/health?v

可查看:
在这里插入图片描述
2.在kibana中输入(kibana不支持配置集群,只用配置到主节点test01上即可):
配置kibana,只用更改两项,其他的不用改:

server.host: "192.168.135.237"

# Enables you to specify a path to mount Kibana at if you are running behind a proxy. This only affects
# the URLs generated by Kibana, your proxy is expected to remove the basePath value before forwarding requests
# to Kibana. This setting cannot end in a slash.
#server.basePath: ""

# The maximum payload size in bytes for incoming server requests.
#server.maxPayloadBytes: 1048576

# The Kibana server's name.  This is used for display purposes.
#server.name: "your-hostname"

# The URL of the Elasticsearch instance to use for all your queries.
elasticsearch.url: "http://192.168.135.237:9201"

访问页面:

http://192.168.135.237:5601/

在Dev Tools模块中输入

GET _cat/nodeattrs?v&h=node,attr,value&s=attr:desc

验证完毕
在这里插入图片描述
集群的测试查看下一篇文章:
冷热分离原理以及实战

猜你喜欢

转载自blog.csdn.net/Zong_0915/article/details/107629707