安装
groupadd elastic
useradd -g elastic elastic -s /sbin/sbin/nologin
mkdir /data/elasticsearch/
cd /data/elasticsearch/
wget http://shu.share/soft/linux/elk/elastic/elasticsearch-6.8.11.tar.gz
tar zxvf elasticsearch-6.8.11.tar.gz
chown -R elastic:elastic /data/elasticsearch/elasticsearch-6.8.11
vim /etc/sysctl.conf
#添加内容
vm.max_map_count=655360
# 使用配置生效
sysctl -p
hosts添加
#es
192.168.1.120 es-node1
192.168.1.121 es-node2
192.168.1.122 es-node3
开机自启
vim /etc/systemd/system/elasticsearch.service
[Unit]
Description=elasticsearch 6.8.11
After=network.target
[Service]
Type=forking
User=elastic
LimitNOFILE=65536
LimitNPROC=65536
ExecStart=/data/elasticsearch/elasticsearch-6.8.11/bin/elasticsearch -d
[Install]
WantedBy=multi-user.target
修改配置文件elasticsearch.yml
cluster.name: es-cluster
#节点主机名
node.name: es-node1
path.data: /data/elasticsearch/elasticsearch-6.8.11/data
path.logs: /data/elasticsearch/elasticsearch-6.8.11/logs
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.1.120", "192.168.1.121", "192.168.1.122"]
discovery.zen.minimum_master_nodes: 2
#跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"
#配置密码访问es集群
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
启动es(集群各机器)
systemctl start elasticsearch
防火墙放行
firewall-cmd --zone=public --add-port=9200/tcp --permanent&&firewall-cmd --reload
firewall-cmd --zone=public --add-port=9300/tcp --permanent&&firewall-cmd --reload
生成证书(其中1台机器)
cd /data/elasticsearch/elasticsearch-6.8.11
./bin/elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass ""
#修改属主
chown elastic:elastic elastic-certificates.p12
拷贝证书到其余节点相同目录
#修改属主
chown elastic:elastic elastic-certificates.p12
执行命令生成密码
/data/elasticsearch/elasticsearch-6.8.11/bin/elasticsearch-setup-passwords interactive
重启es(所有节点)
systemctl stop elasticsearch
systemctl start elasticsearch
查看集群
查看集群节点信息
http://192.168.1.120:9200/_cat/nodes?v
查看集群健康状态
http://192.168.1.120:9200/_cat/health?v
查看集群索引信息
http://192.168.1.120:9200/_cat/indices?v