check

package
v3.0.13+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

README

Check library

check is a library to define some checkers to check configurations of system.

It is mainly used for configuration checking of data synchronization between database systems.

Introduction

MySQL slave privilege Checker

In MySQL data synchronization, REPLICATION SLAVE and REPLICATION CLIENT are required, RELOAD is strongly suggested to have.

MySQL Version Checker

Syncer only supports 5.5 <= version <= 8.0 now

MySQL Server ID Checker

MySQL Server(master) should have server ID in master-slave replications.

MySQL Binlog Enable Checker

MySQL Server(master) should enable binlog in master-slave replication.

MySQL Binlog Format Checker

Syncer only supports ROW binlog format

MySQL Binlog Row Image Checker

binlog_row_image is introduced since mysql 5.6.2, and mariadb 10.1.6. In MySQL 5.5 and earlier, full row images are always used for both before images and after images.

ref:

Documentation

Index

Constants

View Source
const AutoIncrementKeyChecking = "auto-increment key checking"

AutoIncrementKeyChecking is an identification for auto increment key checking

Variables

MaxVersion define a maximum version

View Source
var MinVersion = MySQLVersion{0, 0, 0}

MinVersion define a mininum version

View Source
var SupportedVersion = map[string]struct {
	Min MySQLVersion
	Max MySQLVersion
}{
	"mysql": {
		MySQLVersion{5, 6, 0},
		MySQLVersion{5, 8, 0},
	},
	"mariadb": {
		MySQLVersion{10, 1, 2},
		MaxVersion,
	},
}

SupportedVersion defines the MySQL/MariaDB version that DM/syncer supports * 5.6.0 <= MySQL Version < 5.8.0 * 10.1.2 <= Mariadb Version

Functions

func IsMariaDB

func IsMariaDB(version string) bool

IsMariaDB tells whether the version is from mariadb.

Types

type Checker

type Checker interface {
	Name() string
	Check(ctx context.Context) *Result
}

Checker is interface that defines checker to check configurations of system. It is mainly used for configuration checking of data synchronization between database systems.

func NewMySQLBinlogEnableChecker

func NewMySQLBinlogEnableChecker(db *sql.DB, dbinfo *dbutil.DBConfig) Checker

NewMySQLBinlogEnableChecker returns a Checker.

func NewMySQLBinlogFormatChecker

func NewMySQLBinlogFormatChecker(db *sql.DB, dbinfo *dbutil.DBConfig) Checker

NewMySQLBinlogFormatChecker returns a Checker.

func NewMySQLBinlogRowImageChecker

func NewMySQLBinlogRowImageChecker(db *sql.DB, dbinfo *dbutil.DBConfig) Checker

NewMySQLBinlogRowImageChecker returns a Checker

func NewMySQLServerIDChecker

func NewMySQLServerIDChecker(db *sql.DB, dbinfo *dbutil.DBConfig) Checker

NewMySQLServerIDChecker returns a Checker

func NewMySQLVersionChecker

func NewMySQLVersionChecker(db *sql.DB, dbinfo *dbutil.DBConfig) Checker

NewMySQLVersionChecker returns a Checker

func NewShardingTablesCheck

func NewShardingTablesCheck(name string, dbs map[string]*sql.DB, tables map[string]map[string][]string, mapping map[string]*column.Mapping, checkAutoIncrementPrimaryKey bool) Checker

NewShardingTablesCheck returns a Checker

func NewSourceDumpPrivilegeChecker

func NewSourceDumpPrivilegeChecker(db *sql.DB, dbinfo *dbutil.DBConfig) Checker

NewSourceDumpPrivilegeChecker returns a Checker.

func NewSourceReplicationPrivilegeChecker

func NewSourceReplicationPrivilegeChecker(db *sql.DB, dbinfo *dbutil.DBConfig) Checker

NewSourceReplicationPrivilegeChecker returns a Checker.

func NewTablesChecker

func NewTablesChecker(db *sql.DB, dbinfo *dbutil.DBConfig, tables map[string][]string) Checker

NewTablesChecker returns a Checker

type MySQLBinlogEnableChecker

type MySQLBinlogEnableChecker struct {
	// contains filtered or unexported fields
}

MySQLBinlogEnableChecker checks whether `log_bin` variable is enabled in MySQL.

func (*MySQLBinlogEnableChecker) Check

Check implements the Checker interface.

func (*MySQLBinlogEnableChecker) Name

func (pc *MySQLBinlogEnableChecker) Name() string

Name implements the Checker interface.

type MySQLBinlogFormatChecker

type MySQLBinlogFormatChecker struct {
	// contains filtered or unexported fields
}

MySQLBinlogFormatChecker checks mysql binlog_format.

func (*MySQLBinlogFormatChecker) Check

Check implements the Checker interface.

func (*MySQLBinlogFormatChecker) Name

func (pc *MySQLBinlogFormatChecker) Name() string

Name implements the Checker interface.

type MySQLBinlogRowImageChecker

type MySQLBinlogRowImageChecker struct {
	// contains filtered or unexported fields
}

MySQLBinlogRowImageChecker checks mysql binlog_row_image

func (*MySQLBinlogRowImageChecker) Check

Check implements the Checker interface. 'binlog_row_image' is introduced since mysql 5.6.2, and mariadb 10.1.6. > In MySQL 5.5 and earlier, full row images are always used for both before images and after images. So we need check 'binlog_row_image' after mysql 5.6.2 version and mariadb 10.1.6. ref: - https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_binlog_row_image - https://mariadb.com/kb/en/library/replication-and-binary-log-server-system-variables/#binlog_row_image

func (*MySQLBinlogRowImageChecker) Name

Name implements the Checker interface.

type MySQLServerIDChecker

type MySQLServerIDChecker struct {
	// contains filtered or unexported fields
}

MySQLServerIDChecker checks mysql/mariadb server ID.

func (*MySQLServerIDChecker) Check

func (pc *MySQLServerIDChecker) Check(ctx context.Context) *Result

Check implements the Checker interface.

func (*MySQLServerIDChecker) Name

func (pc *MySQLServerIDChecker) Name() string

Name implements the Checker interface.

type MySQLVersion

type MySQLVersion [3]uint

MySQLVersion represents MySQL version number.

func (MySQLVersion) Ge

func (v MySQLVersion) Ge(min MySQLVersion) bool

Ge means v >= min

func (MySQLVersion) Gt

func (v MySQLVersion) Gt(min MySQLVersion) bool

Gt means v > min

func (MySQLVersion) Le

func (v MySQLVersion) Le(max MySQLVersion) bool

Le means v <= min

func (MySQLVersion) Lt

func (v MySQLVersion) Lt(max MySQLVersion) bool

Lt means v < min

func (MySQLVersion) String

func (v MySQLVersion) String() string

String implements the Stringer interface.

type MySQLVersionChecker

type MySQLVersionChecker struct {
	// contains filtered or unexported fields
}

MySQLVersionChecker checks mysql/mariadb/rds,... version.

func (*MySQLVersionChecker) Check

func (pc *MySQLVersionChecker) Check(ctx context.Context) *Result

Check implements the Checker interface. we only support version >= 5.5

func (*MySQLVersionChecker) Name

func (pc *MySQLVersionChecker) Name() string

Name implements the Checker interface.

type Result

type Result struct {
	ID          uint64 `json:"id"`
	Name        string `json:"name"`
	Desc        string `json:"desc"`
	State       State  `json:"state"`
	ErrorMsg    string `json:"errorMsg"`
	Instruction string `json:"instruction"`
	Extra       string `json:"extra"`
}

Result is result of check

type ResultSummary

type ResultSummary struct {
	Passed     bool  `json:"passed"`
	Total      int64 `json:"total"`
	Successful int64 `json:"successful"`
	Failed     int64 `json:"failed"`
	Warning    int64 `json:"warning"`
}

ResultSummary is summary of all check results

type Results

type Results struct {
	Results []*Result      `json:"results"`
	Summary *ResultSummary `json:"summary"`
}

Results contains all check results and summary

func Do

func Do(ctx context.Context, checkers []Checker) (*Results, error)

Do executes several checkers.

type ShardingTablesCheck

type ShardingTablesCheck struct {
	// contains filtered or unexported fields
}

ShardingTablesCheck checks consistency of table structures of one sharding group * check whether they have same column list * check whether they have auto_increment key

func (*ShardingTablesCheck) Check

func (c *ShardingTablesCheck) Check(ctx context.Context) *Result

Check implements Checker interface

func (*ShardingTablesCheck) Name

func (c *ShardingTablesCheck) Name() string

Name implements Checker interface

type SourceDumpPrivilegeChecker

type SourceDumpPrivilegeChecker struct {
	// contains filtered or unexported fields
}

SourceDumpPrivilegeChecker checks dump privileges of source DB.

func (*SourceDumpPrivilegeChecker) Check

Check implements the Checker interface. We only check RELOAD, SELECT privileges.

func (*SourceDumpPrivilegeChecker) Name

Name implements the Checker interface.

type SourceReplicatePrivilegeChecker

type SourceReplicatePrivilegeChecker struct {
	// contains filtered or unexported fields
}

SourceReplicatePrivilegeChecker checks replication privileges of source DB.

func (*SourceReplicatePrivilegeChecker) Check

Check implements the Checker interface. We only check REPLICATION SLAVE, REPLICATION CLIENT privileges.

func (*SourceReplicatePrivilegeChecker) Name

Name implements the Checker interface.

type State

type State string

State is state of check

const (
	// StateSuccess indicates that the check was successful
	StateSuccess State = "success"
	// StateFailure indicates that the check was failed
	StateFailure State = "fail"
	// StateWarning indicates that the check had warnings
	StateWarning State = "warn"
)

type TablesChecker

type TablesChecker struct {
	// contains filtered or unexported fields
}

TablesChecker checks compatibility of table structures, there are differences between MySQL and TiDB. In generally we need to check definitions of columns, constraints and table options. Because of the early TiDB engineering design, we did not have a complete list of check items, which are all based on experience now.

func (*TablesChecker) Check

func (c *TablesChecker) Check(ctx context.Context) *Result

Check implements Checker interface

func (*TablesChecker) Name

func (c *TablesChecker) Name() string

Name implements Checker interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL