Mysql master-slave replication configuration steps

Source: Internet
Author: User
Mysql master-slave replication configuration steps: We recommend that you use the same version for the master server and slave server. In many cases, copying from the new master server to the old slave server will fail. In general, a master with a lower version can work normally with a higher version of slave, but it cannot be reversed. 1. Create a copy on the master.

Mysql master-slave replication configuration steps: We recommend that you use the same version for the master server and slave server. In many cases, copying from the new master server to the old slave server will fail. In general, a master with a lower version can work normally with a higher version of slave, but it cannot be reversed. 1. Create a copy on the master.

Mysql master-slave replication configuration steps

Note:

We recommend that you use the same version for the master server and slave server. In many cases, copying from the new master server to the old slave server will fail. In general, a master with a lower version can work normally with a higher version of slave, but it cannot be reversed.

1. Create an account with the replication permission on the master.

Grant replication slave, RELOAD, super on *. * TO backup @ 60. * identified by 'slavepass ';

Flush privileges;

2. Use mysqldump to export the database on the master and import it to the slave.

Master # mysqldump-uroot-p high> high. SQL

3. In the replication section of the my. cnf configuration file of the master, add:

Server-id = 1

Log_bin =/var/log/mysql/mysql-bin.log

Binlog_do_db = high

Binlog_ignore_db = mysql

Restart mysql

#/Etc/init. d/mysql restart

View master Status

Mysql> show master status;

4. Add the following in the replication section of the my. cnf configuration file of slave:

Server-id = 2

Master-host = 60 .*.*.*

Master-user = backup

Master-password = slavepass

Master-port = 3300

Replicate-do-db = high

Replicate-ignore-db = mysql

Restart mysql

#/Etc/init. d/mysql restart

View slave status

Mysql> show slave status;

Manually set master on slave:

View the master information:

Mysql> show master status;

+ ------------------ + ---------- + -------------- + ------------------ +

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+ ------------------ + ---------- + -------------- + ------------------ +

| Mysql-bin.000001 | 2244 | high | mysql |

+ ------------------ + ---------- + -------------- + ------------------ +

1 row in set (0.00 sec)

Stop slave:

Mysql> stop slave;

Run the following command on slave:

Change master to MASTER_HOST = '60. * ', MASTER_PORT = 3300,

MASTER_USER = 'backup ', MASTER_PASSWORD = 'slavepass', MASTER_LOG_FILE = 'mysql-bin.000001 ', MASTER_LOG_POS = 2244;

Start slave:

Mysql> start slave;

5. Create and Delete tables in the master's high database, and check whether tables are successfully created and deleted on the slave.

6. Authorize the high user on the slave so that the master can be switched to the slave temporarily when a problem occurs.

Grant select, INSERT, UPDATE, DELETE, CREATE, drop on high. * TO 'high' @ '60. *. *. % 'identified by 'high ';

Flush privileges;

7. Problem

Found: Slave_IO_Running No

Cause: the replication account is not authorized on the master. Perform the first step to solve the problem.

8. Run the following command to view the copy status of the master/slave server:

Show processlist;

Show master status;

Show slave status;

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.