我正在使用 Debian 4.9.168,我想通过 google cloud 配置 mongoDB 副本集监控,我发现最好的解决方案是通过 bindplane bluemedora(如果我错了请纠正我)。
因此,我部署了我的 mongo 副本,并且需要启动一个 mongos 实例。我使用以下命令启动了它:
sudo mongos --configdb rs0/<MYFIRSTIP>:27019,<MYSECONDIP>:27019 --bind_ip 0.0.0.0
我收到了这个错误:
2019-06-09T14:18:07.899+0000 I CONTROL [mongosMain] options: { net: { bindIp: "0.0.0.0" }, sharding: { configDB: "rs0/<MYIP>:27019,35.222.135.175:27019" } }
2019-06-09T14:18:07.900+0000 E SHARDING [mongosMain] 无法设置侦听器:SocketException:地址已在使用中 2019-06-09T14:18:07.900+0000 I CONTROL [mongosMain] 关闭,代码:48
因此我检查了是否有一个进程使用该地址,但是没有:
netstat -tuna | grep 2701
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN
tcp 0 0 10.128.0.13:38586 10.128.0.14:27017 ESTABLISHED
tcp 0 0 10.128.0.13:27017 10.128.0.14:56518 ESTABLISHED
tcp 0 0 10.128.0.13:27017 10.128.0.14:56498 ESTABLISHED
tcp 0 0 10.128.0.13:27017 10.128.0.14:56552 ESTABLISHED
tcp 0 0 10.128.0.13:27017 10.128.0.14:56492 ESTABLISHED
tcp 0 0 10.128.0.13:27017 10.128.0.14:56550 ESTABLISHED
我的 /etc/mongod.conf 文件(通过 Google Cloud 中的 mongoDB 应用程序自动创建 -https://console.cloud.google.com/marketplace/details/click-to-deploy-images/mongodb):
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /mnt/mongodb/db
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
#
# MongoDB 3.0.x *debian* packages set bind_ip to 127.0.0.1 by default
# Compute Engine public addresses are properly firewalled by default
# set bind_ip to 0.0.0.0 to emulate pre-2.6 behavior which eases maintenance
net:
port: 27017
bindIp: 0.0.0.0
#processManagement:
#security:
#authorization: enabled
#keyFile: replace_me
#operationProfiling:
replication:
replSetName: rs0
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
我非常感谢任何形式的帮助。谢谢 :)
答案1
您正在绑定 mongos 0.0.0.0
:
--bind_ip 0.0.0.0
默认情况下(从您的配置),它绑定在端口上2017
:
net:
port: 27017
bindIp: 0.0.0.0
您的 netstat 显示已有一个进程正在监听0.0.0.0:2017
:
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN
因此,我建议您更改配置,或者终止正在运行的 mongos 进程(似乎该进程正在使用该地址)。尝试使用以下命令进行检查:
ps aux | grep mongod