- Database A as the primary service, database B as a synchronous library (note: Both sides of the database library must be one, or there will be constant error information out, change, change, is not successful)
- 1. Configure Master
- Vi/etc/my.cnf
- [Mysqld]
- server-id=1
- log-bin=Log Path
- binlog-do-db=xxxx//means to back up only xxxx This library, you can configure multiple libraries
- binlog-ignore-db=yyy//indicates ignoring YYY library
- Note: If BINLOG-DO-DB,BINLOG-IGNORE-DB does not add the default backup of all libraries
- Restart database service mysqld restart
- Login to Database mysql-uroot-p123456
- Create a backup account, preferably with slave, reload,super, permissions
- Grant Peplication slave,reload,super on * * to ' backup ' @ ' percent ' identfiend by ' 1234 ' with GRANT option;
- Note: This must be available with GRANT option, which indicates that backup has operational permissions
- Flush privileges;
- Show grant for ' backup ' @ '% '; View User
- Show master status;
- If the IP address changes:
- Change Master to master_host=' xxx ',master_user=' backup ',master_password=' 1234 ',Master _port=' 3306 ',master_log_file=' master-log.000001 ',master_log_pos=4, master_connect_ retry=10;
- 2, configuration slave
- Vi/etc/my.cnf
- Server-id=2
- Change Master to master_host=' xxx ',master_user=' backup ',master_password=' 1234 ',Master _port=' 3306 ',master_log_file=' master-log.000001 ',master_log_pos=4, master_connect_ retry=10;
- Note: Log name, user name, password must be with Master one to
- show slave status\g;
- See if the information is correct
- Slave start;
- With show slave status\g;
- Just make sure:
- slave_io_running=Yes
- slave_sql_running=Yes
- It's done.
- I've got 2 questions.
- The first one:
- slave_io_running=connecting
- slave_sql_running=Yes
- Last_io_error:error Connecting Master ...
- Looking for long time, the original user name password is wrong, it is a waste of time
- The second one: (A little dizzy)
- slave_io_running=No
- slave_sql_running=Yes
- Last_io_error: means that both the library and the table one to the synchronization did not find the corresponding libraries and tables
- And then:
- Slave stop;
- Reset slave; Reset Slave
- Change Master to master_host=' xxx ',master_user=' backup ',master_password=' 1234 ',Master _port=' 3306 ',master_log_file=' master-log.000001 ',master_log_pos=4, master_connect_ retry=10;
- Again, no way, finally see
- slave_io_running=Yes
- slave_sql_running=Yes
- Last_io_error: Empty
- The DBA's job is really a careful person to play
Centos6,mysql 5.5 Configuring master \ Slave Data Synchronization Backup