本文整理匯總了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
}