MongoDB starting Mode
MongoDB supports the configuration file startup in addition to supporting the command-line startup method to start the database by reading the startup configuration file.
You can use the following command
1./mongod-f/etc/mongodb.conf
MongoDB parameter Description
DBPath:
Data file storage path each database creates a subdirectory in it to prevent the same instance from being shipped multiple times
The mongod.lock of the row is also saved in this directory.
LogPath
Error log file
Logappend
Error log append mode defaults to overwrite mode
Bind_ip
The binding IP for external services is generally set to null and is bound to all available IP on this computer if necessary can be isolated
Specified
Port
External service port. Web management port based on this port +1000
Fork
Run service in daemon form
Journal
Turn on log function to reduce the recovery time of single machine failure by saving the operation log to be formally joined after version 1.8
Replace the Dur parameter in version 1.7.5.
Syncdelay
The time unit for the system to refresh the disk in seconds is 60 seconds by default.
Directoryperdb
It is recommended that you set this parameter in a separate directory for each db. Similar to MySQL's standalone table space
Maxconns
Maximum number of connections
Repairpath
The temporary directory when the repair is executed. The reboot must be performed if the journal exception down machine is not turned on repair
Operation。
Stopping a database Here's one thing to be aware of.
Use Kill-2 or pkill, but do not use kill-9 to kill mongodb processes that can cause MONGODB data corruption.
Ii. Common Tool Sets
MongoDB provides a series of useful tools in the bin directory that provide MongoDB in operational management
Convenience.
Bsondump: Dump files in Bson format to JSON-formatted data
MONGO: The client command line tool is actually a JS interpreter that supports JS syntax
Mongod: Each instance of the database server starts a process that can be run fork for the background
Mongodump/mongorestore: Database backup and recovery tools
Mongoexport/mongoimport: Data export and import tools
Mongofiles:gridfs management tool enables two file access
MONGOs: Fragmented routing If the sharding feature is used, the application connects MONGOs instead of
Mongod
Mongosniff: This tool works like tcpdump, but he only monitors MongoDB-related packages.
and is output in the specified readability form
Mongostat: Real-time performance monitoring tools
Three, some very important magic methods
1, $all match all
This operator is similar to the SQL syntax in, but the difference is that in simply satisfies a value within (), and $all must
All values within [] must be met for example:
Db.users.find ({age:{$all: [6,8]}});
Can query out {name: ' David ', age:26,age:[6,8,9]}
But the query does not show {name: ' David ', age:26,age:[6,7,9]}
2, $mod modulo operation
Query age modulo 10 equals 0 data
Db.student.find ({age:{$mod: [10,1]}})
Examples are as follows:
The data for the C1 table are as follows:
1234> Db.c1.find () {"_id": ObjectId ("4fb4af85afa87dc1bed94330"), "age": 7, "length_1"