Search code examples
mysqlreplication

mysql CHANGE MASTER TO command's MASTER_HOST's length limitation


I'm trying to setup replication for my database which is powered by mysql 5.6.

The master uses RDS and the slave is built on EC2 instance, so the MASTER_HOST has a pretty long hostname (62 characters).

When I use change master to command to specify MASTER_HOST and start slave, show slave status gives me an connection error, which looks like the hostname is overflowed and part of the hostname string (which is 61 characters) has been saved (to master.info also).

I have tried another hostname, which is shorter, and succeeded.

I have checked the document but nothing about MASTER_HOST hostname length limitation has been mentioned.

Is this a bug? Or have I done anything wrong? Thanks in advance.


Solution

  • There is a limit of 60 characters for master host on MySQL side. But luckily you can create another Canonical Name (CNAME) that references to the original RDS URL. RFC 1034 mentioned that CNAME chain shouldn't break things. So you get the chain: your (sub)domain CNAME -> RDS CNAME -> RDS IP.

    Make sure you have nscd, pdnsd or alternative local DNS cache service is running to avoid too many frequent DNS lookups.