mirror of https://github.com/ledisdb/ledisdb.git
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:
parent
feb3c68f61
commit
39e28b7f17
|
@ -3,16 +3,13 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"github.com/siddontang/ledisdb/ledis"
|
"github.com/siddontang/ledisdb/ledis"
|
||||||
"github.com/siddontang/ledisdb/server"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var configPath = flag.String("config", "/etc/ledis.json", "ledisdb config file")
|
var configPath = flag.String("config", "/etc/ledis.json", "ledisdb config file")
|
||||||
var dumpPath = flag.String("dump_file", "", "ledisdb dump 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() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -74,13 +71,11 @@ func loadDump(cfg *ledis.Config, ldb *ledis.Ledis) error {
|
||||||
return err
|
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
|
return nil
|
||||||
info.LogFileIndex = head.LogFileIndex
|
|
||||||
info.LogPos = head.LogPos
|
|
||||||
|
|
||||||
infoFile := path.Join(cfg.DataDir, "master.info")
|
|
||||||
|
|
||||||
return info.Save(infoFile)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue