MySQL Router daemon not listening any ports

1.1k Views Asked by At

I installed the program as described here https://dev.mysql.com/doc/mysql-router/8.0/en/mysql-router-deploying-bootstrapping.html.

After installation, the service mysqlrouter was launched in the system. But this service does not listen any of the ports specified in the configuration file "/etc/mysqlrouter/mysqlrouter.conf".

Command lsof -i -P -n | grep LISTEN shows:

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) 

As you can see, only port 22 is listening.

To make the mysqlrouter listen to the port which defined in config file, I have to start it as a new process, using command mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf &.

After that, mysqlrouter listening the port and all is OK.

This is looks like that the service does not load the configuration file /etc/mysqlrouter/mysqlrouter.conf during startup, and uses default (empty) configuration, which not listening anything.

Configuration file contents:

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

How to make mysqlrouter daemon start working in accordance with the configuration file, and listen on the specified ports?

If I start mysqlrouter as a new process using command mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf & it works properly:

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)
main      3615            root    4u  IPv4  43469      0t0  TCP *:3306 (LISTEN)

Updated...

Command systemctl status mysqlrouter.service shows:

● mysqlrouter.service - LSB: Start / Stop MySQL Router
   Loaded: loaded (/etc/init.d/mysqlrouter; generated)
   Active: active (exited) since Sun 2019-06-30 16:49:14 UTC; 2min 48s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4089 ExecStop=/etc/init.d/mysqlrouter stop (code=exited, status=0/SUCCESS)
  Process: 4117 ExecStart=/etc/init.d/mysqlrouter start (code=exited, status=0/SUCCESS)

Jun 30 16:49:14 webservicepersonal2o systemd[1]: Starting LSB: Start / Stop MySQL Router...
Jun 30 16:49:14 webservicepersonal2o mysqlrouter[4117]:  * Starting MySQL Router
Jun 30 16:49:14 webservicepersonal2o mysqlrouter[4117]:    ...done.
Jun 30 16:49:14 webservicepersonal2o systemd[1]: Started LSB: Start / Stop MySQL Router.

As I said, service works, but it still does not listening ports.

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)
2

There are 2 best solutions below

0
On

Using this command is normal.

try this:

sudo mysqlrouter --user=mysqlrouter --bootstrap [email protected]:3306  --conf-use-sockets  --report-host localhost  --force
0
On

Use the following instead.

bind_address=127.0.0.1

I got the following:

netstat -ntlp
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      6117/mysqlrouter

Use dbhost: 127.0.0.1