ES集群
机器准备
| 节点名称 | 主机名 | IP地址 |
|---|---|---|
| 节点1 | centos8 | 192.168.195.105 |
| 节点2 | centos8-1 | 192.168.195.106 |
| 节点3 | centos8-2 | 192.168.195.107 |
三个节点分别执行
# 修改各自的主机名
sudo hostnamectl set-hostname centos8
sudo hostnamectl set-hostname centos8-1
sudo hostnamectl set-hostname centos8-2
# 修改hosts文件,每台加入以下全部内容
cat >> /etc/hosts <<EOF
192.168.195.105 centos8
192.168.195.106 centos8-1
192.168.195.107 centos8-2
EOF
# 关闭防火墙和selinux
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
sudo setenforce 0
集群搭建
1.安装ES 安装参考
2.配置文件修改
#节点1上
vi /etc/elasticsearch/elasticsearch.yml #改为如下
cluster.name: centos8-es
node.name: centos8
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 192.168.222.101
http.port: 9200
discovery.seed_hosts: ["192.168.222.101", "192.168.222.102", "192.168.222.103"]
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: false
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
cluster.initial_master_nodes: ["centos8", "centos8-1", "centos8-2"]
http.host: 0.0.0.0
#节点2上
vi /etc/elasticsearch/elasticsearch.yml #改为如下
cluster.name: centos8-es
node.name: centos8-1
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 192.168.222.102
http.port: 9200
discovery.seed_hosts: ["192.168.222.101", "192.168.222.102", "192.168.222.103"]
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: false
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
cluster.initial_master_nodes: ["centos8", "centos8-1", "centos8-2"]
http.host: 0.0.0.0
#节点3上
vi /etc/elasticsearch/elasticsearch.yml #改为如下
cluster.name: centos8-es
node.name: centos8-2
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 192.168.222.103
http.port: 9200
discovery.seed_hosts: ["192.168.222.101", "192.168.222.102", "192.168.222.103"]
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: false
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
cluster.initial_master_nodes: ["centos8", "centos8-1", "centos8-2"]
http.host: 0.0.0.0
3.同步证书 节点1上操作 将第一台机器上的证书:/etc/elasticsearch/certs/*.p12 以及 keystore文件/etc/elasticsearch/elasticsearch.keystore同步到另外两台
scp -r /etc/elasticsearch/certs/* centos8-1:/etc/elasticsearch/certs/
scp -r /etc/elasticsearch/certs/* centos8-2:/etc/elasticsearch/certs/
scp /etc/elasticsearch/elasticsearch.keystore centos8-1:/etc/elasticsearch/
scp /etc/elasticsearch/elasticsearch.keystore centos8-2:/etc/elasticsearch/
4.启动服务(三台都操作)
systemctl start elasticsearch
systemctl enable elasticsearch
集群log位于 /var/log/elasticsearch/集群名字.log 下 5.设置密码(第一台上)
/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic