无法通过MaxScale连接应用程序

时间:2019-12-30 08:22:30

标签: mariadb galera maxscale

我有3个节点Galera Cluseter和一个用于maxscale的节点。问题是只有我在maxscale.cnf中定义的maxscale用户可以通过侦听器服务连接到集群。所有节点都在本地网络中并且可以互相看到。

maxscale.cnf

[maxscale]
threads=1

[Galera-Monitor]
type=monitor
module=galeramon
servers=server1,server2,server3
user=maxscale
password=qwe123
monitor_interval=1000

[Read-Write-Service]
type=service
router=readwritesplit
servers=server1, server2, server3
user=maxscale
password=qwe123

[Read-Only-Service]
type=service
router=readconnroute
servers=server1, server2, server3
user=maxscale
password=qwe123
router_options=slave

[Read-Write-Listener]
type=listener
service=Read-Write-Service
protocol=MariaDBClient
port=4006

[Read-Only-Listener]
type=listener
service=Read-Only-Service
protocol=MariaDBClient
port=4008

[server1]
type=server
address=192.168.122.93
port=3306
protocol=MariaDBBackend

[server2]
type=server
address=192.168.122.17
port=3306
protocol=MariaDBBackend

[server3]
type=server
address=192.168.122.13
port=3306
protocol=MariaDBBackend
root@maxscale:~# mysql -umaxscale -pqwe123 -h192.168.122.222 -P4006                                                                                   
Welcome to the MariaDB monitor.  Commands end with ; or \g. 
root@maxscale:~# mysql -umyuser -pmyuser -h192.168.122.222 -P4006
ERROR 1045 (28000): Access denied for user 'myuser'@'::ffff:192.168.122.222' (using password: YES)
root@sky:~# mysql -umyuser -pmyuser -h192.168.122.17
Welcome to the MariaDB monitor.  Commands end with ; or \g.

MariaDB [(none)]> show grants for myuser;
+-------------------------------------------------------------------------------------------------------+
| Grants for myuser@%                                                                                   |
+-------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'myuser'@'%' IDENTIFIED BY PASSWORD '*CBA73BBE5D9AF59311C3F4D7E8C20AA847F7B188' |
| GRANT ALL PRIVILEGES ON `mydatabase`.`pet` TO 'myuser'@'%'                                            |
+-------------------------------------------------------------------------------------------------------+

您可以看到myuser在通过maxscale节点进行连接时遇到问题。我如何解决此问题并使所有应用程序都通过自己的用户连接到maxscale。

编辑:

这是我的maxscale用户权限:

MariaDB [(none)]> show grants;
+--------------------------------------------------------------------------------------------------------------------------------+
| Grants for maxscale@192.168.122.222                                                                                            |
+--------------------------------------------------------------------------------------------------------------------------------+
| GRANT SHOW DATABASES ON *.* TO 'maxscale'@'192.168.122.222' IDENTIFIED BY PASSWORD '*8DCDD69CE7D121DE8013062AEAEB2A148910D50E' |
| GRANT SELECT ON `mysql`.`db` TO 'maxscale'@'192.168.122.222'                                                                   |
| GRANT SELECT ON `mysql`.`user` TO 'maxscale'@'192.168.122.222'                                                                 |
+--------------------------------------------------------------------------------------------------------------------------------+

1 个答案:

答案 0 :(得分:1)

基于以下有用链接:https://mariadb.com/kb/en/maxscale-troubleshooting/

检查节点配置的以下特权:

GRANT SELECT ON mysql.user TO 'maxscale'@'maxscalehost';
GRANT SELECT ON mysql.db TO 'maxscale'@'maxscalehost';
GRANT SELECT ON mysql.tables_priv TO 'maxscale'@'maxscalehost';
GRANT SELECT ON mysql.roles_mapping TO 'maxscale'@'maxscalehost';
GRANT SHOW DATABASES ON *.* TO 'maxscale'@'maxscalehost';