diff --git a/cmd/drainer/README.md b/cmd/drainer/README.md index ab70faea9..0921b9a76 100644 --- a/cmd/drainer/README.md +++ b/cmd/drainer/README.md @@ -41,6 +41,8 @@ Usage of drainer: prometheus pushgateway address, leaves it empty will disable prometheus push -metrics-interval int prometheus client push interval in second, set "0" to disable prometheus push (default 15) + -node-id string + the ID of drainer node; if not specified, we will generate one from hostname and the listening port -pd-urls string a comma separated list of PD endpoints (default "http://127.0.0.1:2379") -safe-mode diff --git a/cmd/pump/README.md b/cmd/pump/README.md index 44228b4f7..bde9bd4f4 100644 --- a/cmd/pump/README.md +++ b/cmd/pump/README.md @@ -34,7 +34,7 @@ pump is a daemon that receives realtime binlog from tidb-server and writes in se -metrics-interval int prometheus client push interval in second, set "0" to disable prometheus push (default 15) -node-id string - the ID of pump node; if not specify, we will generate one from hostname and the listening port + the ID of pump node; if not specified, we will generate one from hostname and the listening port -pd-urls string a comma separated list of the PD endpoints (default "http://127.0.0.1:2379") -zookeeper-addrs string diff --git a/drainer/config.go b/drainer/config.go index 0e8649e43..2f49d0612 100644 --- a/drainer/config.go +++ b/drainer/config.go @@ -79,6 +79,7 @@ type SyncerConfig struct { type Config struct { *flag.FlagSet `json:"-"` LogLevel string `toml:"log-level" json:"log-level"` + NodeID string `toml:"node-id" json:"node-id"` ListenAddr string `toml:"addr" json:"addr"` AdvertiseAddr string `toml:"advertise-addr" json:"advertise-addr"` DataDir string `toml:"data-dir" json:"data-dir"` @@ -110,6 +111,7 @@ func NewConfig() *Config { fmt.Fprintln(os.Stderr, "Usage of drainer:") fs.PrintDefaults() } + fs.StringVar(&cfg.NodeID, "node-id", "", "the ID of drainer node; if not specified, we will generate one from hostname and the listening port") fs.StringVar(&cfg.ListenAddr, "addr", util.DefaultListenAddr(8249), "addr (i.e. 'host:port') to listen on for drainer connections") fs.StringVar(&cfg.AdvertiseAddr, "advertise-addr", "", "addr(i.e. 'host:port') to advertise to the public, default to be the same value as -addr") fs.StringVar(&cfg.DataDir, "data-dir", defaultDataDir, "drainer data directory path (default data.drainer)") diff --git a/drainer/server.go b/drainer/server.go index 0a6f79c5a..df00b2cd6 100644 --- a/drainer/server.go +++ b/drainer/server.go @@ -86,9 +86,12 @@ func init() { // NewServer return a instance of binlog-server func NewServer(cfg *Config) (*Server, error) { - ID, err := genDrainerID(cfg.ListenAddr) - if err != nil { - return nil, errors.Trace(err) + if cfg.NodeID == "" { + var err error + cfg.NodeID, err = genDrainerID(cfg.ListenAddr) + if err != nil { + return nil, errors.Trace(err) + } } if err := os.MkdirAll(cfg.DataDir, 0700); err != nil { @@ -148,10 +151,10 @@ func NewServer(cfg *Config) (*Server, error) { return nil, errors.Annotatef(err, "invalid configuration of advertise addr(%s)", cfg.AdvertiseAddr) } - status := node.NewStatus(ID, advURL.Host, node.Online, 0, syncer.GetLatestCommitTS(), util.GetApproachTS(latestTS, latestTime)) + status := node.NewStatus(cfg.NodeID, advURL.Host, node.Online, 0, syncer.GetLatestCommitTS(), util.GetApproachTS(latestTS, latestTime)) return &Server{ - ID: ID, + ID: cfg.NodeID, host: advURL.Host, cfg: cfg, collector: c, diff --git a/pump/config.go b/pump/config.go index b3a4932bb..987c7aec9 100644 --- a/pump/config.go +++ b/pump/config.go @@ -93,7 +93,7 @@ func NewConfig() *Config { fs.PrintDefaults() } - fs.StringVar(&cfg.NodeID, "node-id", "", "the ID of pump node; if not specify, we will generate one from hostname and the listening port") + fs.StringVar(&cfg.NodeID, "node-id", "", "the ID of pump node; if not specified, we will generate one from hostname and the listening port") fs.StringVar(&cfg.ListenAddr, "addr", util.DefaultListenAddr(8250), "addr(i.e. 'host:port') to listen on for client traffic") fs.StringVar(&cfg.AdvertiseAddr, "advertise-addr", "", "addr(i.e. 'host:port') to advertise to the public") fs.StringVar(&cfg.Socket, "socket", "", "unix socket addr to listen on for client traffic")