2.3 配置同步信息:
Master上:
#mysql>change master to master_host=‘10.200.36.167’,master_port=3306,master_user=‘root’,master_password=‘123456’,master_log_file=‘mysql-bin.000003’,master_log_pos=5094;
#mysql> start slave;
#mysql> show slave status\G;
显示有如下状态则正常:
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.200.36.167
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000005
Read_Master_Log_Pos: 5094
Relay_Log_File: localhost-relay-bin.000006
Relay_Log_Pos: 2408
Relay_Master_Log_File: mysql-bin.000005
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql,information_schema,performance_schema,test,zabbix
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: 5094
Relay_Log_Space: 2659
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: 2
Master_UUID: 9be18158-3fc0-11e9-b3bc-00505694ed12
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 9be18158-3fc0-11e9-b3bc-00505694ed12:1-14
Executed_Gtid_Set: 9be18158-3fc0-11e9-b3bc-00505694ed12:1-14,
ae807b12-3fbf-11e9-bd3d-00505694bdbe:1-1620
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
Backup上:
#mysql>change master to master_host=‘10.200.36.166’,master_port=3306,master_user=‘root’,master_password=‘123.com123.COM’,master_log_file=‘mysql-bin.000003’,master_log_pos=5094;
start slave;
mysql> show slave status\G;
显示有如下状态则正常:
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.200.36.166
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000005
Read_Master_Log_Pos: 5094
Relay_Log_File: localhost-relay-bin.000006
Relay_Log_Pos: 3315
Relay_Master_Log_File: mysql-bin.000005
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql,information_schema,performance_schema,test,zabbix
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: 5094
Relay_Log_Space: 3582
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
Master_UUID: ae807b12-3fbf-11e9-bd3d-00505694bdbe
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: ae807b12-3fbf-11e9-bd3d-00505694bdbe:1-3:5-1620
Executed_Gtid_Set: 9be18158-3fc0-11e9-b3bc-00505694ed12:1-14,
ae807b12-3fbf-11e9-bd3d-00505694bdbe:1-1620
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
3.测试主从同步
3.1 在Master上创建一个测试同步效果
#mysql> show databases;
#mysql> create database test01;
#mysql> show databases;
3.2 到masterB查看是否已经同步创建
#mysql> show databases;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| mytest |
| sys |
| test01 |
+--------------------+
5 rows in set (0.01 sec)
4. 开启MySQL5.7的GTID功能
Master和Backup分别执行如下命令:
#mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
#mysql> change master to MASTER_AUTO_POSITION=1;
Query OK, 0 rows affected (0.01 sec)
#mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
5.MySql更改密码并添加远程登录功能:
查看随机密码:
#log-error=/var/log/mysqld.log。cat /var/log/xorg.0.log | grep ee。cat /var/log/xorg.0.log | grep nvidia。
更改密码:
mysqladmin -u root -p password “abc123”
授权远程登录:
mysql-> grant all privileges on *.* to root@"%" identified by "pwd" with grant option。mysql>grant all privileges on *.* to 'root'@'%' identified by 'youpassword' with grant option。mysql>grant all privileges on *.* to'root'@'%'identified by 'youpassword' with grant option。
mysql>FLUSH PRIVILEGES;
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-111706-6.html
质检总局都买不着真货
演员杨洋