MySQL Replication User

Currently, I have 2 servers running mysql 5.1. Im setting them up as a lead slave. Both have a static IP address and are not part of any domain. (they are currently located on the vmware local network)

The question is the same as in the mysql documentation, which says that u should configure the domain user for replication, although I don't have a domain.

How can I configure the user so that I can replicate 2 servers? This is the original line from the documentation:

CREATE USER 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass'; 
+4
source share
2 answers

If you only need a slave to be able to connect to the master from one IP address, you do not need a domain user, but rather use a static IP address.

If the slave has a host name, then the host will allow its use. This is evidenced by documents.

 GRANT REPLICATION SLAVE ON *.* TO 'repl'@'slaveserver.example.com' IDENTIFIED BY 'slavepass'; -- Or if the replication slave isn't in DNS, as in your situation, use its IP -- Assumes replication slave IP is 192.168.1.1 GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.1.1' IDENTIFIED BY 'slavepass'; 
+3
source

Let's pretend that

 SERVER1 (192.168.0.100) SERVER2 (192.168.0.200) 

If you are replicating, then SERVER1 will need to have access to MySQL on SERVER2 (and possibly vice versa if SERVER2 needs access to SERVER1). To do this, you need a USER who is allowed access from another server, i.e.

 -- User on SERVER1 that SERVER2 would use to repllicate CREATE USER 'repl'@'192.168.0.200' IDENTIFIED BY 'slavepass'; -- User on SERVER2 that SERVER1 would use to repllicate CREATE USER 'rep2'@'192.168.0.100' IDENTIFIED BY 'slavepass'; 

For ease of use, you can later apply them to the domain name, i.e.

 SERVER1 (192.168.0.100) server1.mydomain.com SERVER2 (192.168.0.200) server2.mydomain.com 

And then for the sake of consistency, you can simply have the next user on both SERVER1 and SERVER2

 -- User on SERVER1 that SERVER2 would use to repllicate CREATE USER 'rep'@'%.mydomain.com' IDENTIFIED BY 'slavepass'; -- User on SERVER2 that SERVER1 would use to repllicate CREATE USER 'rep'@'%.mydomain.com' IDENTIFIED BY 'slavepass'; 

The domain does not even have to be real if physical servers can resolve them, i.e. you can add the following to host files.

 -- On SERVER1 add the following into /etc/hosts server2.mydomain.com 192.168.0.200 -- On SERVER2 add the following into /etc/hosts server1.mydomain.com 192.168.0.100 

If your server is Windows based, you will probably find hosts in C:\Windows\system32\drivers\etc\hosts

+6
source

Source: https://habr.com/ru/post/1398042/


All Articles