Iptables setting after mysql master-slave synchronization is enabled
BitsCN.com
Iptables setting after mysql master-slave synchronization is enabled
The two are performing master-slave synchronization of mysql. when my mysql server version is 5.6.10 and mysql5.6 and later is used for master-slave synchronization, the official recommendation is to store the information in master.info in the database, the specific location is in the master.info table of the mysql database.
There are already many examples of master-slave synchronization in mysql. now I am mainly talking about the problems I have encountered. the settings of master-slave synchronization are smooth. here is a brief description:
Execute SQL in the primary database
Flush tables with read lock;
View binlog records of the primary database:
Show master status;
Back up the primary database:
1. you can package the database: tar-zcvf/backup/mysql_dump.tar.gz/var/lib/mysql
2. mysql tool mysqldump: mysqldump -- user = root-h 127.0.0.1 -- databases test_repl -- default-character-set = utf8 -- lock-all-tables>/backup/test_repl. SQL
Restore a database from a database
1. extract the tar package directly to the directory where mysql stores the database, and change the file to the mysql permission.
2. run mysqldump: mysql-uroot-p123456 <test_repl. SQL to restore the database
Then set the synchronization information from the database:
Change master
Master_host = 'master database ip address ',
Master_user = 'synchronize user name ',
Master_password = 'synchronize user password ',
Master_port = 3306,
Master_log_file = 'Log file ',
Master_log_pos = Location of the log file;
Enable the slave database synchronization service
Start slave;
Release the read lock of the primary database and run it on the primary database.
Unlock tables;
Run on slave database
Show slave status/G
Check whether the synchronization status of the slave database is correct
Master/slave server firewall settings
You only need to release mysql tcp on the primary database.
Iptables-A-p tcp -- dport 3306-j ACCEPT
On the slave server, you need to release the tcp udp of mysql at the same time:
Iptables-A-p tcp -- dport 3306-j ACCEPT
Iptables-A-p udp -- dport 3306-j ACCEPT
In this way, the master-slave synchronization can run normally.
Work done
BitsCN.com