NoSQL MongoDB daily Operations Command collation

Source: Internet
Author: User
Tags rowcount

1. Db.serverstatus () See Shard Performance Information


Db.serverstatus (). connections; Shards view the number of client connections, Mongod and MONGOs connections are long connections


"Connections": {
"Current": 737,--the currently active connection amount. The current number of active connections to the server
"Available": 82--The amount of idle connections remaining. Number of available connections remaining
},

Db.serverstatus (). Mem View Shard Memory condition

"Mem": {
"Bits": 64,--64-bit machine
"Resident": 18363,--occupies the amount of physical memory.
"Virtual": 478810,--The amount of memory occupied
"Supported": true---whether to support extended memory
"Mapped": 233311,--data file size mapped to memory, very close to all of your database size.
"Mappedwithjournal": 466622,
"Note": "Virtual minus mapped is large. Could indicate a memory leak "
},

2, Mongod and MONGOs login method, note Management database to use MONGO client login management

/usr/local/bin/mongo Localhost:port

/usr/local/bin/mongo 10.20.25.48:10001

/usr/local/bin/mongo 10.20.25.48:27017/admin-uroot-p123456


3. View the average distribution of shards in a cluster

Sh.status ()

The results are as follows

Dbname.tablename

Shard key: {"_id": "Hashed"}

Chunks

S2 16

S1 13

S3 14

Too many chunks to print, use verbose if you want to force print

4. View Shard MONGO Performance

Mongostat-h 10.20.25.48--port 27017-uroot-p123456-n 100 20

Mongostat is a state detection tool that is mongdb, and is used under the command line. It will take a fixed time to get the current running state of MongoDB and output. If you find that the database is suddenly slow or has other problems, your first-hand action is to consider using Mongostat to see the status of Mongo.

Mongostat command format, of course, can also add parameters:

In the first example, Mongostat will return every second of the data for 20 seconds. Mongostat collects data on the Mongod instance running on the local host interface Port 27017. All of the following calls produce the same behavior:

Mongostat-RowCount 1

Mongostat-rowcount

Mongostat-n 20 1

Mongostat-n 20

In the following example, MONGOSTAT returns data every 5 minutes (300 seconds) as long as the program is running. Mongostat collects data on the Mongod instance running on the local host interface Port 27017. The following two types of calls produce the same behavior.

Mongostat- RowCount 0

Mongostat-n 0 300

Mongostat 300

In the following example, the data returned by Mongostat is one hours (12 times) every 5 minutes. Mongostat collects data on the Mongod instance running on the local host interface Port 27017. The following two types of calls produce the same behavior.

Mongostat-rowcount

Mongostat-n 12 300

In many cases, using-discover will help to provide a more complete snapshot of the state of the entire set of machines. If the MONGOs process is connected to port 27017 on a chip cluster running on the local machine, you can use the following form to return statistics from all members of the cluster:

Mongostat- Discover

Reference Document:http://cn.docs.mongodb.org/manual/reference/mongostat/

The main details of the column of the meaning (also can refer to./mongostat--help)

Insert: Number of inserts in one second

Query: Number of queries in one second

Update: Number of updates in one second

Delete: Number of deletions in one second

10 simple queries may be faster than a complex query, so the size of the values is not very significant.

But at least you can know if the query is currently being processed, whether it is inserted.

If it is slave, there is always a number before the value, which represents the replicate operation

Getmore: Getmore operation of cursor at query time

Not very useful

Www.2cto.com

Command: Number of commands executed in one second

For example, BULK INSERT, is only considered a command. It doesn't make much sense.

If it is slave, will show two values, local|replicated, through the comparison of these two values, may be able to see the point of the problem.

Flushes: Number of flush in one second

usually 0, or 1, by calculating the interval between two 1, you can get a general idea of how long it takes to flush once.

Flush overhead is great, and if you flush frequently, you may want to find out why.

Mapped

Vsize:

Res:

This and you use top to see the same, mapped, vsize generally do not have big changes, res will slowly rise, if res often suddenly drop, to check if there are other programs crazy eat memory.

Faults:

Don't be frightened by the name, this value is often not 0 under pressure. If it's often not 0, it's time to add memory.

Locked

MongoDB is a read-write lock, which refers to the percentage of time that a write lock lives. This value is too large (often more than 10%), that is the situation.

IDX Miss:

Very important parameter, under normal circumstances, all queries should be indexed, that is, idx miss is 0. If the value here is large, the index is missing.

Qr|qw:queue lengths for clients Waiting (Read|write)

Ar|aw:active Clients (Read|write)

If these two values are large, then the DB is blocked and the DB processing speed is less than the requested speed.

See if there is a lot of slow queries that are expensive. If the query is all right, it is really a heavy load, you need to add the machine.

Netin:network Traffic In-bits

Netout:network Traffic Out-bits

Network bandwidth pressure, General MongoDB, the network will not become a bottleneck

Conn:number of open connections

MongoDB creates a thread for each connection, and the creation and release of threads are also overhead. Try not to make this a large number.

REPL: Server Current state

M-master

Sec-secondary

Rec-recovering

Unk-unknown

Slv-slave

Time: Current

If you execute the mongostat command in a CMD window under Windows, it may be because the window is too narrow, the monitoring data arrangement is disorderly and hinder the visual situation, you can output the results to a TXT file, and then go to view this file, the way is twists and turns some haha.

E:\mongodb-win32-x86_64-2.2.1\bin\mongostat-n 2 > E:\test.txt

Prints 2 rows of results to the test.txt of the E-drive in the directory.



5. View MONGO TCP connection IP ordering

Netstat-ant|awk ' {print $} ' |awk-f: ' {print $} ' |sort |uniq-c|sort-rn


6. MONGO Simple Shard Backup

/home/mongodb/bin/mongodump-h192.168.0.15:50001-u username-p 123456--authenticationdatabase admin-d dbname-o/ home/data/dbbackup/


7. Db.status () View Shard cluster status


8. To be Continued

This article is from the "Beingawhole Memory Brick Hut" blog, reprint please contact the author!

NoSQL MongoDB daily Operations Command collation

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.