ElasticSeacrh版本号:7.5.1
1、需要在配置文件中开启x-pack验证,修改config目录下面的elasticsearch.yml文件,在里面添加如下内容,并重启elasticsearch服务。
[root@localhost config]# vim elasticsearch.yml
# 配置X-Pack
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
2、重启elasticsearch服务
[root@localhost config]# su - elk
[elk@localhost ~]$ kill -9 2932
[elk@localhost ~]$ /usr/local/elasticsearch/bin/elasticsearch -d
3、执行设置用户名和密码的命令,这里需要为4个用户分别设置密码,elastic、kibana、logstash_system、beats_system
[elk@localhost ~]$ /usr/local/elasticsearch/bin/elasticsearch-setup-passwords interactive
future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk1.8.0_181/jre] does not meet this requirement
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y
Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana]:
Reenter password for [kibana]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
4、修改kibana.yml配置文件,添加以下配置
[elk@localhost ~]$ vim /usr/local/kibana/config/kibana.yml
elasticsearch.username: "elastic"
elasticsearch.password: "123456"
5、重启Kibana服务
[elk@localhost ~]$ kill -9 13666
[elk@localhost ~]$ /usr/local/kibana/bin/kibana &
6、验证
#浏览器输入本机IP+端口,会出现如下界面
至此,elasticsearch配置用户名和密码成功。
7、修改elasticsearch用户名密码
[elk@localhost ~]$ curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'
# 修改密码之后,需要重新设置kibana的配置文件,才可以重新使用Kibana。
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!
广东省深圳市 电信 1F
写的不错。