View the status of the Replica Set in MongoDB

Source: Internet
Author: User

Check the status of the Replica Set and execute rs. status ().

Rs. status ()
{
"Set": "set1 ",
"Date": "Thu Oct 28 2010 10:09:28 GMT + 0800 (CST )",
"MyState": 2,
"Members ":[
{
"_ Id": 0,
"Name": "192.168.95.216: 10000 ",
"Health": 1,
"State": 1,
"Uptime": 2486042,
"LastHeartbeat": "Thu Oct 28 2010 10:09:26 GMT + 0800 (CST )"
},
{
"_ Id": 1,
"Name": "zjm-Hadoop-slave217: 10000 ",
"Health": 1,
"State": 2,
"Self": true
},
{
"_ Id": 2,
"Name": "192.168.95.218: 10001 ",
"Health": 1,
"State": 7,
"Uptime": 2486042,
"LastHeartbeat": "Thu Oct 28 2010 10:09:27 GMT + 0800 (CST )"
}
],
"OK": 1
}

Health 1 indicates that the server is normal, and 0 indicates that the server is down.

If the state is 1, it indicates Primary, 2 indicates Secondary, 3 indicates Recovering, 7 indicates Arbiter, and 8 indicates Down.

To find data on Secondary, run the following command:

Db. getMongo (). setSlaveOk ();
Db. suv. find (). count ()

To view information about a Collection, you can use db. suv. stats ()

{
"Ns": "suv. suv ",
"Count": 9519581,
"Size": 573341552,
"AvgObjSize": 60.2276037149114,
"StorageSize": 736285696,
"NumExtents": 21,
"Nindexes": 3,
"LastExtentSize": 129238272,
"PaddingFactor": 1,
"Flags": 1,
"TotalIndexSize": 1612344128,
"IndexSizes ":{
"_ Id _": 462365632,
"Lt_1": 790758336,
"Cl. Cid_1": 359220160
},
"OK": 1
}

Where:

  1. The size is DataSize, which is the space occupied by data.
  2. StorageSize is the primary des free space allocated to this collection, that is, it includes allocated but idle space.
  3. TotalIndexSize indicates the space occupied by all indexes.
  4. TotalSize is the total space occupied by the Collection, which is equal to storageSize + totalIndexSize

You can use the following command to query the preceding information:

Db. suv. dataSize ()
Db. suv. storageSize ()
Db. suv. totalIndexSize ()
Db. suv. totalSize ()

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.