您的位置:首页 > 其它

Elasticsearch集群部署

burisi_ken 2021-02-22 16:52 29 查看 https://blog.51cto.com/dusthun

参考官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/7.11/rpm.html#rpm-repo

1、安装elasticsearch
# 导入KEY
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

# 配置YUM源
cd /etc/yum.repos.d/
vi elasticsearch.repo

[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md

# 安装elasticsearch

yum install --enablerepo=elasticsearch elasticsearch

# 设置自启动并启动elasticsearch服务
systemctl daemon-reload
systemctl enable elasticsearch

systemctl start elasticsearch
systemctl stop elasticsearch
2、集群配置

elasticsearch默认单机集群模式启动,需修改配置部署一个3节点集群,并将数据保存位置修改为指定位置

mkdir /sas/elasticsearch
chown -R elasticsearch:elasticsearch /sas/elasticsearch

vi /etc/elasticsearch/elasticsearch.yml

cluster.name: es-devops
node.name: devops01

path.data: /sas/elasticsearch

network.host: 10.255.200.1

discovery.seed_hosts: ["10.255.200.1", "10.255.200.2", "10.255.200.3"]

cluster.initial_master_nodes: ["devops01", "devops02", "devops03"]

# 重启服务
systemctl restart elasticsearch
3、启用安全认证
# 新版本的安全认证启用时必须启用SSL,否则会报错:
# Transport SSL must be enabled if security is enabled on a [basic] license. Please set [xpack.security.transport.ssl.enabled] to [true] or disable security by setting [xpack.security.enabled] to [false]

# 启用安全认证
vi /etc/elasticsearch/elasticsearch.yml

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.key: /etc/elasticsearch/sslkey/devops.key
xpack.security.transport.ssl.certificate: /etc/elasticsearch/sslkey/devops.crt

# 重启服务
systemctl restart elasticsearch

# 设置初始密码
/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
标签: