MySQL master-Slave, Environment construction, master-slave configuration

Source: Internet
Author: User

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

Related Article

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.