dump

package
v0.0.0-...-948e253 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SetDumpFlag 设置dump 标志
	SetDumpFlag = 1
	// ReleaseDumpFlag 释放dump 标志
	ReleaseDumpFlag = 0
	// AddRuleFlag 添加规则标志
	AddRuleFlag = 2
	// DelRuleFlag 删除规则标志
	DelRuleFlag = 3
	// RestartCanalFlag 重启解析标志
	RestartCanalFlag = 4
	// RuleApplySuccess 规则修改完成
	RuleApplySuccess = 1
)
View Source
var DumpFlagChan = make(chan int)

DumpFlagChan dump flag chan

View Source
var RuleChan = make(chan int)

RuleChan 重新启动后,需要将rule operation 字段置成0

Functions

func DelPosTable

func DelPosTable()

DelPosTable 保留最近的ReserveHours小时的数据

func GetBinlogFromMysqlPosInfo

func GetBinlogFromMysqlPosInfo(sql string, args ...interface{}) (string, int)

GetBinlogFromMysqlPosInfo 查询mysql_pos_info表获取新主对应的位置

func GetMasterStatus

func GetMasterStatus() (string, int)

GetMasterStatus 获取master binlog file and pos

func GetNewBinlogBefore

func GetNewBinlogBefore(mysqlAddr string, binlog string, pos uint32) (string, int)

GetNewBinlogBefore 新主根据mysql_pos_info表向前最接近working_info位置点,作为同步位置

func GetNewMasterBinlogInfo

func GetNewMasterBinlogInfo(mysqlAddr string, binlog string, pos uint32) (string, int)

GetNewMasterBinlogInfo 主从切换后,根据fusion处理到的老主节点的位置信息和mysql_pos_info表中信息来确定新主的位置进行同步

func GetSlaveInfo

func GetSlaveInfo() (string, string, string, string)

GetSlaveInfo 获取从节点的info

func Manually

func Manually(tables string, flag int) error

Manually flag = 0 手动dump, 用以恢复不一致的内存数据, flag = 2 , 添加新规则,全量dump 需要dump 的数据, flag = 1 删除规则, 重启fusion 加载最新的同步表信息

func Monitor

func Monitor()

Monitor 监听表规则是否增加or 删除, 并根据配置信息决定是否dump 数据

func MonitorMysqlPos

func MonitorMysqlPos()

MonitorMysqlPos 每秒获取一次mysql主从pos对应关系,写入到数据库表mysql_pos_info,便于主从切换时找到从节点对应的pos位置

Types

type MasterStatus

type MasterStatus struct {
	File            string `db:"File"`
	Position        int    `db:"Position"`
	BinlogDoDB      string `db:"Binlog_Do_DB"`
	BinlogIgnoreDB  string `db:"Binlog_Ignore_DB"`
	ExecutedGtidSet string `db:"Executed_Gtid_Set"`
}

MasterStatus keep master file and pos

type MysqlPosInfo

type MysqlPosInfo struct {
	SID              int         `db:"sid"`
	MasterMysqlAddr  string      `db:"master_mysql_addr"`
	MasterBinlogFile interface{} `db:"master_binlog_file_name"`
	MasterBinlogPos  interface{} `db:"master_binlog_position"`
	SlaveMysqlAddr   string      `db:"slave_mysql_addr"`
	SlaveBinlogFile  string      `db:"slave_binlog_file_name"`
	SlaveBinlogPos   int         `db:"slave_binlog_position"`
}

MysqlPosInfo mysql_pos_info

func GetPosFromSlave

func GetPosFromSlave() (MysqlPosInfo, error)

GetPosFromSlave 在从节点获取主从当前的pos,写入到数据库表mysql_pos_info

Jump to

Keyboard shortcuts

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