1, MySQL master-slave introduction
2. Environment Construction
2. Master-Slave Preparation:
Modify master configuration file:vim/etc/my.cnf
Add to:
server_id = # # #
Log_bin = Diy_name
Then save restart:/etc/init.d/mysqld restart
Backup and recovery of data:
Backup:mysqldump-uroot-p base_name >/tmp/base_name.sql
Recovery:mysql-uroot-p base_name </tmp.base_name.sql
Create a Sync User:grant replication Slave on * * to [e-mail protected]*.***.***.**6 identified by "aa123456";
Sometimes it is necessary to lock the table (that is, write data is not allowed):flush tables with read lock;
Then, check the status of the current main library:show master status;
3, the preparation from the library:
Modified:vim/etc/mysql.cnf
Join:server_id = # # #
Restart:/etc/init.d/mysqld restart
Go to MySQL and then close slave:stop slave;
Then the master-slave formulation:
Change Master to master_host= ' ***.***.***.*** ', master_user= ' SLA ', master_password= ' aa123456 ', master_log_file= ' Master.000001 ', master_log_pos=329;
Re-open slave:start slave;
See if the preparation is successful:show slave status\g;
and then test it. Create a database on the primary server: "Create databasesmaster_test;
Several parameters are relevant:
The main use of these two:
replicate_wild_do_table=base_name.% or Replicate_wild_do_table=base_name.table_name (Back up all of a library's tables, or a table)
replicate_wild_ignore_table=base_name.% or Replicate_wild_ignore_table=base_name.table_name(do not back up all tables of a library, or a table)
MySQL master-Slave, Environment construction, master-slave configuration