Mysql master/slave test process

Source: Internet
Author: User

1. test environment:

> Master: physical machine, Debian (testing) + mysql5.0 + ip: 192.168.40.223

> Slave: Virtual Machine, CentOS (4.0) + mysql5.0 + ip: 192.168.40.225

2. Modify the Master (192.168.40.223)

1). Modify/etc/mysql/my. cnf

Make the following changes in [mysqld]

> Change bind-address from 127.0.0.1 to 192.168.40.223.

> Add: server-id = 1

> Add: log-bin

> Add: binlog-do-db = test

> Add: binlog-ignore-db = mysql

2). Create a copy data account:

> Grant replication slave on *. * to 'slave _ Server' @ 192.168.40.225 identified by 'vobile ';

3) Restart mysql

>/Etc/init. d/mysql restart

3. Modify Slave (192.168.40.225)

1). Modify/etc/my. cnf

In [mysqld], make the following changes:

> Add: server-id = 2

> Add: master-host = 192.168.40.223

> Add: master-user = slave_server

> Add: master_password = vobile

> Master-port = 3306

2) Restart mysql

>/Etc/init. d/mysqld restart

4. Data Import

1) Export the test database in master (192.168.40.223): mysqldump-uroot test> test. SQL

2). Import test. SQL to the slave database:

> Mysql-uroot-e 'create database test ;'

> Mysql-uroot test <test. SQL

5. Enable slave

1). Input start slave in mysql on slave (192.168.40.255;

2). view the slave status (192.168.40.225 mysql): show slave status \ G;

> In the status values, Slave_IO_Running and Slave_ SQL _Running are set to Yes.

3). view the master status (192.168.40.223 mysql): show master status;

6. Detection results

1) In the master database, test has a table human with only three records, and three records are recorded in the same database and table in slave;

2) Insert a record in the master;

3). Add the same record to the corresponding 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.