0

I'm working with Debian 4.9.168 and I want to configure mongoDB replica set monitoring through google cloud, and I found the best solution is through bindplane bluemedora (currect me if I wrong).

So, I deployed my mongo replica and I need to start a mongos instance. I started it with that command:

sudo mongos --configdb rs0/<MYFIRSTIP>:27019,<MYSECONDIP>:27019 --bind_ip 0.0.0.0

and I'm getting that error:

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] Failed to set up listener: SocketException: Address already in use 2019-06-09T14:18:07.900+0000 I CONTROL [mongosMain] shutting down with code:48

So I checked if there's a process that uses that address, and there isn't:

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

my /etc/mongod.conf file (created automaticly through mongoDB application in Google cloud - 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:

I really appreciate any kind of help. Thank you :)

0

You're binding mongos on 0.0.0.0:

--bind_ip 0.0.0.0

And by default (from your config), it binds on port 2017:

  net:
  port: 27017
  bindIp: 0.0.0.0

Your netstat shows that there is already a process listening on 0.0.0.0:2017:

tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN  

So I suggest either you change your config, or kill your already running mongos process (seems like that is what is using the address). Try checking with the following command:

ps aux | grep mongod
  • mongos is not running :( ps aux | grep mongos idan_ch+ 2228 0.0 0.0 12780 1004 pts/0 S+ 15:01 0:00 grep mongos – Idan Chau Jun 9 at 15:01
  • @IdanChau try using netstat -tunap (add the -p flag for process ID and name) – Fanatique Jun 10 at 8:08
  • still there isn't mongos process. my netstat -tunap output – Idan Chau Jun 10 at 8:34
  • @IdanChau what do you mean there isn't? There is. The process name is mongod. The first process which is listening on 0.0.0.0:27017 is mongod. I'll edit my answer, run ps aux | grep mongod and then check. – Fanatique Jun 10 at 9:27
  • yeah mongod is running, but I'm trying to start mongos too. When I killed mongod and started mongos I got error of "can't connect to master" so I needed to start both processes, but when I try to start mongos AND mongod (but in another port) it says address already in use - no matter which port I use. – Idan Chau Jun 10 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.