ElasticSearch集群修改密码
[toc]
集群设置密码后通过下面这两个方法都可以进行密码修改
# 方法一
通过发送HTTP请求进行密码修改
$ curl -XPOST -u elastic "bigdata-01:9200/_security/user/elastic/_password" -H 'Content-Type: application/json' -d'{"password" : "123456789"}'
Enter host password for user 'elastic': # 输入我们原密码
1
2
2
password:123456789 指定的是我们修改后的密码
# 方法二
当我们想通过bin/elasticsearch-setup-passwords interactive
修改密码时,发现提示密码已经设置过了,没有办法再次设置。
tip:
echo -e 'y\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n'
这段命令是直接将987654当成密码设置,实现一行命令交互设置密码。
# echo -e 'y\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n' | bin/elasticsearch-setup-passwords interactive
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/src/jdk1.8.0_151/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
Failed to authenticate user 'elastic' against http://172.31.0.8:9200/_security/_authenticate?pretty
Possible causes include:
* The password for the 'elastic' user has already been changed on this cluster
* Your elasticsearch node is running against a different keystore
This tool used the keystore at /usr/hdp/3.1.5.0-152/elasticsearch/config/elasticsearch.keystore
ERROR: Failed to verify bootstrap password
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
删除.security-7
索引之后,就可以继续使用上面命令进行密码设置了。
删除索引
curl -X DELETE "http://bigdata-01:9200/.security-7" -u elastic:123456
1
重新设置密码,设置成功。
$ echo -e 'y\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n987654\n' | bin/elasticsearch-setup-passwords interactive
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/src/jdk1.8.0_151/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
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.
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]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
上次更新: 2024/04/08, 10:55:49