Lab: Deploy a Sharded Cluster

I have edited the mongos.conf file to be:

security:
  keyFile: /var/mongodb/pki/m103-keyfile
net:
  bindIp: localhost
  port: 26000
systemLog:
  destination: file
  path: /var/mongodb/logs/mongos.log
  logAppend: true
processManagement:
  fork: true
sharding:
  configDB: csrs/localhost:27004,localhost:27005,localhost:27006

I then run the command mongos -f mongos.conf to start mongos

I then try to authenticate to the database with the command mongo --port 2600 -u "m103-admin" -p "m103-pass" --authenticationDatabase "admin" but I get the error:

MongoDB shell version v4.0.5
connecting to: mongodb://127.0.0.1:2600/?authSource=admin&gssapiServiceName=mongodb
2020-11-24T22:00:03.868+0000 E QUERY    [js] Error: couldn't connect to server 127.0.0.1:2600, connection attempt failed: SocketException: Error connecting to 127.0.0.1:2600 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed

Any ideas on what I’m doing incorrectly?

Your --port is wrong. You started mongod at port 26000 yet you try to connect with port 2600.

1 Like

Hi @Eric_Kenney,

I hope you found @steevej-1495’s response helpful and you were able to resolve the issue.

Let us know if you are still facing any issues.

~ Shubham

I connected with the config file but later when trying to connect to mongo asks me for a password. is not m103-pass
is my config file wrong?


sharding:
configDB: csrs/localhost:27004,localhost:27005,localhost:27006
security:
keyFile: /var/mongodb/pki/m103-keyfile
net:
bindIp: localhost
port: 26000
systemLog:
destination: file
path: /var/mongodb/logs/mongos.log
logAppend: true
processManagement:
fork: true


mongos -f mongos.conf
about to fork child process, waiting until server is ready for connections.
forked process: 852
child process started successfully, parent exiting

I think your command is not ok
Space is missing after m103-admin

yes thanks for your help !!!