Bug #96036 Service mysqlrouter starts but process exited
Submitted: 30 Jun 2019 19:00 Modified: 23 Aug 2019 11:53
Reporter: Vladmi Ivanochkenzoprano Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Router Severity:S2 (Serious)
Version:8.0.16 for Linux on x86_64 OS:Ubuntu (18.04.2 LTS (GNU/Linux 4.15.0-52-generic x86_64))
Assigned to: MySQL Verification Team CPU Architecture:x86

[30 Jun 2019 19:00] Vladmi Ivanochkenzoprano
Description:
Service mysqlrouter starts and active, but process status "exited".

My config located at /etc/mysqlrouter/mysqlrouter.conf contains:

[DEFAULT]
name=system
user=root
keyring_path=/var/lib/mysqlrouter/keyring
master_key_path=/etc/mysqlrouter/mysqlrouter.key
connect_timeout=15
read_timeout=30
dynamic_state=/var/lib/mysqlrouter/state.json

[logger]
level = INFO

[metadata_cache:personal]
router_id=7
user=mysql_router7_kj7msssz96w6
metadata_cluster=personal
ttl=0.5

[routing:default]
bind_address=0.0.0.0
bind_port=3306
destinations=metadata-cache://personal/default?role=PRIMARY
routing_strategy=first-available
protocol=classic

For start service I use command "sudo service mysqlrouter start". After that in status I can see:

● mysqlrouter.service - LSB: Start / Stop MySQL Router
   Loaded: loaded (/etc/init.d/mysqlrouter; generated)
   Active: active (exited) since Sun 2019-06-30 18:27:22 UTC; 17min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 5915 ExecStop=/etc/init.d/mysqlrouter stop (code=exited, status=0/SUCCESS)
  Process: 5931 ExecStart=/etc/init.d/mysqlrouter start (code=exited, status=0/SUCCESS)

Jun 30 18:27:22 webservicepersonal2o systemd[1]: Stopped LSB: Start / Stop MySQL Router.
Jun 30 18:27:22 webservicepersonal2o systemd[1]: Starting LSB: Start / Stop MySQL Router...
Jun 30 18:27:22 webservicepersonal2o mysqlrouter[5931]:  * Starting MySQL Router
Jun 30 18:27:22 webservicepersonal2o mysqlrouter[5931]:    ...done.
Jun 30 18:27:22 webservicepersonal2o systemd[1]: Started LSB: Start / Stop MySQL Router.

And command "lsof -i -P -n | grep LISTEN" shows that no listening 3306 port.

systemd-r  780 systemd-resolve   13u  IPv4  17461      0t0  TCP 127.0.0.53:53 (LISTEN)
sshd      1140            root    3u  IPv4  20873      0t0  TCP *:22 (LISTEN)
sshd      1140            root    4u  IPv6  20890      0t0  TCP *:22 (LISTEN)

Command "ps -ef | grep mysqlrouter" shows:
root      6088  4171  0 18:50 pts/1    00:00:00 grep --color=auto mysqlrouter

Logs located at /var/log/mysqlrouter/mysqlrouter.log is empty at all.

But if I start process manually using command "mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf &" it works properly, command lsof shows that port 3306 currently listening and I can connect to router via mysql client.

It looks like script /etc/init.d/mysqlrouter is broken.

How to repeat:
Just install mysql-router from APT repository and bootstrap it system-wide using command "mysqlrouter --bootstrap root@192.168.0.69:3306 --user=root"
[1 Jul 2019 13:40] MySQL Verification Team
Hi,

Have you tried using our binaries: https://dev.mysql.com/downloads/router/

I'm not reproducing this issue with our binearies

thanks
bogdan
[7 Jul 2019 11:11] Vladmi Ivanochkenzoprano
Anyway it may not work if you are install it using simple few steps:

1. wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
2. dpkg -i mysql-apt-config_0.8.13-1_all.deb
3. apt-get update
4. apt-get install mysql-router

After that, router has been installed successfully, but daemon not works.
[23 Jul 2019 11:53] MySQL Verification Team
Hi, weird, I'm not reproducing the problem, I'm using 19.04, but should behave identically.

Can you upload the log file?

thanks
Bogdan
[15 Aug 2019 10:05] Eric van Es
I had the same problem on Debian. My problem was that I ran the bootstrap as root user. This was set in the configuration file /etc/mysqlrouter/mysqlrouter.conf: user=root (as is in yours)

/etc/init.d/mysqlrouter wants to run the service as user mysqlrouter (start-stop-daemon is called with --chuid mysqlrouter). This creates a problem; mysqlrouter is started as that user, but tries to change to user root which is obviously not going to work.

I changed in /etc/mysqlrouter/mysqlrouter.conf the user to mysqlrouter and all was well in my setup.
[24 Aug 2019 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[22 Sep 2020 5:40] Henry Chen
Using this command is normal.

sudo mysqlrouter --user=mysqlrouter --bootstrap root@192.168.30.241:3306  --conf-use-sockets  --report-host localhost  --force