1、安装elasticsearch参考官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/7.11/rpm.html#rpm-repo
# 导入KEYrpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch# 配置YUM源cd /etc/yum.repos.d/vi elasticsearch.repo[elasticsearch]name=Elasticsearch repository for 7.x packagesbaseurl=https://artifacts.elastic.co/packages/7.x/yumgpgcheck=1gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearchenabled=0autorefresh=1type=rpm-md# 安装elasticsearchyum install --enablerepo=elasticsearch elasticsearch# 设置自启动并启动elasticsearch服务systemctl daemon-reloadsystemctl enable elasticsearchsystemctl start elasticsearchsystemctl stop elasticsearch
2、集群配置elasticsearch默认单机集群模式启动,需修改配置部署一个3节点集群,并将数据保存位置修改为指定位置
mkdir /sas/elasticsearchchown -R elasticsearch:elasticsearch /sas/elasticsearchvi /etc/elasticsearch/elasticsearch.ymlcluster.name: es-devopsnode.name: devops01path.data: /sas/elasticsearchnetwork.host: 10.255.200.1discovery.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.ymlxpack.security.enabled: truexpack.security.transport.ssl.enabled: truexpack.security.transport.ssl.key: /etc/elasticsearch/sslkey/devops.keyxpack.security.transport.ssl.certificate: /etc/elasticsearch/sslkey/devops.crt# 重启服务systemctl restart elasticsearch# 设置初始密码/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive