MySQL the simplest way to deploy a replication link

Source: Internet
Author: User

The simplest way to deploy replication environments

Here the environment is as follows:

Master has no write operation
Master and slave in a single virtual machine with 3306 and 3307 port numbers, respectively

1. Close MasterDatabase Services
-umysql-p-S /data/mysqldata/3306/mysql.sock shutdown
2. Copying data files
cp -r /data/mysqldata/3306 /data/mysqldata/3307
3. Editing MasterThe parameter file

Add in [mysqld] chunks

server_id =1log_bin   =../binlog/mysql-bin

Binlog have to open
Each member of the same set of replication environments must have a separate server_id . server_idrange of values in 1~ (2 of 32 square-1)

Once the parameters are configured, you can start the database, but do not have a write operation

4. Create a copy-only account

On the master side

grant replication slave on *.* to ‘repl‘@‘192.168.134.%‘ identified by ‘repl‘;

This creates the account

([email protected]) [(none)]> select user,host from mysql.user;+--------+---------------+| user   | host          |+--------+---------------+| repl   | 192.168.134.% || backup | localhost     || mysql  | localhost     |+--------+---------------+

Then, get the Master end information

([email protected]) [(none)]> show master status;+------------------+----------+--------------+------------------+-------------------+| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |+------------------+----------+--------------+------------------+-------------------+| mysql-bin.000003 |      331 |              |                  |                   |+------------------+----------+--------------+------------------+-------------------+
5. Configuration Slave-End Options File

Add in [mysqld] chunks

server_id =2log_bin   =../binlog/mysql-bin --非必选项

The slave end does not have to turn on Bin-log

-i‘s/3306/3307/g‘ /data/mysqldata/330/my.cnf

Also need to delete Slave the end of the auto.cnf file

rm /data/mysqldata/3307/data/auto.cnf

This file holds an server-uuid important parameter named, which uniquely identifies the MySQL service, and our environment is a direct copy of the main library, so we need to delete it. The database service for the slave node will automatically regenerate a

6. Start Slave-End Services
[[email protected] 3307]$ mysql -umysql -p  -S /data/mysqldata/3307/mysql.sock Enter password: Welcome to the MySQL monitor.  Commands end with ; or \g....配置Slave到Master的连接:mysql> change master to     -> master_host=‘192.168.134.128‘,    -> master_port=3306,    -> master_user=‘repl‘,    -> master_password=‘repl‘,    -> master_log_file=‘mysql-bin.000003‘,    -> master_log_pos=331;Query OK, 0 rows affected, 2 warnings (0.05 sec)启动Slave端的应用服务:mysql> start slave;

Then you can create a table in the main library, insert the data, and then go to the library and see if the data is consistent, then OK.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MySQL the simplest way to deploy a replication link

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.