Description:
When you bootstrap a configuration with mysqlrouter, the directory /var/lib/mysqlrouter is created as the root user with no permissions for the mysqlrouter user.
This causes mysqlrouter not to start at all.
How to repeat:
[root@mysql1 ~]# rm -rf /var/lib/mysqlrouter/
[root@mysql1 ~]# mysqlrouter --bootstrap mysql3:3306 --user mysqlrouter
Please enter MySQL password for root:
WARNING: The MySQL server does not have SSL configured and metadata used by the router may be transmitted unencrypted.
Reconfiguring system MySQL Router instance...
MySQL Router has now been configured for the InnoDB cluster 'perconalive'.
The following connection information can be used to connect to the cluster.
Classic MySQL protocol connections to cluster 'perconalive':
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447
X protocol connections to cluster 'perconalive':
- Read/Write Connections: localhost:64460
- Read/Only Connections: localhost:64470
Existing configurations backed up to /etc/mysqlrouter/mysqlrouter.conf.bak
[root@mysql1 ~]# ls -alhs /var/lib/mysqlrouter/
total 8.0K
0 drwx------. 2 root root 20 Apr 23 22:13 .
4.0K drwxr-xr-x. 34 root root 4.0K Apr 23 22:13 ..
4.0K -rw-------. 1 mysqlrouter mysqlrouter 120 Apr 23 22:13 keyring
[root@mysql1 ~]# mysqlrouter --version
MySQL Router v2.1.3 on Linux (64-bit) (GPL community edition)
You can see the username and password of the directory /var/lib/mysqlrouter is root:root with 700 permissions.
[root@mysql1 ~]# systemctl start mysqlrouter
[root@mysql1 ~]# systemctl status mysqlrouter
● mysqlrouter.service - MySQL Router
Loaded: loaded (/usr/lib/systemd/system/mysqlrouter.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2017-04-23 22:16:53 UTC; 3s ago
Process: 12390 ExecStart=/usr/bin/mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf (code=exited, status=1/FAILURE)
Main PID: 12390 (code=exited, status=1/FAILURE)
Apr 23 22:16:53 mysql1 systemd[1]: Started MySQL Router.
Apr 23 22:16:53 mysql1 systemd[1]: Starting MySQL Router...
Apr 23 22:16:53 mysql1 systemd[1]: mysqlrouter.service: main process exited, code=exited, status=1/FAILURE
Apr 23 22:16:53 mysql1 systemd[1]: Unit mysqlrouter.service entered failed state.
Apr 23 22:16:53 mysql1 systemd[1]: mysqlrouter.service failed.
When I start mysqlrouter manually I get the permissions denied error:
[root@mysql1 ~]# sudo -u mysqlrouter /usr/bin/mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf
Error: stat() failed (/var/lib/mysqlrouter/keyring): Permission denied
Let's fix it:
[root@mysql1 ~]# chown mysqlrouter. /var/lib/mysqlrouter/
[root@mysql1 ~]# systemctl start mysqlrouter
[root@mysql1 ~]# systemctl status mysqlrouter
● mysqlrouter.service - MySQL Router
Loaded: loaded (/usr/lib/systemd/system/mysqlrouter.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2017-04-23 22:21:27 UTC; 3s ago
Main PID: 12451 (main)
CGroup: /system.slice/mysqlrouter.service
└─12451 /usr/bin/mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf
Apr 23 22:21:27 mysql1 systemd[1]: Started MySQL Router.
Apr 23 22:21:27 mysql1 systemd[1]: Starting MySQL Router...
now it works!
Suggested fix:
Make the owner of /var/lib/mysqlrouter mysqlrouter: