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

小柒博客 1 105,3623字数 423阅读1分24秒阅读模式

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。

若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!

继续阅读
Wechat
微信扫一扫,加我!
weinxin
微信号已复制
微信公众号
微信扫一扫,关注我!
weinxin
公众号已复制
小柒博客
  • 本文由 小柒博客 发表于 2020年3月24日 09:05:26
  • 声明:本站所有文章,如无特殊说明或标注,本站文章均为原创。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。转载请务必保留本文链接:https://www.yangxingzhen.com/6394.html
    • 小柒博客
      小柒博客

      写的不错。

    匿名

    发表评论

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

    拖动滑块以完成验证