Unable to connect to Mongos server in Sharding lesson

Hi,
I am trying to connect to Mongos server as instructed in the lab exercise

I have added this entry in Mongos.conf as in below

sharding:
  configDB: shard1/localhost:27001,localhost:27002,localhost:27003

I had started Mongos config using the below command

mongos -f mongos.conf

When I try to connect to Mongos using the below command

mongo --port 26000 --host localhost --username m103-admin --password m103-pass --authenticationDatabase admin

I am getting ‘Connection Refused’ error. Please help

Have you created m103-admin user on config server?
Just like you create user on data replicaset you need to have user on config server

As per lab problem statement

the m103-admin user has been created on both replica sets with password m103-pass

So it is already created correct?

ok
try without giving host option and see

This is the command I tried

mongo --port 26000 --username m103-admin --password m103-pass --authenticationDatabase admin

This is the error log I found in the terminal

MongoDB shell version v4.0.5

connecting to: mongodb://127.0.0.1:26000/?authSource=admin&gssapiServiceName=mongodb

2020-10-19T13:26:46.947+0000 E QUERY [js] Error: couldn’t connect to server 127.0.0.1:26000, connection attempt failed: SocketException: Error connecting to 127.0.0.1:26000 :: caused by :: Connection refused :

connect@src/mongo/shell/mongo.js:328:13

@(connect):1:6

exception: connect failed

Is your mongos up and running on port 26000?
Check ps -ef|grep mongos

This is the command I used to start Mongos process

mongos -f mongos.conf

I got the below response in the terminal

about to fork child process, waiting until server is ready for connections.

forked process: 1207

When I check whether the mongos process running using the below command

ps -ef|grep mongos

I got the below response

1205 root 0:00 mongos -f mongos.conf
1206 root 0:00 mongos -f mongos.conf
1207 root 0:01 mongos -f mongos.conf
3909 root 0:00 grep mongos

Also this is the mongos.conf file after I had updated

sharding:
configDB: shard1/localhost:27001,localhost:27002,localhost:27003
security:
keyFile: /var/mongodb/pki/m103-keyfile
net:
bindIp: localhost,127.0.0.1
port: 26000
systemLog:
destination: file
path: /var/mongodb/logs/mongos.log
logAppend: true
processManagement:
fork: true

Does the lab instructions ask you to add that line?
How was the original file
From other posts i see you don’t have to edit any config files

This is the original config file before editing

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

When I tried to start mongos command as in below

mongos -f mongos.conf

I got the below error

BadValue: error: no args for --configdb
try 'mongos --help' for more information

If I added this entry in the config

sharding:
    configDB: shard1/localhost:27001,localhost:27002,localhost:27003

I did not get any error. Instead I am getting the response I shared in my previous reply

Please check mongos.log for more details
If 1207 is the PID for your mongos process what are the other two?

Other ports are 1205 and 1206 I had shared in my response already

I have updated sharding database details in config instead of config database.

So updated the below entry

to

sharding:
configDB: csrs/localhost:27004,localhost:27005,localhost:27006

Fixed the issue

Closing this thread as the issue has been resolved.