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
Master
Database Services
-umysql-p-S /data/mysqldata/3306/mysql.sock shutdown
2. Copying data files
cp -r /data/mysqldata/3306 /data/mysqldata/3307
3. Editing
Master
The 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_id
range 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