ELK集群设置密码
参考资料
注意
如果是集群的话,需要使用ssl的证书,只开XPACH的话,在设置账号密码会有报错,如下图
操作步骤
一、修改elasticsearch.yml的配置文件,每个节点都要加上如下标红的配置,并重启3个节点的ES
[root@ES1 ~]# grep "^[a-Z]" /data/elasticsearch-7.8.0/config/elasticsearch.yml
cluster.name: Log
node.name: node-1
path.data: /data/elk/data
path.logs: /data/elk/logs
bootstrap.memory_lock: true
network.host: 172.130.211.18
http.port: 9200
discovery.seed_hosts: ["172.130.211.18", "172.130.211.19", "172.130.211.20"]
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"
xpack.security.enabled: true
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
[root@ES1 ~]# sudo -u elasticsearch /data/elasticsearch-7.8.0/bin/elasticsearch -d
二、生成证书,过程期间什么都不需要输入一直回车回车就可以了
[root@ES1 ~]# sudo -u elasticsearch sh elasticsearch-certutil ca
[root@ES1 ~]# sudo -u elasticsearch sh elasticsearch-certutil cert --ca elastic-stack-ca.p12
然后就会生成两个文件elastic-stack-ca.p12和elastic-certificates.p12,然后把elastic-certificates.p12放在每个节点的config目录下面
三、设置账号密码
[root@ES1 ~]# sudo -u elasticsearch sh elasticsearch-setup-passwords interactive
四、修改Kibana的配置
[root@ES1 config]# grep "^[a-Z]" /etc/kibana/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://172.130.211.18:9200"]
elasticsearch.username: "kibana"
elasticsearch.password: "您的密码!"
i18n.locale: "zh-CN"
[root@ES1 config]# systemctl restart kibana.service
五、登陆Kibana