Master configuration:
| The code is as follows |
|
Log-bin = Mysql-bin Server-id = 1 Binlog-do-db = Powerdns #要同步的数据库 |
Master new Slave Account:
| The code is as follows |
|
mysql> GRANT replication Slave on *.* to ' slave ' @ ' 192.168.1.2 ' identified by ' passwd '; mysql> FLUSH privileges; |
Restart Master MySQL, view master status information, remember the file name, POS location.
| The code is as follows |
|
Mysql> Show master status; +------------------+----------+--------------+------------------+ | File | Position | binlog_do_db | binlog_ignore_db | +------------------+----------+--------------+------------------+ | mysql-bin.000002 | 309 | Powerdns | MySQL | +------------------+----------+--------------+------------------+ 1 row in Set (0.00 sec) |
Slave configuration:
| The code is as follows |
|
Server-id =2 |
Start Sync:
| The code is as follows |
|
mysql> Change Master to master_host= ' 192.168.1.1 ', master_user= ' slave ', master_password= ' passwd ', Master_log_file= ' mysql-bin.000002 ', master_log_pos=309; mysql> START Slave; |
To view the slave sync status:
| code is as follows |
&nbs P; |
| mysql> show slave statusg; Slave_io_running:yes Slave_sql_running:yes |