yandex / mysync

MySync is mysql high-availability and cluster configuration tool.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MySync ignores short server's name in mysync hosts add command

FactorT opened this issue · comments

Short description:
When you put short server name in mysync hosts add command, MySync ignores it, takes fqfn from the remote host and puts fqnd in zookeeper.
If you deploy your MySQL cluster via short server's name, MySync will fail with error

2023-12-05T15:02:56+03:00 INFO: active: []
2023-12-05T15:02:56+03:00 INFO: master: server1
2023-12-05T15:02:56+03:00 INFO: cs: map[server1:<ping=ok repl=master sync=--- ro=true offline=true lag=0.00 du=??? cr=??? gtid=184a9613-9366-11ee-b999-005056b39ebb:1-14> server2:<ping=ok repl=error sync=--- ro=true offline=true lag=NaN du=??? cr=??? gtid=184a9613-9366-11ee-b999-005056b39ebb:1-14>]
2023-12-05T15:02:56+03:00 INFO: dcs cs: map[server1:<ping=ERR repl=??? sync=??? ro=false offline=false lag=0.00 du=??? cr=??? gtid=???> server2:<ping=ERR repl=??? sync=??? ro=false offline=false lag=0.00 du=??? cr=??? gtid=???>]
2023-12-05T15:02:56+03:00 ERROR: MASTER FAILURE

Full description:

  1. Setup two servers Debian12:
  • server1.org.com
  • server2.org.com
  1. Every server has the same fqdn in /etc/hostname:
  • server1.org.com
  • server2.org.com
  1. Install MySQL and setup replication with server's short name: server1, server2
  2. Install MySync and run commands:
  • hosts add server1
  • hosts add server2
  1. Run zkCli.sh and run command:
[zk: localhost:2181(CONNECTED) 2] ls /mysql/cluster_id_2fb4f574-2ce8-59fb-a8c7-0dfbe20793e3/health
[server1.org.com, server2.org.com]
  1. You can see that MySync created records in zookeeper with fqdn: server1.org.com, server2.org.com
    Not with short names: server1, server2, server3
    And this is why MySyncs fails with error:
2023-12-05T15:02:56+03:00 INFO: active: []
2023-12-05T15:02:56+03:00 INFO: master: server1
2023-12-05T15:02:56+03:00 INFO: cs: map[server1:<ping=ok repl=master sync=--- ro=true offline=true lag=0.00 du=??? cr=??? gtid=184a9613-9366-11ee-b999-005056b39ebb:1-14> server2:<ping=ok repl=error sync=--- ro=true offline=true lag=NaN du=??? cr=??? gtid=184a9613-9366-11ee-b999-005056b39ebb:1-14>]
2023-12-05T15:02:56+03:00 INFO: dcs cs: map[server1:<ping=ERR repl=??? sync=??? ro=false offline=false lag=0.00 du=??? cr=??? gtid=???> server2:<ping=ERR repl=??? sync=??? ro=false offline=false lag=0.00 du=??? cr=??? gtid=???>]
2023-12-05T15:02:56+03:00 ERROR: MASTER FAILURE

MySync always takes server name from /etc/hostname of remote server, not from hosts add command
Is this behavior by design or bug?

Each mysql/mysync instance identifies itself with host's FQDN.
Mysync takes it from config Hostname option, or from /etc/hostname as default.
Mysync will report its health status under this name.

To make mysql/mysync instance member of the cluster we need to

  1. setup mysql instance, setup initial replication
  2. register instance explicitly with mysync hosts add hostname command

You should use the same hostname in mysync config (or /etc/hostname) and hosts add command.
MySQL instance should be accessible via this hostname.

TLDR: we recommend to always use FQDN (fully qualified domain name) both in config (or /etc/hostname) and hosts add command.