前言
今天在linux服务器上搭建elasticsearch索引库,但这段时间正在搞护网行动,所以elasticsearch和kibana就不能裸奔了,所以这篇文章我写了如何设置账户密码
- elasticsearch 使用版本7.6.2
- kibana 使用版本7.6.2
1. 设置elasticsearch账户密码,并且允许外部访问
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: No available authentication scheme
./elasticsearch-certutil ca

cd ..
ls

- 然后使用刚刚生成的证书,生成p12秘钥 ,进入bin目录执行
./elasticsearch-certutil cert --ca /usr/local/elk/elasticsearch-7.6.2/elastic-stack-ca.p12
 回到elasticsearch根目录,可以看到生成了elastic-certificates.p12这个文件 
cd /config
mkdir certs
cp /usr/local/elk/elasticsearch-7.6.2/elastic-certificates.p12 certs
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12
修改完配置文件之后重新启动elasticsearch
./elasticsearch-setup-passwords interactive
 将elasticsearch的9200端口对外开放,这里我直接关闭防火墙
systemctl stop firewalld
下图所示,这里我外部已经可以访问9200 了,并且访问需要账号密码
 外部访问成功 
2. 设置kibana账户密码
elasticsearch.hosts: ["http://localhost:9200"]
elasticsearch.username: "elastic"
elasticsearch.password: "123546"
重新启动kibana ,访问已经需要登录了 
3. logstash配置账号密码
output {
elasticsearch {
hosts => ["http://127.0.0.1:9200"]
user => "elastic"
passwrod => "123456"
index => "%{[fields][servicename]}-%{+yyyy.MM.dd}"
}
}
|