sh.status() error processing query: ns=config.mongosTree - mongodb

if I run sh.status in mongos I get the error:
assert: command failed: {
"ok" : 0,
"errmsg" : "error processing query: ns=config.mongosTree: ping $gt new Date(1532712420740)\nSort: {}\nProj: {}\n No query solutions",
"code" : 2
} : aggregate failed
_getErrorWithCode#src/mongo/shell/utils.js:25:13
doassert#src/mongo/shell/assert.js:16:14
assert.commandWorked#src/mongo/shell/assert.js:290:5
DBCollection.prototype.aggregate#src/mongo/shell/collection.js:1312:5
printShardingStatus#src/mongo/shell/utils_sh.js:611:13
sh.status#src/mongo/shell/utils_sh.js:78:5
#(shell):1:1
2018-07-27T11:28:05.644-0600 E QUERY [thread1] Error: command failed: {
"ok" : 0,
"errmsg" : "error processing query: ns=config.mongosTree: ping $gt new Date(1532712420740)\nSort: {}\nProj: {}\n No query solutions",
"code" : 2
} : aggregate failed :
_getErrorWithCode#src/mongo/shell/utils.js:25:13
doassert#src/mongo/shell/assert.js:16:14
assert.commandWorked#src/mongo/shell/assert.js:290:5
DBCollection.prototype.aggregate#src/mongo/shell/collection.js:1312:5
printShardingStatus#src/mongo/shell/utils_sh.js:611:13
sh.status#src/mongo/shell/utils_sh.js:78:5
I reinstalled all mongo-enterprise packages but still the error persist, all the shards are working correctly, since I can perform find from mongos.
thanks

Related

this object is already an operator expression, and can't be used as a document expression

I am getting error while executing the following command in mongodb:
db.trans.aggregate(
[
{ $match: {"cno":89}},
{ $group: { _id: [ $dateToString: { format: "%Y-%m-%d", date: "$transactiondate" },types:"$type"], count: { $sum: 1 } } }])
I want to group by transaction date and type.
The error is:
assert: command failed: {
"ok" : 0,
"errmsg" : "this object is already an operator expression, and can't be used as a document expression (at 'types')",
"code" : 15990
} : aggregate failed_getErrorWithCode#src/mongo/shell/utils.js:25:13
doassert#src/mongo/shell/assert.js:16:14
assert.commandWorked#src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate#src/mongo/shell/collection.js:1319:5
#(shell):1:1
2017-10-24T15:38:35.498+0530 E QUERY [thread1] Error: command failed: {
"ok" : 0,
"errmsg" : "this object is already an operator expression, and can't be used as a document expression (at 'types')",
"code" : 15990
} : aggregate failed :
_getErrorWithCode#src/mongo/shell/utils.js:25:13
doassert#src/mongo/shell/assert.js:16:14
assert.commandWorked#src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate#src/mongo/shell/collection.js:1319:5
#(shell):1:1

Making a replica in MongoDB

I am trying to create a replica in mongodb. I have used the following commands to make a replica. I got the following outputs.
cfg = { _id : "mySet", members : [ { _id : 0, host : "localhost:27017"
} ] }
rs.initiate(cfg)
Output:
{
"ok" : 0,
"errmsg" : "Attempting to initiate a replica set with name mySet, but command line reports 0; rejecting",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig"
}
i get the following output:
017-09-22T14:22:22.093+0530 E QUERY [thread1] ReferenceError: conf is not defined :
#(shell):1:1
When i ran show dbs and rs.config(), i get the following errors:
show dbs
2017-09-22T14:23:56.234+0530 E QUERY [thread1] Error: listDatabases
failed:{
"ok" : 0,
"errmsg" : "not master and slaveOk=false",
"code" : 13435,
"codeName" : "NotMasterNoSlaveOk"
} :
_getErrorWithCode#src/mongo/shell/utils.js:25:13 .
Mongo.prototype.getDBs#src/mongo/shell/mongo.js:62:1
shellHelper.show#src/mongo/shell/utils.js:769:19
shellHelper#src/mongo/shell/utils.js:659:15 .
#(shellhelp2):1:1
> rs.config()
2017-09-22T14:24:23.718+0530 E QUERY [thread1] Error: Could not
retrieve replica set config: {
"info" : "run rs.initiate(...) if not yet done for the set",
"ok" : 0,
"errmsg" : "no replset config has been received",
"code" : 94,
"codeName" : "NotYetInitialized"
} :
rs.conf#src/mongo/shell/utils.js:1276:11
#(shell):1:1
delete all replication and oplog.
use local
db.dropDatabase()
restart the mongo
config = {_id: "repl1", members:[
{_id: 0, host: 'localhost:15000'},
{_id: 1, host: '192.168.2.100:15000'}]
}
rs.initiate(config);

mongodb returning error using $out with mongos

I have a mongodb cluster containing two shards, each a replication set of 3 nodes, and a config server cluster again with three nodes.
All seems to be in order apart from when I attempt to write a collection at the end of an aggregation pipeline using the $out operator:
db.getCollection('restaurants').aggregate([
{$match : {$text : {$search : "steak"}}},
{$out : "steak_restaurants"}
])
This is return the following error:
ailed to execute script.
Error: Assert: command failed: { "ok" : 0, "errmsg" : "listIndexes
failed: { ok: 0.0, errmsg: \"not master and slaveOk=false\", code:
13435, codeName: \"NotMasterNoSlaveOk\" }", "code" : 18631,
"codeName" : "Location18631" } : aggregate failed
_getErrorWithCode#src/mongo/shell/utils.js:25:13 doassert#src/mongo/shell/assert.js:16:14
assert.commandWorked#src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate#src/mongo/shell/collection.js:1319:5
#(shell):1:1
Error: command failed: { "ok" : 0, "errmsg" : "listIndexes failed: {
ok: 0.0, errmsg: \"not master and slaveOk=false\", code: 13435,
codeName: \"NotMasterNoSlaveOk\" }", "code" : 18631, "codeName" :
"Location18631" } : aggregate failed :
_getErrorWithCode#src/mongo/shell/utils.js:25:13 doassert#src/mongo/shell/assert.js:16:14
assert.commandWorked#src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate#src/mongo/shell/collection.js:1319:5
#(shell):1:1
The mongo shell is connected to a mongos router. If I execute the same against mongod, this works fine.
The error suggests that somehow reading is taking place from a secondary, however, I have not set any read preference and I would have thought that mongos would resolve the primary correctly by itself. Any ideas or insight please?
Appears to only be occurring when executed through Robo 3T. Executing through a raw shell works fine.
I had the same problem today and solved it by removing the "getCollection".
Can you try running:
db.restaurants.aggregate([
{$match : {$text : {$search : "steak"}}},
{$out : "steak_restaurants"}
])

In slave mongoDB, when I run "show dbs" command I am getting this error

In slave mongoDB, when I run "show dbs" command I am getting this error:
E QUERY [thread1] Error: listDatabases failed:{
"ok" : 0,
"errmsg" : "unable to open cursor at URI statistics:table:collection-2-6982414143487404550. reason: No such file or directory",
"code" : 43,
"codeName" : "CursorNotFound"
} :

mongoDB aggregation with error msg

I am trying to search for the word "credit" in my colloection suing the aggregation framework but I having an error. could anyone help figure out what the issue might be.
db.complaints.createIndex({issue:1})
db.complaints.aggregate([
{$match:{$text:{$search:"credit"}}},
{$project:{issue:1,_id:0}}
])
I am having this error:
assert: command failed: {
"errmsg" : "exception: error processing query: ns=customers.complaints l
imit=0 skip=0\nTree: TEXT : query=credit, language=, tag=NULL\nSort: {}\nProj: {
$textScore: { $meta: \"textScore\" }, issue: 1, _id: 0 }\n planner returned err
or: need exactly one text index for $text query",
"code" : 2,
"ok" : 0
} : aggregate failed
Error: command failed: {
"errmsg" : "exception: error processing query: ns=customers.complaints l
imit=0 skip=0\nTree: TEXT : query=credit, language=, tag=NULL\nSort: {}\nProj: {
$textScore: { $meta: \"textScore\" }, issue: 1, _id: 0 }\n planner returned err
or: need exactly one text index for $text query",
"code" : 2,
"ok" : 0
} : aggregate failed
at Error (<anonymous>)
at doassert (src/mongo/shell/assert.js:11:14)
at Function.assert.commandWorked (src/mongo/shell/assert.js:254:5)
at DBCollection.aggregate (src/mongo/shell/collection.js:1278:12)
at (shell):1:15
2015-09-01T17:10:45.512+0100 E QUERY Error: command failed: {
"errmsg" : "exception: error processing query: ns=customers.complaints l
imit=0 skip=0\nTree: TEXT : query=credit, language=, tag=NULL\nSort: {}\nProj: {
$textScore: { $meta: \"textScore\" }, issue: 1, _id: 0 }\n planner returned err
or: need exactly one text index for $text query",
"code" : 2,
"ok" : 0
} : aggregate failed
at Error (<anonymous>)
at doassert (src/mongo/shell/assert.js:11:14)
at Function.assert.commandWorked (src/mongo/shell/assert.js:254:5)
at DBCollection.aggregate (src/mongo/shell/collection.js:1278:12)
at (shell):1:15 at src/mongo/shell/assert.js:13
If you take a look at your error message then you will see the following message: need exactly one text index for $text query.
Your post shows that you did create an index on issue. However, it appears that you do not have a Text Index declared for your collection.
If you want the issue document field to be text searchable then create a text index as follows:
db.complaints.createIndex({issue:"text"})
(Note, you may only have one text index per collection. However, the fields included in the text index are established upon index creation. Again, see the abovementioned Text Index link.)
This query will work:
db.things.aggregate([{$match:{issue:"credit"}},{$project:{issue:1,_id:0}}])