Search code examples
mariadbgaleramaxscale

Failing to connect applications via MaxScale


I have 3 node Galera Cluseter and a node for maxscale. the problem is only maxscale user i have defined in maxscale.cnf can connect to cluster via listener service. all nodes are in local network and can see each other.

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'@'%'                                            |
+-------------------------------------------------------------------------------------------------------+

As you can see myuser have problem in connecting via maxscale node. How I can solve this problem and make so any application connect to maxscale with their own user.

edit:

This is my maxscale user permissions:

MariaDB [(none)]> show grants;
+--------------------------------------------------------------------------------------------------------------------------------+
| Grants for [email protected]                                                                                            |
+--------------------------------------------------------------------------------------------------------------------------------+
| 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'                                                                 |
+--------------------------------------------------------------------------------------------------------------------------------+

Solution

  • Base on this useful link: https://mariadb.com/kb/en/maxscale-troubleshooting/

    Check the below privileges on your nodes configurations:

    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';