Error:Connect to MongoClient using SSL = true
$mc = new MongoClient("mongodb://server1", array("ssl" => true));
Cause: Your mongod instance is running but not properly configured with ssl.
Error:Connect to MongoClient using SSL = true
$mc = new MongoClient("mongodb://server1", array("ssl" => true));
Cause: Your mongod instance is running but not properly configured with ssl.
Error: mongod cannot start with error: keyFile too open permissions
Cause: Mongod key file accepts only mode 600 (read and write by owner only)
chmod 600 ./keyFile
Error: When use rs.Add():
{
“errmsg” : “exception: can’t use localhost in repl set member names except when using it for all members”,
“code” : 13393,
“ok” : 0
}
Cause:
1. Your replica set is using localhost for it members and you are adding a new member with IP/hostname other than localhost
2. Your replica set is using IP/hostname for it members and you are adding a new member with localhost as hostname
Solution: Only use localhost for replica set members if you are sure that all mongod/mongos instance are on the same local machine. Otherwise, use hostname or IP.
Error: When use coomand rs.initiate()
{ “errmsg” : “couldn’t initiate : can’t find self in the replset config”, “ok” : 0 }
Cause: a hostname(s) of a replica set member(s) cannot be resolved
Solution: Add hostname(s) in /etc/hosts
Error: addShard() command returns error:
{
“ok” : 0,
“errmsg” : “couldn’t connect to new shard socket exception [CONNECT_ERROR] for replname/hostname:27017″
}
Cause:
1. hostname:27017 cannot be reached
2. if hostname:27017 can be reached, then your replica set [replname] configuration contains members with ‘localhost‘ as host name
Solution: Unless you are running all mongod/mongos instances on the same machine, then you can use ‘localhost’ in rs.Add() command. Otherwise, use hostname instead of localhost in all rs.Add(), sh.addShard() command. Note that when adding a host itself to replcaset/shard an usable hostname should be present in /etc/hosts, or you will get this error:
{ “errmsg” : “couldn’t initiate : can’t find self in the replset config”, “ok” : 0 }
First, get the list of packages to be removed:
rpm -qa –qf=”%{n}-%{v}-%{r}.%{arch}n” ‘mongo*’ | sort
Then use yum remove
sudo yum remove
Error: replset couldn’t find a slave with id 1, not tracking
Causes: After removing and adding replica to MongoDB replica set using rs.add() and rs.remove(), the replica set member id’s don’t follow a continuous order from _id: 0, for example:
{
“_id” : “rs0″,
“version” : 1,
“members” : [
{
“_id” : 4,
“host” : “mongodb0.example.net:27017″
},
{
“_id” : 5,
“host” : “mongodb1.example.net:27017″
},
{
“_id” : 7,
“host” : “mongodb2.example.net:27017″
}
]
}
Solution: You can use rs.reconfig() to re-etablish the order:
var cfg = {
“_id” : “rs0″,
“version” : 1,
“members” : [
{
“_id” : 0,
“host” : “mongodb0.example.net:27017″
},
{
“_id” : 1,
“host” : “mongodb1.example.net:27017″
},
{
“_id” : 2,
“host” : “mongodb2.example.net:27017″
}
]
}
rs.reconfig(cfg);
Error: When starting the MongoDB service in the prompt (c:mongodbbinmongod.exe), I get the following error:
exception in initAndListen:13082 getnameinfo error errno:10106
The requested service provider could not be loaded or initialized.. terminating
Cause: This is a WinSock error as in the mongod.log
WSAEPROVIDERFAILEDINIT [10106]: Service provider failed to initialize. This error is returned if either a service provider’s DLL could not be loaded (LoadLibrary failed) or the provider’s WSPStartup or NSPStartup function failed.
Solution: open cmd as admin, type the following and hit Enter to repair winsock.
netsh winsock reset
MongoDB aggregation result exceeds maximum document size (16MB)
{
“errmsg” : “exception: aggregation result exceeds maximum document size (16MB)”,
“code” : 16389,
“ok” : 0
}
Cause:
Solution for 2.4: Limit the output using $skip and $limit to fit the 16MB limit
Solution for 2.6:
Java driver: Use option:
.newAggregationOptions().outputMode(
AggregationOptions.OutputMode.CURSOR).build()
PHP driver:
public MongoCommandCursor MongoCollection::aggregateCursor ( array
$command
[, array$options
] )
When stopping a docker with mongod daemon running using command:
docker stop
the next time you start the mongod docker, it will complain about unclean shutdown detected:
“Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery
instructions.”
Cause: “docker stop” use SIGTERM to kill mongod daemon, while it is recommended to use SIGINT
Solution:
docker kill -s INT