自学内容网 自学内容网

es集群配置用户名密码

背景:项目中用到了es,平时自己玩es的时候,并没有设置用户名、密码,但是项目中需要有用户名密码,然后就搜索了以下,觉得还是自己记录一下好一些

一、 进入到config目录下,修改elasticsearch.yml文件

在配置文件中开启x-pack验证

xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
二、重新启动es
三、进入到bin目录下,执行下面的命令
elasticsearch-setup-passwords interactive

然后就是分别为下面的用户设置密码

[elastic@localhost bin]$ ./elasticsearch-setup-passwords interactive
future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/soft/jdk/jdk1.8.0_333/jre] does not meet this requirement
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,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_system]: 
Reenter password for [kibana_system]: 
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_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]

四、设置完成后,重新启动es集群即可,在浏览器上测试如下,输入你配置好的用户名、密码
{
  "name" : "es-01",
  "cluster_name" : "es_cluster",
  "cluster_uuid" : "Cz8e8lkvS0iswo2Cf9xRug",
  "version" : {
    "number" : "7.10.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "747e1cc71def077253878a59143c1f785afa92b9",
    "build_date" : "2021-01-13T00:42:12.435326Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

原文地址:https://blog.csdn.net/qq_38220334/article/details/138843010

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!