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:
- The size is DataSize, which is the space occupied by data.
- StorageSize is the primary des free space allocated to this collection, that is, it includes allocated but idle space.
- TotalIndexSize indicates the space occupied by all indexes.
- 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 ()