Stepbystep: how to configure mysql replication: bitsCN.com
Full-database replication is adopted to facilitate the management of mysql 5.5 + rhel5.8
10.4.11.12 master
10.4.11.13 slave
--- Master side settings
1. to create a replication account, you must have the 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 them to take effect.
# Skip-networking
Server-id = 12
# Uncomment the following if you want to log updates
Log-bin = mysql-bin
Restart mysql
Service mysql restart
--- Slave-side settings
3. the parameter settings of the slave Library also need to be restarted to take effect.
Vi/etc/my. cnf
# Skip-networking
Server-id = 13
# Uncomment the following if you want to log updates
Log-bin = mysql-relay-bin
4. the master node exports data to the slave database.
If the database uses the MyISAM table type, perform the following operations:
Shell> mysqldump -- all-databases -- master-data = 1> data. SQL
If the database uses the InnoDB table type, use single-transcation:
Shell> mysqldump -- all-databases -- single-transaction -- master-data = 1> data. SQL
Data import from slave
Mysql <data. SQL
5. view the master configuration.
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 replication. run the following command on the slave side:
-- Point of configuration replication
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. check the copy status. pay attention to the values in the slave_io_state, slave_io_Running, and slave_ SQL _running 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 status.
Create a table on the Master side
Slave check whether the replication is complete
BitsCN.com