本文整理汇总了Golang中github.com/yiduoyunQ/sm/sm-svr/swarm.Swarm.MasterReset方法的典型用法代码示例。如果您正苦于以下问题:Golang Swarm.MasterReset方法的具体用法?Golang Swarm.MasterReset怎么用?Golang Swarm.MasterReset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/yiduoyunQ/sm/sm-svr/swarm.Swarm
的用法示例。
在下文中一共展示了Swarm.MasterReset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: clearMaster
func clearMaster(dbName string, swm *swarm.Swarm) error {
err := swm.MasterReset(dbName)
if err != nil {
return err
}
return nil
}
示例2: changeMaster
func changeMaster(swm *swarm.Swarm, fromName, toIp string, toPort int) error {
slaveStatus, err := swm.SlaveShowStatus(fromName)
if err != nil {
return err
}
log.WithFields(log.Fields{
"DbName": fromName,
"SlaveStatus": slaveStatus,
}).Debug("change master")
if slaveStatus.MasterIp == toIp && slaveStatus.MasterPort == toPort {
if slaveStatus.SlaveIoRunning == "No" && slaveStatus.SlaveSqlRunning == "No" {
// 1.4 start slave
err = swm.SlaveStart(fromName)
if err != nil {
return err
}
}
return nil
}
if slaveStatus.SlaveIoRunning == "Yes" || slaveStatus.SlaveSqlRunning == "Yes" {
// 1.1 stop slave
err = swm.SlaveStop(fromName)
if err != nil {
return err
}
}
if slaveStatus.MasterIp != "" {
// 1.2 reset slave
err = swm.SlaveReset(fromName)
if err != nil {
return err
}
}
// 1.3 get gtid_executed
gtidExecuted, err := swm.GetGtidExecuted(fromName)
if err != nil {
return err
}
if gtidExecuted != "" {
// 1.4 reset master
err = swm.MasterReset(fromName)
if err != nil {
return err
}
// 1.5 set gtid_purged
err = swm.SetGtidPurged(fromName, gtidExecuted)
if err != nil {
return err
}
}
// 1.6 change master
err = swm.ChangeMaster(fromName, toIp, toPort)
if err != nil {
return err
}
// 1.7 start slave
err = swm.SlaveStart(fromName)
if err != nil {
return err
}
return nil
}