Linux环境下MySQL数据库主从同步配置(4)

change master to master_host='192.168.21.128',master_user='osyunweidbbak',master_password='123456',master_log_file='mysql-bin.000011' ,master_log_pos=107;    #执行同步语句

slave start;    #开启slave同步进程

SHOW SLAVE STATUS\G   #查看slave同步信息,出现以下内容

mysql> SHOW SLAVE STATUS\G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.21.128

Master_User: osyunweidbbak

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000011

Read_Master_Log_Pos: 107

Relay_Log_File: mysqlslave-relay-bin.000004

Relay_Log_Pos: 253

Relay_Master_Log_File: mysql-bin.000011

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB: osyunweidb

Replicate_Ignore_DB: mysql

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 107

Relay_Log_Space: 560

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 1

1 row in set (0.00 sec)

mysql>

注意查看:

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

以上这两个参数的值为Yes,即说明配置成功!

测试篇

测试MySQL主从服务器是否正常运行

1、进入MySQL主服务器(192.168.21.128)

mysql -u root -p  #进入MySQL控制台

use osyunweidb   #进入数据库

CREATE TABLE test ( id int not null primary key,name char(20) );   #创建test表

2、进入MySQL从服务器

mysql -u root -p  #进入MySQL控制台

use osyunweidb   #进入数据库

show  tables;  #查看osyunweidb表结构,会看到有一个新建的表test,表示数据库同步成功

mysql> show  tables;

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

| Tables_in_osyunweidb |

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

| test                |

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

1 row in set (0.00 sec)

至此,Linux下MySQL数据库主从同步配置完成!

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5867a3f6bc50850b42b0441783255675.html