33
votes
Accepted
How to specify authentication database and target database separately on mongodb connection uri?
Yes.. Easily!
mongo "mongodb://test:testpwd@localhost/test?authSource=admin"
MongoDB shell version v3.4.6
connecting to: mongodb://test:testpwd@localhost/test?authSource=admin
MongoDB server version: ...
11
votes
Accepted
How to views all documents in a particular collection of database in MongoDB through mongo Shell?
OK, let's start from basics!
After you have connected to mongod with command mongo.
List databases with command show dbs
iot:PRIMARY> show dbs
admin 0.000GB
iot 0.020GB
local ...
9
votes
Accepted
mongorestore Too many open files
ulimit can be set in the same terminal by
ulimit -n 10000;
You can change the value in /etc/security/limit.conf file by
nofiles to 10000 #line
the maximum no of files can be opened in any linux/...
7
votes
Accepted
Multiple BindIp in MongoDB 3.4.1 on Debian Jessie
Remove []. so solution is: bindIp: 127.0.0.1,192.168.20.1 and remember, no space characters anywhere in that string.
6
votes
Accepted
Mongodb Secondary Node not recovering
Link in the error message exactly explain what happened.
A replica set member becomes “stale” when its replication process
falls so far behind that the primary overwrites oplog entries the
...
5
votes
How to views all documents in a particular collection of database in MongoDB through mongo Shell?
Ref:
https://docs.mongodb.com/manual/tutorial/query-documents/
Select All Documents in a Collection
To select all documents in the collection, pass an empty document as the query filter parameter ...
4
votes
How to specify authentication database and target database separately on mongodb connection uri?
Ref:
https://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options
You will need to use below format and do not need to use admin database.
mongodb://user:password@...
4
votes
MongoDB Maxing CPU Usage
Strange indeed.
That local.oplog.rs is journaling what is enable (default) at 64 bit systems (32bit default value is false). So, running time for that thread should be same than your mongod uptime.
...
4
votes
Accepted
Save output of a Mongo Command to a Variable bash script
Mongo -command have multiple parameters that are handy in this case.
'--eval' let you run commands and '--quiet' keep all clutter away
out=$(mongo --quiet --eval="db.currentOp()") ; echo $...
3
votes
Accepted
Why `distinct` and `count` operations generate `"op": "command"` in system.profile
Originally, all database operation in MongoDB are encoded in the Wire Protocol. However, this would mean that creating a new command would involve:
Creating a new opcode in the wire protocol, and
...
3
votes
Accepted
Is MongoDB IXSCAN operator a scan or a seek?
I guess MongoDB can do index seek and index scan ?
Yes MongoDB can do index seek and index scan, but it can do both during one fetch. That is what happened in your case. If started with a seek to ...
3
votes
Accepted
Service mongod fails after adding security.keyFile in config file
Use full path for keyfile. Don't use ~ -character there. Your mongod is started (probably) with user 'mongod' and that user don't have home directory.
Additionally keyfile must be have chmod 0400 and ...
3
votes
MongoDB secondary node does not become primary when other nodes are stopped
This is by design. If you want to run with only one node, restart that node without replica set switch.
If a majority of the replica set is inaccessible or unavailable to the
current primary, ...
3
votes
Replica Set not getting created
OK.. It's look like that you have managed to mix things. So, you have working mongodb at "C:\program files\mongodb\data" and now you want to convert that mongodb to three node replica set?!?
First ...
3
votes
Accepted
WiredTiger internal cache
Do we need to keep extra memory for some kind of memory mapped files for MongoDB data files
The mem.mapped and mem.mappedWithJournal metrics in serverStatus output are only applicable to the MMAPv1 ...
3
votes
What's the difference between DISTINCT_SCAN and IXSCAN in explain output?
They are different stages for different purposes. I believe DISTINCT_SCAN is only present when there is an index in the field. An IXSCAN stage basically means that the query planner scans an index as ...
2
votes
Accepted
Restoring the database dump of a newer version to an older version of mongodb
Assuming you aren't using any newer features or index/collection options from MongoDB 3.2+ that aren't supported in MongoDB 3.0, you should be able to restore the backup.
Before doing so, I would ...
2
votes
Accepted
How to set up a user who doesn't have `admin` database access but use it as authentication database?
Not need. You just give user needed rights to the wanted non-admin database. User can use admin database as authentication database even user doesn't have read/write access to admin database.
use ...
2
votes
Transferring Mongodb database with rsync while working, is it okay?
No, not directly! If your data is top of LVM, do a snapshot and copy that to another node, start it and connect it to the replica set. This only if you have lot's of data and normal initial sync (as @...
2
votes
Issue with MongoDB Replication Set
I fixed the issue by adding below lines in /etc/mongod.conf
replication:
replSetName: yogi
2
votes
Accepted
MongoDb linearizable read concern restrictions
Dmitry,
As of MongoDB v3.6, MongoDB only supports the linearizable read concern on single documents, hence the wording of the documentation. However, it doesn't mean you have to run the query using a ...
2
votes
mongo crashing due to too many open files
I have gone through your error and find out that in your case the Open file limit is 990000. Which is sufficient to open the mongos and mongod process. As per MongoDB BOL Here The default net....
2
votes
How to run mongod from the commandline?
Because nothing is written to log file, the first (and only) problem is (probably) ownership of log file. Usermongodb don't have access to that file. sudo chown -R mongodb: /var/log/mongodb should fix ...
2
votes
Accepted
Mongodb Standalone Performs better than Replica Set
I would like to know what could be the real reason for the replica sets to function slower compared to the standalone db.
Replica sets provide high availability and data redundancy, but these ...
2
votes
MongoDB multiple Cluster data sync
1)MongoDB - Multiple cluster data synchronizing master to master
As MongoDB jira documentation Why was MongoDB not designed to have master-master replication actually, don't think master-master ...
2
votes
MongoDB update multiple sub documents inside array, each according to a condition
Use the arrayFilters property:
db.getCollection("test").updateOne(
{
"wid": 1
},
{
$inc: {
"items.$[aa].sent": 37,
"items.$[bb].sent": 58,
...
2
votes
Accepted
Not authorized on admin to execute command mongoDB: Atlas M0 Free Tier cluster
Since you are using a hosted database service (MongoDB Atlas), many administrative commands are limited as they are either provided via the management interface or likely to introduce performance/...
1
vote
Is MongoDB IXSCAN operator a scan or a seek?
Of course when you do regex query (starting with star), we cannot directly do index scan, we need to read all index entries thru.
What comes to "seeks":1 it reports the number of times that we had to ...
1
vote
Accepted
MongoDB Write Concern when Journaling is off
Since you're using MongoDB 3.4.7 with WiredTiger, there are certain defaults in place if you run MongoDB with the default values (journal is enabled):
If newly created, the replica set would use ...
1
vote
MongoDB Write Concern when Journaling is off
The answer to your question: Writing data change to disk.
When journaling is on, the first change is written to the journal, then it is written to data blocks.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
mongodb-3.4 × 131mongodb × 118
sharding × 15
mongodb-3.2 × 15
mongodb-3.0 × 13
wiredtiger × 11
mongodb-3.6 × 8
replication × 7
permissions × 4
security × 3
master-slave-replication × 3
docker × 3
mongodb-4.0 × 3
performance × 2
configuration × 2
view × 2
aggregate × 2
ubuntu × 2
recovery × 2
python × 2
centos × 2
centos-7 × 2
mongodump × 2
update × 1
linux × 1