系统:Linuxcentos7
ES版本:7.13.2
机器IP:192.168.211.137、192.168.211.132
首先确保这两台机器的ES和kibana能正常启动且已启动
1.ES的安装路径(随便找一台本集群内的机器):/usr/local/esk7/es01
cd /usr/local/esk7/es01
./bin/elasticsearch-certutil ca
./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
生成两个elastic-certificates.p12和elastic-stack-ca.p12文件把elastic-certificates.p12 文件拷贝到本集群其他机器的ES安装目录下的config目录下(包含这台机器)
vi config/elasticsearch.ym (在最后添加以下信息)
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.client_authentication: required
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
即yml文件的全部内容是:
-------------------------------------
cluster.name: es-cluster
node.name: node-2
node.master: true
node.data: true
node.ingest: true
node.ml: true
path.data: /path/to/data1
path.logs: /path/to/logs1
bootstrap.memory_lock: false
network.host: 192.168.211.137
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: ["192.168.211.137:9300","192.168.211.129:9300","192.168.211.132:9300"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
cluster.initial_master_nodes: ["192.168.211.137:9300","192.168.211.129:9300","192.168.211.132:9300"]
http.cors.enabled: true
http.cors.allow-origin: "*"
xpack.monitoring.collection.enabled: true
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.client_authentication: required
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
-----------------------------------------------------------------------------------------------
其他机器都添加完成后,重新启动ES集群(一个一个启动)
停止命令: ps -ef|grep elasticsearch kill 查到的进程
启动命令: cd /usr/local/esk7/es01
./bin/elasticsearch -d 备注:挂在了后台运行
设置密码(随便找一台机器就可以):
cd /usr/local/esk7/es01
./bin/elasticsearch-setup-passwords interactive
输入:y
然后输入要设置的密码(连续输12次,6个账户):
6个账户分别是:elastic、apm_system、kibana_system、logstash_system 、beats_system、remote_monitoring_user 本人因测试,输入的密码都是111111
试着输入IP:9200 在网页登陆看是否需要密码,如需要密码则,则ES设置成功(测试,一般用elastic 用户登陆)
打开kibana 的安装目录:
vi conf/kibana.yml
server.name: kibana
server.host: "0"
server.port: 5601
elasticsearch.hosts: [ "http://192.168.211.132:9200", "http://192.168.211.132:9201" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
elasticsearch.username: "kibana"
elasticsearch.password: "111111"
备注:username: "kibana"和 password: "111111"是和上边6个账户中的kibana的账户密码一致。
报错退出后,重启一下kibana,再打开kibana界面,看是否需要输入密码。