[915]ElasticSearch设置用户名密码

2020-12-29 10:38:54 浏览数 (1)

1、需要在配置文件中开启x-pack验证, 修改config目录下面的elasticsearch.yml文件,在里面添加如下内容,并重启.

代码语言:javascript复制
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true

2、执行设置用户名和密码的命令,这里需要为4个用户分别设置密码,elastic, kibana, logstash_system,beats_system

代码语言:javascript复制
bin/elasticsearch-setup-passwords interactive
代码语言:javascript复制
D:softelasticsearch-7.10.0bin>elasticsearch-setup-passwords interactive
future versions of Elasticsearch will require Java 11; your Java version from [D:softjavajdk1.8.0_151jre] 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]

D:softelasticsearch-7.10.0bin>

3、修改密码命令如下

代码语言:javascript复制
curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'
4、修改kibana配置文件,config下的kibana.yml,添加如下内容
代码语言:javascript复制
elasticsearch.username: "elastic"
elasticsearch.password: "123456"

问题

current license is non-compliant for [jdbc]

通过 dbeaver 配置 jdbc 连接 es时报错 current license is non-compliant for [jdbc]

在官网 https://www.elastic.co/cn/subscriptions 搜索后发现需要白金级别

查看服务器es的license信息,发现 “type” : “basic”

代码语言:javascript复制
# curl -XGET http://localhost:9200/_license
{
  "license" : {
    "status" : "active",
    "uid" : "91546f48-bd7f-4a74-b4b9-889dece7db80",
    "type" : "basic",
    "issue_date" : "2020-05-12T20:10:42.742Z",
    "issue_date_in_millis" : 1589314242742,
    "max_nodes" : 1000,
    "issued_to" : "my-application",
    "issuer" : "elasticsearch",
    "start_date_in_millis" : -1
  }
}

修改成30天试用版,https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trial.html

启动trial license(30天试用)

代码语言:javascript复制
curl -H "Content-Type:application/json" -XPOST  http://127.0.0.1:9200/_xpack/license/start_trial?acknowledge=true -u elastic
Enter host password for user 'elastic':
{"acknowledged":true,"trial_was_started":true,"type":"trial"}curl: (6) Could not resolve host: 123456

再查看license信息时,内容已发生变化。

代码语言:javascript复制
# curl -XGET http://localhost:9200/_license
{
  "license" : {
    "status" : "active",
    "uid" : "275f23b1-7b57-4bfd-b309-16d9545aebfa",
    "type" : "trial",
    "issue_date" : "2020-05-14T03:16:54.139Z",
    "issue_date_in_millis" : 1589426214139,
    "expiry_date" : "2020-06-13T03:16:54.139Z",
    "expiry_date_in_millis" : 1592018214139,
    "max_nodes" : 1000,
    "issued_to" : "my-application",
    "issuer" : "elasticsearch",
    "start_date_in_millis" : -1
  }
}

此时在 dbeaver 里查看时,已正常显示。

参考:https://www.cnblogs.com/snail90/p/11444393.html https://www.cnblogs.com/yulibostu/articles/13515854.html https://blog.csdn.net/qq_35349114/article/details/100096115

问题: https://blog.csdn.net/ctypyb2002/article/details/106115691

0 人点赞