0. 问题描述
无论什么情况导致Cloudera Manager的管理员用户由于密码登录异常,当需要重置admin密码时,就可以按照这篇文章逐步操作执行。
1. 解决办法
1.1 查看Cloudera Manager服务的数据库配置文件
登录Cloudera Manager所在的服务器,查看/etc/cloudera-scm-server/db.properties配置,获取CM数据库的用户名和密码等信息:
Administrator@WIN-1MAF14IC7DP MINGW64 ~/Downloads
$ ssh root@10.80.36.30
Last login: Fri Apr 10 17:42:31 2020 from 10.81.129.102
[root@bdpadmin ~]# ssh bdpcm01
Last login: Thu Apr 9 17:16:38 2020 from 192.168.1.30
[root@bdpcm01 ~]# cd /etc/cloudera-scm-server/
[root@bdpcm01 cloudera-scm-server]# ll
total 12
-rw-------. 1 cloudera-scm cloudera-scm 389 Dec 27 2017 db.properties
-rw-------. 1 cloudera-scm cloudera-scm 507 Oct 20 2016 db.properties.~1~
-rw-r--r--. 1 root root 1521 Oct 20 2016 log4j.properties
[root@bdpcm01 cloudera-scm-server]# cat db.properties
# Auto-generated by scm_prepare_database.sh on Wed Dec 27 03:19:48 CST 2017
#
# For information describing how to configure the Cloudera Manager Server
# to connect to databases, see the "Cloudera Manager Installation Guide."
#
com.cloudera.cmf.db.type=mysql
com.cloudera.cmf.db.host=192.168.1.36
com.cloudera.cmf.db.name=cm
com.cloudera.cmf.db.user=cm
com.cloudera.cmf.db.password=123456
1.2 登录到CM的数据库服务器
$ mysql -h hostname -u username -p [password] -D DBname
#确认本地IP地址,看在登录mysql数据库时是不是必须需要指定hostname.
[root@bdpcm01 cloudera-scm-server]# ifconfig bond0 | egrep -o "inet addr:[^ ]*" | grep -o "[0-9.]*"
10.80.36.36
You have new mail in /var/spool/mail/root
[root@bdpcm01 cloudera-scm-server]# ifconfig bond1 | egrep -o "inet addr:[^ ]*" | grep -o "[0-9.]*"
192.168.1.36
# 登录mysql,指定数据库名cm
[root@bdpcm01 cloudera-scm-server]# mysql -u cm -p -D cm
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11444721
Server version: 5.5.44-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT * FROM USERS WHERE USER_ID = 1;
+---------+-----------+------------------------------------------------------------------+---------------------+----------------+-------------------------+
| USER_ID | USER_NAME | PASSWORD_HASH | PASSWORD_SALT | PASSWORD_LOGIN | OPTIMISTIC_LOCK_VERSION |
+---------+-----------+------------------------------------------------------------------+---------------------+----------------+-------------------------+
| 1 | admin | 13ddefad5ab144aeaf0f845ff072231f6f6e0a96e5978b117b9c0d122779704e | 2899640814494508251 | 1 | 13 |
+---------+-----------+------------------------------------------------------------------+---------------------+----------------+-------------------------+
1 row in set (0.01 sec)
mysql> SELECT PASSWORD_HASH, PASSWORD_SALT FROM USERS WHERE USER_ID = 1;
+------------------------------------------------------------------+---------------------+
| PASSWORD_HASH | PASSWORD_SALT |
+------------------------------------------------------------------+---------------------+
| 13ddefad5ab144aeaf0f845ff072231f6f6e0a96e5978b117b9c0d122779704e | 2899640814494508251 |
+------------------------------------------------------------------+---------------------+
1 row in set (0.00 sec)
mysql> SELECT PASSWORD_HASH, PASSWORD_SALT FROM USERS WHERE USER_NAME = "admin";
+------------------------------------------------------------------+---------------------+
| PASSWORD_HASH | PASSWORD_SALT |
+------------------------------------------------------------------+---------------------+
| 13ddefad5ab144aeaf0f845ff072231f6f6e0a96e5978b117b9c0d122779704e | 2899640814494508251 |
+------------------------------------------------------------------+---------------------+
1 row in set (0.00 sec)
#备份admin管理员用户PASSWORD_HASH和PASSWORD_SALT信息到文本
#更新admin管理员用户PASSWORD_HASH和PASSWORD_SALT信息
mysql> update USERS set PASSWORD_HASH='2518db3278f704558ece63f469af87a7c12dbad8ff0971d3b677e291d61b44fc', PASSWORD_SALT=-5792243850706636683 WHERE USER_ID = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT PASSWORD_HASH, PASSWORD_SALT FROM USERS WHERE USER_NAME = "admin";
+------------------------------------------------------------------+----------------------+
| PASSWORD_HASH | PASSWORD_SALT |
+------------------------------------------------------------------+----------------------+
| 2518db3278f704558ece63f469af87a7c12dbad8ff0971d3b677e291d61b44fc | -5792243850706636683 |
+------------------------------------------------------------------+----------------------+
1 row in set (0.00 sec)
#备份密码为文本为了确保可以改回密码
mysql> update USERS set PASSWORD_HASH='13ddefad5ab144aeaf0f845ff072231f6f6e0a96e5978b117b9c0d122779704e', PASSWORD_SALT=2899640814494508251 WHERE USER_ID = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
#cloudera->cloudera 、 CM->admin
mysql> SELECT * FROM USERS WHERE USER_NAME IN ("admin","cloudera","CM");
+---------+-----------+------------------------------------------------------------------+----------------------+----------------+-------------------------+
| USER_ID | USER_NAME | PASSWORD_HASH | PASSWORD_SALT | PASSWORD_LOGIN | OPTIMISTIC_LOCK_VERSION |
+---------+-----------+------------------------------------------------------------------+----------------------+----------------+-------------------------+
| 1 | admin | 13ddefad5ab144aeaf0f845ff072231f6f6e0a96e5978b117b9c0d122779704e | 2899640814494508251 | 1 | 13 |
| 8 | cloudera | 90f0070e17755eed6cccbaea7fd96d1c5f1f9897c51648cf331dbd75745860e0 | 1585038119737244823 | 1 | 0 |
| 9 | CM | 1a845dd0bf0f35e313ad3bd7b696a041b74fc2b5343ee17b9a0750a69220cb3a | -4144583196928873757 | 1 | 1 |
+---------+-----------+------------------------------------------------------------------+----------------------+----------------+-------------------------+
3 rows in set (0.00 sec)