mysql中rpl_MySQL管理工具MySQL Utilities — mysqlrplcheck(44)
mysqlrplcheck ?工具是用來檢查復制的先決條件的。這些檢查的設計或者說是測試,是用來確保復制的健康。測試的內容有:
在主上是否啟用了二進制?
是否有排除某些二進制(如有*_do_db 或 *_ignore_db的設置)?如果有,顯示它們。
在主上是否有復制用戶以及權限是否正確?
SERVER_ID是否沖突?
從是否連接到主?如果沒有顯示主的主機和端口。
從上的master.info文件與主上的SHOW SLAVE STATUS顯示的值是否沖突?
InnoDB配置是否兼容(插件還是內嵌的)?
存儲引擎是否兼容(主從一樣)?
lower_case_tables_names設置是否兼容?如果有設置大小寫表名可能會導致問題產生警告。
從是否落后主?
該工具進行每個測試,如果發現任何一個發生錯誤將退出。連接服務器失敗也會退出的。
每個測試的狀態有:pass(滿足先決條件)、fail(滿足先決條件但是發生了一個或多個錯誤,或者例外)、warn(需要進一步研究配置,但是不是錯誤的。)
使用–verbose選項來獲取額外的信息,如server_id、lower_case_table_name設置和從上面的主信息文件內容。
為了查看到SHOW SLAVE STATUS語句的值,可以使用?–show-slave-status 選項。
選項
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
MySQLUtilitiesmysqlrplcheckversion 1.5.3
Licensetype: GPLv2
Usage: mysqlrplcheck —master=root@localhost:3306 —slave=root@localhost:3310
mysqlrplcheck – checkreplication
Options:
—versionshowprogram‘s version number and exit
–help????????????????display a help message and exit
–license???????????? display program’s licenseand exit
—master=MASTERconnectioninformationfor masterserverin theform:
[:]@[:][:] or
[:][:] or
path>[].
—slave=SLAVEconnectioninformationfor slaveserverin theform:
[:]@[:][:] or
[:][:] or
path>[].
—master–info–file=MASTER_INFO
thenameofthemasterinformationfileontheslave.
Default = ‘master.info’ readfromthedatadirectory.
Note: this optionrequiresthattheutilityrunonthe
slavewithappropriatefilereadaccessto thedata
directory.從上的master.info文件。要求在從上執行并有訪問該文件的權限。
–s, —show–slave–status
showslavestatus。在主上顯示SHOWSLAVESTATUS值。
—width=WIDTHdisplaywidth。改變測試報告的顯示寬度。默認是75個字符。
—suppresssuppresswarningmessages。取消警告消息。
—ssl–ca=SSL_CAThepathto a filethatcontains a listoftrustedSSL
CAs.
—ssl–cert=SSL_CERTThenameoftheSSLcertificatefileto use for
establishing a secureconnection.
—ssl–key=SSL_KEYThenameoftheSSLkeyfileto use for establishing a
secureconnection.
–v, —verbosecontrolhowmuchinformationis displayed. e.g., –v =
verbose, –vv = moreverbose, –vvv = debug
–q, —quietturnoffallmessagesfor quietexecution.
注意
用戶必須要有SHOW SLAVE STATUS, SHOW MASTER STATUS, SHOW VARIABLES的執行權限。
IP地址和主機名混合使用不推薦。涉及到反向解析的問題。
MySQL客戶端工具的路徑需要包含在PATH環境變量中,以便使用login-paths驗證機制。允許使用my_print_defaults 來從登陸配置文件(.mylogin.cnf)讀取login-path值。
實例
在設置主從復制之前,檢測主從的先決條件,命令如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
shell> mysqlrplcheck —master=root@host1:3310 —slave=root@host2:3311
# master on host1: … connected.
# slave on host2: … connected.
TestDescriptionStatus
————————————————————————————————————
Checkingfor binaryloggingonmaster[pass]
Aretherebinlogexceptions?[pass]
Replicationuserexists?[pass]
Checkingserver_idvalues[pass]
Is slaveconnectedto master?[pass]
Checkmasterinformationfile[pass]
CheckingInnoDBcompatibility[pass]
Checkingstorageenginescompatibility[pass]
Checkinglower_case_table_namessettings[pass]
Checkingslavedelay (secondsbehindmaster)[pass]
# …done.
在這個例子中,必須要有登錄主從的有效的登錄信息。
執行相同的命令,并顯示從上的主信息文件的內容和?SHOW SLAVE STATUS 值以及額外的詳細信息,如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
shell> mysqlrplcheck —master=root@host1:3310 —slave=root@host2:3311 \
—show–slave–status –vv
# master on host1: … connected.
# slave on host2: … connected.
TestDescriptionStatus
————————————————————————————————————
Checkingfor binaryloggingonmaster[pass]
Aretherebinlogexceptions?[pass]
Replicationuserexists?[pass]
Checkingserver_idvalues[pass]
masterid = 10
slaveid = 11
Is slaveconnectedto master?[pass]
Checkmasterinformationfile[pass]
#
# Master information file:
#
Master_Log_File : clone–bin.000001
Read_Master_Log_Pos : 482
Master_Host : host1
Master_User : rpl
Master_Password : XXXX
Master_Port : 3310
Connect_Retry : 60
Master_SSL_Allowed : 0
Master_SSL_CA_File :
Master_SSL_CA_Path :
Master_SSL_Cert :
Master_SSL_Cipher :
Master_SSL_Key :
Master_SSL_Verify_Server_Cert : 0
CheckingInnoDBcompatibility[pass]
Checkingstorageenginescompatibility[pass]
Checkinglower_case_table_namessettings[pass]
Masterlower_case_table_names: 2
Slavelower_case_table_names: 2
Checkingslavedelay (secondsbehindmaster)[pass]
#
# Slave status:
#
Slave_IO_State : Waitingfor masterto sendevent
Master_Host : host1
Master_User : rpl
Master_Port : 3310
Connect_Retry : 60
Master_Log_File : clone–bin.000001
Read_Master_Log_Pos : 482
Relay_Log_File : clone–relay–bin.000006
Relay_Log_Pos : 251
Relay_Master_Log_File : clone–bin.000001
Slave_IO_Running : Yes
Slave_SQL_Running : Yes
Replicate_Do_DB :
Replicate_Ignore_DB :
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 : 482
Relay_Log_Space : 551
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 :
# …done.
權限
在主上需要對mysql數據庫具有SELECT 和 INSERT權限,同時還要有REPLICATION SLAVE, REPLICATION CLIENT 和 GRANT OPTION權限。
在從上需要有SUPER 權限。
此外,當使用GTIDs時,從用戶還必需要有對mysql數據庫的SELECT 權限。
文章轉載來自:ttlsa.com
總結
以上是生活随笔為你收集整理的mysql中rpl_MySQL管理工具MySQL Utilities — mysqlrplcheck(44)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: disconf mysql_discon
- 下一篇: mysql+如何开发存储引擎_干货!My