1. 程式人生 > >安裝keystone時創建用戶失敗

安裝keystone時創建用戶失敗

nor remote net class have sql hat 安全 過程

1.1. 安裝keystone時創建用戶報錯

1.1.1. 問題描述

安裝keystone在創建用戶時報錯:

The request you have made requires authentication. (HTTP 401) (Request-ID: req-03560e9f-bacc-4b0f-ac00-6ee4030cab8a)

1.1.2. 檢查過程

1.登陸mysql,查看keystone數據庫下有沒有生成新表

use keystone;

show tables;

發現keyston數據庫下沒有表生成,理論上運行如下語句後會生成表:

# su -s /bin/sh -c "keystone-manage db_sync" keystone

2.使用授權帳號和密碼嘗試登陸mysql

mysql -h localhost -u keystone -pKEYSTONE_DBPASS --登陸成功

mysql -h controller -u keystone -pKEYSTONE_DBPASS --登陸失敗

理論上使用controller主機名能登陸,因為授權對象包括%和localhost

3.查看keystone日誌

# vim /var/log/keystone/keystone.log

2018-07-20 13:59:29.019 2958 CRITICAL keystone [-] OperationalError: (pymysql.err.OperationalError) (1045, u"Access denied for user ‘keystone‘@‘controller‘ (using password: YES)")

發現登陸失敗信息

1.1.3. 解決方法

經過多次測試,如果在mysql安全初始化時,不移除匿名用戶、刪除test數據庫,就會出現以上授權問題

# mysql_secure_installation

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from ‘localhost‘.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named ‘test‘ that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...

自動腳本:

# mysql_secure_installation<<EOF

n
Y
Y
Y
Y
EOF

安裝keystone時創建用戶失敗