MySQL Master-slave replication

Source: Internet
Author: User

System environment

System version: centos6.4-x86.64

Software Environment

mysql-5.5.27

Environment

Role IP Address

Mysql-master 192.168.1.10 (Mysql external service IP)

192.168.1.11 (Master-Slave synchronization IP )

MySql-Slave        192.168.1.20 ( Slave Foreign Service ip

192.168.1.22 (Master-Slave synchronization IP )

Main Library Authorization Password Tongda

--------------------------------------------------------  

1. System Environment Preparation

Shutting down firewalls and SELinux


2. Main Library configuration steps

#############################

Vim /etc/my.cnf

######## #my. cnf################

Log-bin=master-bin (open Mysql-binlog log)

server-id=10 (Specify Mysql-master-id)

###############################

[[Email protected]~]# service MySQL Restart

######## #登录mysql ##############

mysql> grant replication Slave on * * to [e-mail protected] ' 192.168.1.22 ' identified by ' Tongda ';

mysql> flush Privileges;

mysql> Reset Master

Mysql> Show master status;

+---------------+----------+--------------+------------------+

| File | Position | binlog_do_db | binlog_ignore_db |

+---------------+----------+--------------+------------------+

|     my-bak.000004 |              2382 | | Mysql,mysql |

+---------------+----------+--------------+------------------+

1 row in Set (0.00 sec)


2. From the Library configuration step

#############################

Vim /etc/my.cnf

######## #my. cnf###############

Server-id=20 (Specify Mysql-slave-id)

######### #登录mysql ############

mysql> Change Master to master_host= ' 192.168.1.10 ', master_user= ' slave20 ', master_password= ' tongdal ', Master_log_ File= ' mysql-bin.000004 ', master_log_pos=2382;

Mysql> Show Slave Status\g

1. Row ***************************

Slave_io_state:waiting for Master to send event

master_host:192.168.3.30

Master_user:slave

master_port:3336

Connect_retry:60

master_log_file:my-bak.000004

read_master_log_pos:2382

relay_log_file:ipsan-relay-bin.000013

relay_log_pos:2525

relay_master_log_file:my-bak.000004

Slave_io_running:yes//Read binlog from the master server, store in nativeslave_sql_running:yes//Read local mysqld-relay-bin (relay log), Write native MySQL

#################################################################

Comments:

Master_log_file= ' mysql-bin.* ', master_log_pos=*;

Binlog value and POS value specific need to view the main library state get

Mysql> Show master status; View out-of-Library status

#####################################################################

MySQL Master slave external service IP and master-slave synchronization IP can be a network card or two network cards, it is recommended to bind to two network cards and configure other network segment IP address






This article is from the "Hanging Sword" blog, please be sure to keep this source http://sublime.blog.51cto.com/8856101/1545512

MySQL master-slave replication

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.