CentOS Mysql Master-Slave synchronization Quick setup step sharing _mysql

Source: Internet
Author: User
Tags centos
Installation Environment
CentOS 5.4
MySQL 5.1.xx with rpm direct installation
Xtrabackup 1.2.22 with RPM direct installation
1. Master:/etc/my.cnf
[Mysqld] Server-id = 1 Log-bin innodb_flush_log_at_trx_commit=1 sync_binlog=1 datadir=/var/lib/mysql Character-set-server=utf8 init_connect= ' Set NAMES UTF8 ' Set the default character set to UTF8, you can choose this configuration according to the actual situation.

2. slave:/etc/my.cnf
[Mysqld] server-id=2 datadir=/var/lib/mysql character-set-server=utf8 init_connect= ' Set NAMES UTF8 '

3. Master: Set the slave user rights to sync in the master database
GRANT REPLICATION SLAVE on *.* to ' <slave_username> ' @ ' <slave_ip> ' identified by ' <slave_password> ';

4. Master: Export data to Slave
The advantage of using Xtrabackup to back up MySQL is that the master has a very short lock schedule, is available in the actual production environment, and Xtrabackup automatically records the location of the synchronization log files.

sudo innobackupex-1.5.1--stream=tar/tmp/| SSH <slave_host> "mkdir/tmp/db; Tar Xfi--c/tmp/db/"This step will be the master's data including the table structure of the entire export and compression copied to the slave, and also extracted to the slave/tmp/db directory.

5. Slave: Import data to Slave
innobackupex-1.5.1--apply-log/tmp/db innobackupex-1.5.1--copy-back/tmp/db chown-r mysql.mysql/var/lib/mysql/*

6. Slave: Start synchronizing Data
View/var/lib/mysql/xtrabackup_binlog_info, get log files, and position.

Change MASTER to master_host= ' <master_host> ', master_user= ' <slave_username> ', master_password= ' < Slave_password> ', master_log_file= ' <see xtrabackup_binlog_info> ', Master_log_pos=<see xtrabackup_ binlog_info>; START SLAVE;
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.