elasticSearch 7.X配置用户名密码访问

小柒博客
小柒博客
小柒博客
197
文章
79
评论
2020-03-2409:05:26 1 2,295 2045字阅读6分49秒

版本号: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.X配置用户名密码访问

至此,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。

继续阅读
  • 微信号
  • 微信扫一扫加我~~
  • weinxin
  • 微信公众号
  • 微信扫一扫关注我吧~~
  • weinxin
广告也精彩
小柒博客
  • 本文由 发表于 2020-03-2409:05:26
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

 

评论:1   其中:访客  1   博主  0
    • 小柒博客 小柒博客 3

      写的不错。