binlog.go 906 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package binlog
  2. import "github.com/beego/beego/v2/client/orm"
  3. // BinlogFormatStruct
  4. // @Description: 数据库的binlog格式
  5. type BinlogFormatStruct struct {
  6. VariableName string `orm:"column(Variable_name)"`
  7. Value string `orm:"column(Value)"`
  8. }
  9. // GetBinlogFormat
  10. // @Description: 获取数据库的binlog格式
  11. // @return item
  12. // @return err
  13. func GetBinlogFormat() (item *BinlogFormatStruct, err error) {
  14. o := orm.NewOrmUsingDB("data")
  15. sql := `SHOW VARIABLES LIKE 'binlog_format'`
  16. err = o.Raw(sql).QueryRow(&item)
  17. return
  18. }
  19. type BinlogFileStruct struct {
  20. File string `orm:"column(File)"`
  21. Position uint32 `orm:"column(Position)"`
  22. }
  23. // GetShowMaster
  24. // @Description: 获取master的状态
  25. // @return item
  26. // @return err
  27. func GetShowMaster() (item *BinlogFileStruct, err error) {
  28. o := orm.NewOrmUsingDB("data")
  29. sql := `show master status`
  30. err = o.Raw(sql).QueryRow(&item)
  31. return
  32. }