基础部分安装请参考博主之前的单节点安装:
Elasticsearch8.1基于CentOS7.9的单机安装_yangkei的博客-CSDN博客
集群安装的方式,将单节点es复制,修改相应的端口和配置文件,在一台服务器上将运行两个ES节点组成的集群。
Part1 ES集群安装配置。
1,拷贝单节点的ES文件
拷贝之前修改配置文件(具体每个参数的意义可以网上查询):
/app/es/config/elasticsearch.yml
[es@localhost config]$ grep -v "#" elasticsearch.yml |grep -v "^$"
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
transport.port: 9300
discovery.seed_hosts: ["192.168.88.8:9300", "192.168.88.8:9302"]
cluster.initial_master_nodes: ["node-1", "node-2"]
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: true
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
然后复制节点2:
cd /app
cp -R es es2
2, 删除es2节点的数据目录数据
[es@localhost data]$ ll
total 12
drwxrwxr-x. 15 es es 4096 Oct 16 14:35 indices
-rw-rw-r--. 1 es es 0 Oct 16 14:35 node.lock
-rw-rw-r--. 1 es es 115 Oct 16 14:35 nodes
drwxrwxr-x. 2 es es 42 Oct 16 14:35 snapshot_cache
drwxrwxr-x. 2 es es 4096 Oct 16 14:35 _state
[es@localhost data]$ pwd
/app/es2/data
[es@localhost data]$ rm -rf ./*
删除数据以后接下来依然可以加入集群。
3,修改节点2的配置文件
vi /app/es2/config/elasticsearch.yml
[es@localhost config]$ grep -v "#" elasticsearch.yml |grep -v "^$"
node.name: node-2
network.host: 0.0.0.0
http.port: 9202
transport.port: 9302
discovery.seed_hosts: ["192.168.88.8:9300", "192.168.88.8:9302"]
cluster.initial_master_nodes: ["node-1", "node-2"]
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: true
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
注:如果要配置三节点集群采用类似的方法。
JVM部分设置:/app/es/config/jvm.options,app/es/config/jvm.options
##
-Xms4g
-Xmx4g
##
这块根据自己服务器内存的情况进行配置,如果内存不足需要适当调小,默认为4GB。
4,启动ES集群
启动集群1节点
[es@localhost bin]$ /app/es/bin/elasticsearch
启动成功后启动2节点
[es@localhost bin]$ /app/es2/bin/elasticsearch
通过chrome浏览器的Elasticsearch-head插件查看集群状态:
节点1

节点2:

备注:集群之间的安全配置,启动集群的时候自动生成的,不用手动配置。
Part2 Kibana启动配置
[es@localhost bin]$ /app/kibana/bin/kibana
启动完成后访问:http://192.168.88.8:5601/
可以进行集群检查的查询操作:

查询之前导入的sample index数据:
至此,ES8.1的集群安装配置完成。
本文介绍了如何在CentOS7.9上搭建Elasticsearch8.1的两节点集群。首先,参照单节点安装教程配置基础环境,然后复制节点并修改配置文件,包括端口、节点名称和集群参数。接着删除第二个节点的数据目录,启动两个节点,通过Elasticsearch-head插件检查集群状态。最后启动Kibana并进行集群检查。
1106

被折叠的 条评论
为什么被折叠?



