Iptables setting after mysql master-slave synchronization is enabled _ MySQL

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.