The concrete method of configuring Mysql replication with step by step _mysql

Source: Internet
Author: User

Using the whole library replication scheme, easy to manage MySQL 5.5 + rhel5.8
10.4.11.12 Master
10.4.11.13 slave
---master-side settings
1, create the replication account, need to copy and slave permissions
Mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT on *.* to repl@ ' 10.4.11.12 identified by ' MySQL;
Query OK, 0 rows Affected (0.00 sec)
2, modify the parameters, and restart the effective
#skip-networking
Server-id = 12
# Uncomment the following if you are want to log updates
Log-bin=mysql-bin
Restart MySQL
Service MySQL Restart

setting of the---slave end
3,slave library parameter settings, also need to restart the effective
Vi/etc/my.cnf
#skip-networking
Server-id = 13
# Uncomment the following if you are want to log updates
Log-bin=mysql-relay-bin

4,master Export data to Slave library
If the database is using a MyISAM table type, you can do the following:

shell> mysqldump--all-databases--master-data=1 > Data.sql
If the database is using a InnoDB table type, you should use Single-transcation:

shell> mysqldump--all-databases--single-transaction--master-data=1 > Data.sql

Slave-side Import data
MySQL < Data.sql


5, view the configuration of master
Mysql> Show master status;
+------------------+----------+--------------+------------------+
| File | Position | binlog_do_db | binlog_ignore_db |
+------------------+----------+--------------+------------------+
|      mysql-bin.000001 |              107 |                  | |
+------------------+----------+--------------+------------------+
1 row in Set (0.00 sec)

6, start the copy, the slave side run the following command

Copy Code code as follows:

--Configure the replication point
Change MASTER to master_host= ' 10.4.11.12 ',
Master_user= ' Repl ',
master_password= ' MySQL ',
Master_log_file= ' mysql-bin.000001 ',
master_log_pos=0;

--Start copying
mysql> start slave;
Query OK, 0 rows Affected (0.00 sec)

7, view the status of the replication, note the values of slave_io_state, slave_io_running, and slave_sql_running three columns

Mysql> Show Slave Status\g
1. Row ***************************
Slave_io_state:waiting for Master to send event
master_host:172.16.251.11
Master_user:repl
master_port:3306
Connect_retry:60
master_log_file:mysql-bin.000001
read_master_log_pos:1278
relay_log_file:linux2-relay-bin.000002
relay_log_pos:503
relay_master_log_file:mysql-bin.000001
Slave_io_running:yes
Slave_sql_running:yes
replicate_do_db:
........

8, test the replication situation
Master-side Create a new table
Slave See if replication is complete

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.