mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
default bind to one ip address
fix https://github.com/chrislusf/seaweedfs/issues/1937
This commit is contained in:
parent
728bf50a73
commit
3a6eb8ca5f
|
@ -60,7 +60,7 @@ func init() {
|
||||||
f.mastersString = cmdFiler.Flag.String("master", "localhost:9333", "comma-separated master servers")
|
f.mastersString = cmdFiler.Flag.String("master", "localhost:9333", "comma-separated master servers")
|
||||||
f.collection = cmdFiler.Flag.String("collection", "", "all data will be stored in this default collection")
|
f.collection = cmdFiler.Flag.String("collection", "", "all data will be stored in this default collection")
|
||||||
f.ip = cmdFiler.Flag.String("ip", util.DetectedHostAddress(), "filer server http listen ip address")
|
f.ip = cmdFiler.Flag.String("ip", util.DetectedHostAddress(), "filer server http listen ip address")
|
||||||
f.bindIp = cmdFiler.Flag.String("ip.bind", "", "ip address to bind to")
|
f.bindIp = cmdFiler.Flag.String("ip.bind", "", "ip address to bind to. If empty, default to same as -ip option.")
|
||||||
f.port = cmdFiler.Flag.Int("port", 8888, "filer server http listen port")
|
f.port = cmdFiler.Flag.Int("port", 8888, "filer server http listen port")
|
||||||
f.portGrpc = cmdFiler.Flag.Int("port.grpc", 0, "filer server grpc listen port")
|
f.portGrpc = cmdFiler.Flag.Int("port.grpc", 0, "filer server grpc listen port")
|
||||||
f.publicPort = cmdFiler.Flag.Int("port.readonly", 0, "readonly port opened to public")
|
f.publicPort = cmdFiler.Flag.Int("port.readonly", 0, "readonly port opened to public")
|
||||||
|
@ -188,6 +188,9 @@ func (fo *FilerOptions) startFiler() {
|
||||||
if *fo.portGrpc == 0 {
|
if *fo.portGrpc == 0 {
|
||||||
*fo.portGrpc = 10000 + *fo.port
|
*fo.portGrpc = 10000 + *fo.port
|
||||||
}
|
}
|
||||||
|
if *fo.bindIp == "" {
|
||||||
|
*fo.bindIp = *fo.ip
|
||||||
|
}
|
||||||
|
|
||||||
defaultLevelDbDirectory := util.ResolvePath(*fo.defaultLevelDbDirectory + "/filerldb2")
|
defaultLevelDbDirectory := util.ResolvePath(*fo.defaultLevelDbDirectory + "/filerldb2")
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ func init() {
|
||||||
m.port = cmdMaster.Flag.Int("port", 9333, "http listen port")
|
m.port = cmdMaster.Flag.Int("port", 9333, "http listen port")
|
||||||
m.portGrpc = cmdMaster.Flag.Int("port.grpc", 0, "grpc listen port")
|
m.portGrpc = cmdMaster.Flag.Int("port.grpc", 0, "grpc listen port")
|
||||||
m.ip = cmdMaster.Flag.String("ip", util.DetectedHostAddress(), "master <ip>|<server> address, also used as identifier")
|
m.ip = cmdMaster.Flag.String("ip", util.DetectedHostAddress(), "master <ip>|<server> address, also used as identifier")
|
||||||
m.ipBind = cmdMaster.Flag.String("ip.bind", "", "ip address to bind to")
|
m.ipBind = cmdMaster.Flag.String("ip.bind", "", "ip address to bind to. If empty, default to same as -ip option.")
|
||||||
m.metaFolder = cmdMaster.Flag.String("mdir", os.TempDir(), "data directory to store meta data")
|
m.metaFolder = cmdMaster.Flag.String("mdir", os.TempDir(), "data directory to store meta data")
|
||||||
m.peers = cmdMaster.Flag.String("peers", "", "all master nodes in comma separated ip:port list, example: 127.0.0.1:9093,127.0.0.1:9094,127.0.0.1:9095")
|
m.peers = cmdMaster.Flag.String("peers", "", "all master nodes in comma separated ip:port list, example: 127.0.0.1:9093,127.0.0.1:9094,127.0.0.1:9095")
|
||||||
m.volumeSizeLimitMB = cmdMaster.Flag.Uint("volumeSizeLimitMB", 30*1000, "Master stops directing writes to oversized volumes.")
|
m.volumeSizeLimitMB = cmdMaster.Flag.Uint("volumeSizeLimitMB", 30*1000, "Master stops directing writes to oversized volumes.")
|
||||||
|
@ -124,6 +124,9 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {
|
||||||
if *masterOption.portGrpc == 0 {
|
if *masterOption.portGrpc == 0 {
|
||||||
*masterOption.portGrpc = 10000 + *masterOption.port
|
*masterOption.portGrpc = 10000 + *masterOption.port
|
||||||
}
|
}
|
||||||
|
if *masterOption.ipBind == "" {
|
||||||
|
*masterOption.ipBind = "localhost"
|
||||||
|
}
|
||||||
|
|
||||||
myMasterAddress, peers := checkPeers(*masterOption.ip, *masterOption.port, *masterOption.portGrpc, *masterOption.peers)
|
myMasterAddress, peers := checkPeers(*masterOption.ip, *masterOption.port, *masterOption.portGrpc, *masterOption.peers)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ func init() {
|
||||||
cmdMasterFollower.Run = runMasterFollower // break init cycle
|
cmdMasterFollower.Run = runMasterFollower // break init cycle
|
||||||
mf.port = cmdMasterFollower.Flag.Int("port", 9334, "http listen port")
|
mf.port = cmdMasterFollower.Flag.Int("port", 9334, "http listen port")
|
||||||
mf.portGrpc = cmdMasterFollower.Flag.Int("port.grpc", 0, "grpc listen port")
|
mf.portGrpc = cmdMasterFollower.Flag.Int("port.grpc", 0, "grpc listen port")
|
||||||
mf.ipBind = cmdMasterFollower.Flag.String("ip.bind", "", "ip address to bind to")
|
mf.ipBind = cmdMasterFollower.Flag.String("ip.bind", "", "ip address to bind to. Default to localhost.")
|
||||||
mf.peers = cmdMasterFollower.Flag.String("masters", "localhost:9333", "all master nodes in comma separated ip:port list, example: 127.0.0.1:9093,127.0.0.1:9094,127.0.0.1:9095")
|
mf.peers = cmdMasterFollower.Flag.String("masters", "localhost:9333", "all master nodes in comma separated ip:port list, example: 127.0.0.1:9093,127.0.0.1:9094,127.0.0.1:9095")
|
||||||
|
|
||||||
mf.ip = aws.String(util.DetectedHostAddress())
|
mf.ip = aws.String(util.DetectedHostAddress())
|
||||||
|
@ -111,6 +111,10 @@ func startMasterFollower(masterOptions MasterOptions) {
|
||||||
option := masterOptions.toMasterOption(nil)
|
option := masterOptions.toMasterOption(nil)
|
||||||
option.IsFollower = true
|
option.IsFollower = true
|
||||||
|
|
||||||
|
if *masterOptions.ipBind == "" {
|
||||||
|
*masterOptions.ipBind = "localhost"
|
||||||
|
}
|
||||||
|
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
ms := weed_server.NewMasterServer(r, option, masters)
|
ms := weed_server.NewMasterServer(r, option, masters)
|
||||||
listeningAddress := util.JoinHostPort(*masterOptions.ipBind, *masterOptions.port)
|
listeningAddress := util.JoinHostPort(*masterOptions.ipBind, *masterOptions.port)
|
||||||
|
|
|
@ -40,7 +40,7 @@ type S3Options struct {
|
||||||
func init() {
|
func init() {
|
||||||
cmdS3.Run = runS3 // break init cycle
|
cmdS3.Run = runS3 // break init cycle
|
||||||
s3StandaloneOptions.filer = cmdS3.Flag.String("filer", "localhost:8888", "filer server address")
|
s3StandaloneOptions.filer = cmdS3.Flag.String("filer", "localhost:8888", "filer server address")
|
||||||
s3StandaloneOptions.bindIp = cmdS3.Flag.String("ip.bind", "", "ip address to bind to")
|
s3StandaloneOptions.bindIp = cmdS3.Flag.String("ip.bind", "", "ip address to bind to. Default to localhost.")
|
||||||
s3StandaloneOptions.port = cmdS3.Flag.Int("port", 8333, "s3 server http listen port")
|
s3StandaloneOptions.port = cmdS3.Flag.Int("port", 8333, "s3 server http listen port")
|
||||||
s3StandaloneOptions.domainName = cmdS3.Flag.String("domainName", "", "suffix of the host name in comma separated list, {bucket}.{domainName}")
|
s3StandaloneOptions.domainName = cmdS3.Flag.String("domainName", "", "suffix of the host name in comma separated list, {bucket}.{domainName}")
|
||||||
s3StandaloneOptions.config = cmdS3.Flag.String("config", "", "path to the config file")
|
s3StandaloneOptions.config = cmdS3.Flag.String("config", "", "path to the config file")
|
||||||
|
@ -193,6 +193,10 @@ func (s3opt *S3Options) startS3Server() bool {
|
||||||
|
|
||||||
httpS := &http.Server{Handler: router}
|
httpS := &http.Server{Handler: router}
|
||||||
|
|
||||||
|
if *s3opt.bindIp == "" {
|
||||||
|
*s3opt.bindIp = "localhost"
|
||||||
|
}
|
||||||
|
|
||||||
listenAddress := fmt.Sprintf("%s:%d", *s3opt.bindIp, *s3opt.port)
|
listenAddress := fmt.Sprintf("%s:%d", *s3opt.bindIp, *s3opt.port)
|
||||||
s3ApiListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second)
|
s3ApiListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -55,7 +55,7 @@ var cmdServer = &Command{
|
||||||
|
|
||||||
var (
|
var (
|
||||||
serverIp = cmdServer.Flag.String("ip", util.DetectedHostAddress(), "ip or server name, also used as identifier")
|
serverIp = cmdServer.Flag.String("ip", util.DetectedHostAddress(), "ip or server name, also used as identifier")
|
||||||
serverBindIp = cmdServer.Flag.String("ip.bind", "", "ip address to bind to")
|
serverBindIp = cmdServer.Flag.String("ip.bind", "", "ip address to bind to. If empty, default to same as -ip option.")
|
||||||
serverTimeout = cmdServer.Flag.Int("idleTimeout", 30, "connection idle seconds")
|
serverTimeout = cmdServer.Flag.Int("idleTimeout", 30, "connection idle seconds")
|
||||||
serverDataCenter = cmdServer.Flag.String("dataCenter", "", "current volume server's data center name")
|
serverDataCenter = cmdServer.Flag.String("dataCenter", "", "current volume server's data center name")
|
||||||
serverRack = cmdServer.Flag.String("rack", "", "current volume server's rack name")
|
serverRack = cmdServer.Flag.String("rack", "", "current volume server's rack name")
|
||||||
|
@ -184,6 +184,10 @@ func runServer(cmd *Command, args []string) bool {
|
||||||
masterOptions.peers = &peers
|
masterOptions.peers = &peers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *serverBindIp == "" {
|
||||||
|
serverBindIp = serverIp
|
||||||
|
}
|
||||||
|
|
||||||
// ip address
|
// ip address
|
||||||
masterOptions.ip = serverIp
|
masterOptions.ip = serverIp
|
||||||
masterOptions.ipBind = serverBindIp
|
masterOptions.ipBind = serverBindIp
|
||||||
|
|
|
@ -74,7 +74,7 @@ func init() {
|
||||||
v.publicPort = cmdVolume.Flag.Int("port.public", 0, "port opened to public")
|
v.publicPort = cmdVolume.Flag.Int("port.public", 0, "port opened to public")
|
||||||
v.ip = cmdVolume.Flag.String("ip", util.DetectedHostAddress(), "ip or server name, also used as identifier")
|
v.ip = cmdVolume.Flag.String("ip", util.DetectedHostAddress(), "ip or server name, also used as identifier")
|
||||||
v.publicUrl = cmdVolume.Flag.String("publicUrl", "", "Publicly accessible address")
|
v.publicUrl = cmdVolume.Flag.String("publicUrl", "", "Publicly accessible address")
|
||||||
v.bindIp = cmdVolume.Flag.String("ip.bind", "", "ip address to bind to")
|
v.bindIp = cmdVolume.Flag.String("ip.bind", "", "ip address to bind to. If empty, default to same as -ip option.")
|
||||||
v.mastersString = cmdVolume.Flag.String("mserver", "localhost:9333", "comma-separated master servers")
|
v.mastersString = cmdVolume.Flag.String("mserver", "localhost:9333", "comma-separated master servers")
|
||||||
v.preStopSeconds = cmdVolume.Flag.Int("preStopSeconds", 10, "number of seconds between stop send heartbeats and stop volume server")
|
v.preStopSeconds = cmdVolume.Flag.Int("preStopSeconds", 10, "number of seconds between stop send heartbeats and stop volume server")
|
||||||
// v.pulseSeconds = cmdVolume.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats, must be smaller than or equal to the master's setting")
|
// v.pulseSeconds = cmdVolume.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats, must be smaller than or equal to the master's setting")
|
||||||
|
@ -193,6 +193,9 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
|
||||||
*v.ip = util.DetectedHostAddress()
|
*v.ip = util.DetectedHostAddress()
|
||||||
glog.V(0).Infof("detected volume server ip address: %v", *v.ip)
|
glog.V(0).Infof("detected volume server ip address: %v", *v.ip)
|
||||||
}
|
}
|
||||||
|
if *v.bindIp == "" {
|
||||||
|
*v.bindIp = *v.ip
|
||||||
|
}
|
||||||
|
|
||||||
if *v.publicPort == 0 {
|
if *v.publicPort == 0 {
|
||||||
*v.publicPort = *v.port
|
*v.publicPort = *v.port
|
||||||
|
|
Loading…
Reference in a new issue