MySQL master-slave replication configuration

Source: Internet
Author: User

Mysql Master-slave replication configuration

First, the test environment

1. Software Environment

A) operating system:

CentOS 6.5 X64

b) mysql-server:

Mysql-server-5.1.73-3.el6_5.x86_64

2. network Environment

Each host has two network card, one of the network card and make a network card directly connected;

A) mater_db:

I.eth0:

192.168.99.11/24

Ii. Eth1:

10.1.1.11/24

b) slave_db:

I.eth0:

192.168.99.12/24

Ii. Eth1:

10.1.1.12/24

3.

Ii. Related Explanations

Third, the experimental process

A) master_db

I. Install mysql-server (slightly)

Ii. Configuration Mysql-server

1. Modify The root user password under Mysql;

2. Create a database for testing

3. Modify the configuration file

A) vim/etc/my.cnf

Add the following paragraph:

[Mysqld]

Server-id=1 # specifying service ID

Log-bin=log # turn on log

Binlog_do_db=luoyangbo # Select the database you want to synchronize

Binlog_ignore_db=test,mysql # Select a database that does not need to be synchronized

b) Restart the database

b) slave_db

1. Modify The root user password under Mysql;

2. Create a database of tests with the same name as the database that needs to be synchronized on the Materdb

3. Modify the configuration file

A) vim/etc/my.cnf

Add the following paragraph:

[Mysqld]


server-id=2 # Server ID

master-host=10.1.1.11 # Primary server address

MASTER-USER=SLAVE01 # Mysql user name connecting to the primary server master-password=7490283 # Mysql password to connect to the master server

master-port=3306 # Port connecting to the primary server

MASTER-CONNECT-RETRY=20 # If the connection fails, the retry time

Replicate-do-db=luoyangbo # Synchronized database name

Replicate-ignore-db=mysql,test # out -of-sync database name

b) Restart the database


4. Test Mysql master-slave configuration

A) Master DB

I. Create a table and insert row data;

Create tables Test (ID int,name char (10));

Insert into test values (1,hello);

b) Slave DB

I. retrieving test tables for synchronization

Show tables;

SELECT * FROMTEST;


This article is from the "Luo Old Three Road" blog, please be sure to keep this source http://robert283.blog.51cto.com/528368/1408662

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.