1
+ // Copyright 2018 PingCAP, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+
1
14
package check
2
15
3
16
import (
@@ -6,7 +19,6 @@ import (
6
19
"fmt"
7
20
"strings"
8
21
9
- "github.com/ngaut/log"
10
22
"github.com/pingcap/tidb-tools/pkg/dbutil"
11
23
)
12
24
@@ -25,11 +37,10 @@ func NewMySQLBinlogEnableChecker(db *sql.DB, dbinfo *dbutil.DBConfig) Checker {
25
37
func (pc * MySQLBinlogEnableChecker ) Check (ctx context.Context ) * Result {
26
38
result := & Result {
27
39
Name : pc .Name (),
28
- Desc : "checks whether mysql binlog is enable" ,
40
+ Desc : "check whether mysql binlog is enable" ,
29
41
State : StateFailure ,
30
- Extra : fmt .Sprintf ("%s:%d" , pc .dbinfo .Host , pc .dbinfo .Port ),
42
+ Extra : fmt .Sprintf ("address of db instance - %s:%d" , pc .dbinfo .Host , pc .dbinfo .Port ),
31
43
}
32
- defer log .Infof ("check binlog enable, result %+v" , result )
33
44
34
45
value , err := dbutil .ShowLogBin (ctx , pc .db )
35
46
if err != nil {
@@ -38,7 +49,7 @@ func (pc *MySQLBinlogEnableChecker) Check(ctx context.Context) *Result {
38
49
}
39
50
if strings .ToUpper (value ) != "ON" {
40
51
result .ErrorMsg = fmt .Sprintf ("log_bin is %s, and should be ON" , value )
41
- result .Instruction = "ref: https://dev.mysql.com/doc/refman/5.7/en/replication-howto-masterbaseconfig.html"
52
+ result .Instruction = "ref document : https://dev.mysql.com/doc/refman/5.7/en/replication-howto-masterbaseconfig.html"
42
53
return result
43
54
}
44
55
result .State = StateSuccess
@@ -67,11 +78,10 @@ func NewMySQLBinlogFormatChecker(db *sql.DB, dbinfo *dbutil.DBConfig) Checker {
67
78
func (pc * MySQLBinlogFormatChecker ) Check (ctx context.Context ) * Result {
68
79
result := & Result {
69
80
Name : pc .Name (),
70
- Desc : "checks whether mysql binlog_format is ROW" ,
81
+ Desc : "check whether mysql binlog_format is ROW" ,
71
82
State : StateFailure ,
72
- Extra : fmt .Sprintf ("%s:%d" , pc .dbinfo .Host , pc .dbinfo .Port ),
83
+ Extra : fmt .Sprintf ("address of db instance - %s:%d" , pc .dbinfo .Host , pc .dbinfo .Port ),
73
84
}
74
- defer log .Infof ("check binlog_format, result %+v" , result )
75
85
76
86
value , err := dbutil .ShowBinlogFormat (ctx , pc .db )
77
87
if err != nil {
@@ -80,7 +90,7 @@ func (pc *MySQLBinlogFormatChecker) Check(ctx context.Context) *Result {
80
90
}
81
91
if strings .ToUpper (value ) != "ROW" {
82
92
result .ErrorMsg = fmt .Sprintf ("binlog_format is %s, and should be ROW" , value )
83
- result .Instruction = "set global binlog_format=ROW;"
93
+ result .Instruction = "please execute ' set global binlog_format=ROW;' "
84
94
return result
85
95
}
86
96
result .State = StateSuccess
@@ -121,19 +131,22 @@ func NewMySQLBinlogRowImageChecker(db *sql.DB, dbinfo *dbutil.DBConfig) Checker
121
131
func (pc * MySQLBinlogRowImageChecker ) Check (ctx context.Context ) * Result {
122
132
result := & Result {
123
133
Name : pc .Name (),
124
- Desc : "checks whether mysql binlog_row_image is FULL" ,
134
+ Desc : "check whether mysql binlog_row_image is FULL" ,
125
135
State : StateFailure ,
126
- Extra : fmt .Sprintf ("%s:%d" , pc .dbinfo .Host , pc .dbinfo .Port ),
136
+ Extra : fmt .Sprintf ("address of db instance - %s:%d" , pc .dbinfo .Host , pc .dbinfo .Port ),
127
137
}
128
- defer log .Infof ("check binlog_row_image, result %+v" , result )
129
138
130
139
// check version firstly
131
140
value , err := dbutil .ShowVersion (ctx , pc .db )
132
141
if err != nil {
133
142
markCheckError (result , err )
134
143
return result
135
144
}
136
- version := toMySQLVersion (value )
145
+ version , err := toMySQLVersion (value )
146
+ if err != nil {
147
+ markCheckError (result , err )
148
+ return result
149
+ }
137
150
138
151
// for mysql.version < 5.6.2 || mariadb.version < 10.1.6, we don't need to check binlog_row_image.
139
152
if (! IsMariaDB (value ) && ! version .IsAtLeast (mysqlBinlogRowImageRequired )) || (IsMariaDB (value ) && ! version .IsAtLeast (mariadbBinlogRowImageRequired )) {
@@ -148,7 +161,7 @@ func (pc *MySQLBinlogRowImageChecker) Check(ctx context.Context) *Result {
148
161
}
149
162
if strings .ToUpper (value ) != "FULL" {
150
163
result .ErrorMsg = fmt .Sprintf ("binlog_row_image is %s, and should be FULL" , value )
151
- result .Instruction = "set global binlog_row_image = FULL;"
164
+ result .Instruction = "please execute ' set global binlog_row_image = FULL;' "
152
165
return result
153
166
}
154
167
result .State = StateSuccess
0 commit comments