• #查看mongodb状态:mongostat –port 27001
[root@xynev-p-mongodb1 conf]# mongostat --port 27001
insert query update delete getmore command dirty used flushes vsize res qrw arw net_in net_out conn set repl time
*0 *0 *0 *0 0 3|0 0.1% 2.3% 0 1.60G 206M 0|0 1|0 425b 70.7k 23 shard1 PRI Apr 1 13:32:35.085
  • 列出数据库
> show databases
local   0.011GB
nev     0.000GB
test    0.064GB
testdb  0.249GB
  •  选择数据库
> use nev
switched to db nev
  •  列出表 show tables //或者 show collections
> show tables
gps_record
original_message
system.profile
> 
> show collections
gps_record
original_message
system.profile
>   
  • 查看数据信息
> db.stats()
{
	"db" : "nev",                   //数据库名
	"collections" : 3,              //表数
	"objects" : 1761,               //所有表有多少条数据
	"avgObjSize" : 1342.0618966496309,  //每条数据的平均大小
	"dataSize" : 2363371,               //所有数据的总大小
	"storageSize" : 413696,             //所有数据占用磁盘大小
	"numExtents" : 0,                   //事件数
	"indexes" : 2,                      //索引数
	"indexSize" : 77824,                //索引大小
	"ok" : 1
} 
  • 查看original_message表信息
> db.original_message.stats()
{
	"ns" : "nev.original_message",  //当前表
	"count" : 1742,                 //多少数据
	"size" : 1919684,               //表大小
	"avgObjSize" : 1102,            //每条数据平均大小
	"storageSize" : 319488,         //数据占用磁盘大小
	"capped" : false,               //固定集合
	"nindexes" : 1,                 //索引
	"totalIndexSize" : 61440,       //索引大小
	"indexSizes" : {
		"_id_" : 61440
	},
	"ok" : 1
}
> 
  •  查看集群信息
configs:PRIMARY> sh.status()
--- Sharding Status --- 
  sharding version: {
  	"_id" : 1,
  	"minCompatibleVersion" : 5,
  	"currentVersion" : 6,
  	"clusterId" : ObjectId("5e1bd2eb8383bdfa0968ad23")
  }
  shards:
        {  "_id" : "shard1",  "host" : "shard1/mongodb-node1:27001,mongodb-node2:27001",  "state" : 1 }
        {  "_id" : "shard2",  "host" : "shard2/mongodb-node2:27002,mongodb-node3:27002",  "state" : 1 }
        {  "_id" : "shard3",  "host" : "shard3/mongodb-node1:27003,mongodb-node3:27003",  "state" : 1 }
  most recently active mongoses:
        "4.0.13" : 2
  autosplit:
        Currently enabled: yes
  balancer:
        Currently enabled:  yes
        Currently running:  unknown
        Failed balancer rounds in last 5 attempts:  0
        Migration Results for the last 24 hours: 
                No recent migrations
  databases:
       ... ...

configs:PRIMARY> 
  • 查看分片信息rs.status()
  •  查看平衡器状态sh.getBalancerState()
  • 查看平衡器是否运行sh.isBalancerRunning()
  • 查看表数据大小db.original_message.dataSize()
  • 查看表索引大小db.original_message.totalIndexSize()

  

  

 

版权声明:本文为caonw原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/caonw/p/12618167.html