MongoDB Combat: Tool sets and special magic methods

Source: Internet
Author: User
Keywords nbsp Magic Method
Tags command line configuration data directory etc example file find

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"
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.