change ledis-load refer mysql load dump

although dump file may include master bin log information, ledis-load
will not change in slave but to output.
This commit is contained in:
siddontang 2014-07-20 16:15:23 +08:00
parent feb3c68f61
commit 39e28b7f17
1 changed files with 7 additions and 12 deletions

View File

@ -3,16 +3,13 @@ package main
import (
"encoding/json"
"flag"
"fmt"
"github.com/siddontang/ledisdb/ledis"
"github.com/siddontang/ledisdb/server"
"io/ioutil"
"path"
)
var configPath = flag.String("config", "/etc/ledis.json", "ledisdb config file")
var dumpPath = flag.String("dump_file", "", "ledisdb dump file")
var masterAddr = flag.String("master_addr", "",
"master addr to set where dump file comes from, if not set correctly, next slaveof may cause fullsync")
func main() {
flag.Parse()
@ -74,13 +71,11 @@ func loadDump(cfg *ledis.Config, ldb *ledis.Ledis) error {
return err
}
info := new(server.MasterInfo)
//master enable binlog, here output this like mysql
if head.LogFileIndex != 0 && head.LogPos != 0 {
format := "-- CHANGE MASTER TO MASTER_LOG_FILE='binlog.%07d', MASTER_LOG_POS=%d;\n"
fmt.Printf(format, head.LogFileIndex, head.LogPos)
}
info.Addr = *masterAddr
info.LogFileIndex = head.LogFileIndex
info.LogPos = head.LogPos
infoFile := path.Join(cfg.DataDir, "master.info")
return info.Save(infoFile)
return nil
}