I'm new to mongo and I have just set up a replicaset localy on my laptop.
I'm trying to import the demo database of restaurants from here :
https://raw.githubusercontent.com/mongodb/docs-assets/primer-dataset/dataset.json
and executed the mongoimport comand as this:
mongoimport -v --db test --collection restaurants --drop --file dataset.json
End the import just stops at 45%
2015-12-29T12:42:56.847-0500 filesize: 11880944 bytes
2015-12-29T12:42:56.847-0500 using fields:
2015-12-29T12:42:56.859-0500 connected to: localhost
2015-12-29T12:42:56.859-0500 ns: test.restaurants
2015-12-29T12:42:56.860-0500 connected to node type: replset
2015-12-29T12:42:56.860-0500 using write concern: w='majority', j=false, fsync=false, wtimeout=0
2015-12-29T12:42:56.861-0500 dropping: test.restaurants
2015-12-29T12:42:56.864-0500 using write concern: w='majority', j=false, fsync=false, wtimeout=0
2015-12-29T12:42:59.859-0500 [#########...............] test.restaurants 4.5 MB/11.3 MB (39.9%)
2015-12-29T12:43:02.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:05.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:08.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:11.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:14.849-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:17.849-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:20.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:23.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:26.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:29.849-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:32.849-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:35.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:38.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:41.849-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:44.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:47.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:50.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:53.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:56.850-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:43:59.849-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:44:02.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:44:05.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:44:08.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:44:11.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
2015-12-29T12:44:14.848-0500 [##########..............] test.restaurants 5.2 MB/11.3 MB (45.5%)
On the slave there is a database test created but if I try to do a find:
db.restaurants.find();
I get back :
Error: error: { "$err" : "not master and slaveOk=false", "code" : 13435 }
This is my replica config from master:
repl1:PRIMARY> rs.config()
{
"_id" : "repl1",
"version" : 7,
"members" : [
{
"_id" : 0,
"host" : "mongo1:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : 0,
"votes" : 1
},
{
"_id" : 1,
"host" : "mongo2:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : 0,
"votes" : 1
},
{
"_id" : 2,
"host" : "mongo3:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : 0,
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatTimeoutSecs" : 10,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
}
}
}
Looks like that the slaves do not recognize that they are part of replica set.
Where can i find some more info what is happening?
Best Answer
It's probably fine and just building indexes. Or you could be running out of some system resource, or it could just be slow. Tail the logs for that
mongod
process for more information. Check your disk for free space, and checktop
or whatever system monitoring tools you have to see what resources are being used while the import appears to be stopped at 45%.You can't query data on a secondary without first telling your driver or the mongo shell that it's okay to do so. Run
rs.slaveOk()
first and then you can run yourfind()
query.