Mysql primary structures and configuration from the database replication

Environment: vmwareworkstation 10 deployed two Linux virtual machines under a master, from the server host:
the primary server: centos 7.6 mysql 5.6.45-log IP : 10.11.18.190
from the server: centos 7.6 mysql 5.6.45-log IP : 10.11. 18.193
primary database server test
one: the main server configuration:

1: Create a replication user with permission replication slave.
MySQL> Grant Slave Replication ON . To 'slaveuser'@'10.11.18.193' IDENTIFIED by '123456';
MySQL> flush privileges;
2 :: restart the mysql database:
Service mysqld restart
3: Set table locking
Mysql> flush tables with read lock;
. 4: backup database to be synchronized:
[the root @ localhost ~] -p -p3306 mysqldump -hlocalhost -uroot-Test> /home/test.sql
. 5: tABLE lock release:
Mysql> UNLOCK tables;
. 6: backup database to recover from the server:
[root @ localhost Home] scp test.sql [email protected]: / Home
7: Check the primary database server current status (in use to this from the server configuration)
MySQL> Show master status \ G;

Two: Configure from the server:

1: restore the master (10.11.18.190) backup of the database to the slave (10.11.18.193) from the server
1) to build a test database:
Mysql> the Create test;
2) to recover the database data to test the library:
[root @ localhost Home ] mysql -uroot -p (access to databases)
Mysql> use Test;
Mysql> sET UTF8 names;
Mysql> Source test.sql;
2: the database corresponding settings:
Mysql> Change Master .11.18.190 to master_hsot = '10 ', MASTER_USER = 'slaveuser',
Master_password = '123456', MASTER_LOG_POS = 382, MASTER_LOG_FILE =
'MySQL-bin.000007';
. 3: View from state database server:
Mysql> Show Slave status \ G;

Slave_IO_Running: yes
Slave_SQL_Running: yes
These two or more must be yes state, indicating a successful connection slave and master,
if slave_io_running: connecting possible that the firewall affect the master, and then turn off the firewall test.
III: Test:
1: Log in to the master server mysql, create a table in the test database:

MySQL> the Create the Table test01 (the above mentioned id int not null, var char (20));
2: go to the database to see if the landing slave synchronization from the server:

At this point you can see from the test library on the slave server tables and tables have been on the master primary server synchronization is successful.

Guess you like

Origin blog.51cto.com/wusongyuanxing1/2437365