I have a mongo shared cluster and replica sets:
The ShardA Replica set:
A1. 10.77.14.241
A2. 10.77.14.242
AA. 10.77.14.243 Arbiter
Some parameters of /etc/mongod.conf:
#bind_ip=127.0.0.1
auth=true
replSet=ShardB
keyFile=/srv/mongodb/mongodb-keyfile
The ShardB Replica set:
B1. 10.77.14.244
B2. 10.77.14.245
BA. 10.77.14.246 Arbiter
Some parameters of /etc/mongod.conf:
#bind_ip=127.0.0.1
auth=true
replSet=ShardB
keyFile=/srv/mongodb/mongodb-keyfile
The Config and Mongos servers:
C1. 10.77.14.247
C2. 10.77.14.248
C3. 10.77.14.249
All instances of config mongod and mongos are started in /etc/rc.local:
mongod --configsvr --logpath /var/log/mongodb/mongod.log --keyFile /srv/mongodb/mongodb-keyfile --fork
mongos --configdb 10.77.14.247:27019,10.77.14.248:27019,10.77.14.249:27019 --port 40000 --logpath /data/mongos.log --keyFile /srv/mongodb/mongodb-keyfile --fork
The Replica sets work correctly. If I insert documents in the primary member it replicates on the secondary member.
I have following issue:
On any arbiter, mongod config, mongos –
use admin
switched to db admin
mongos> db.auth({user: 'admin', pwd: '12345678'})
Error: 18 Authentication failed.
0
Hence i can't insert documents to a DB over mongos.
Do I have to enable a sharding of the admin a DB?
Best Answer
I reread http://docs.mongodb.org/manual/tutorial/enable-authentication-without-bypass/ :)
1) I started on the C1, C2, C3:
2) I created a new user on mongos:
3) I restarted instances of the mongod config and mongos --keyfile parameter:
4) Adding Shards was succesful: