mongodb常用命令

db.adminCommand(“flushRouterConfig”)
db.adminCommand( { flushRouterConfig: 1 } )
MyMongo:PRIMARY> rs.add( { host: “10.15.7.114:28005”, arbiterOnly: true } )
db.Dynamic_human.aggregate([{“KaTeX parse error: Expected '}', got 'EOF' at end of input: …ect":{"date":{"dateToString”:{“date”:“ s n a p t i m e " , " f o r m a t " : " snap_time","format":"%Y-%m-%d"}}}},{" snaptime","format":"group”:{"_id":null,“count”:{“KaTeX parse error: Expected 'EOF', got '}' at position 7: sum":1}̲}}]) db.static_…project”:{“num”:{“KaTeX parse error: Expected '}', got 'EOF' at end of input: cond":{if:{"isArray”:“KaTeX parse error: Expected 'EOF', got '}' at position 13: cover_human"}̲,then:{"size”:“KaTeX parse error: Expected 'EOF', got '}' at position 13: cover_human"}̲,else:"NA"}}}},…match”:{“num”:{“KaTeX parse error: Expected 'EOF', got '}' at position 6: gt":1}̲}}]) db.adminCo…nin”:[disresult]}});
var times = (new Date()).getTime() - start;
print(“static find took” + times+ “ms”);
}
db.serverStatus().wiredTiger.concurrentTransactions
db.Dynamic_human.aggregate([
{“KaTeX parse error: Expected 'EOF', got '}' at position 14: match":{....}}̲, {"project”:{“date”:{“KaTeX parse error: Expected '}', got 'EOF' at end of input: …ring":{"date":"snap_time”,“format”:"%Y-%m-%d %H"}},“human_id”:1,“age_range”:1}},
{“KaTeX parse error: Expected '}', got 'EOF' at end of input: …"_id":{"date":"date”,“key”:“KaTeX parse error: Expected 'EOF', got '}' at position 11: age_range"}̲,"humanid":{"addToSet”:“KaTeX parse error: Expected 'EOF', got '}' at position 10: human_id"}̲}}, {"unwind”:“KaTeX parse error: Expected 'EOF', got '}' at position 9: humanid"}̲, {"group”:{"_id":{“date”:" i d . d a t e " , " k e y " : " _id.date","key":" id.date","key":"_id.key"},“count”:{“KaTeX parse error: Expected 'EOF', got '}' at position 7: sum":1}̲}}, {"group”:{"_id":“KaTeX parse error: Expected '}', got 'EOF' at end of input: …te","result":{"push”:{“key”:“ i d . k e y " , " c o u n t " : " _id.key","count":" id.key","count":"count”}}}}
])
db.Dynamic_human.aggregate([
{“KaTeX parse error: Expected 'EOF', got '}' at position 14: match":{....}}̲, {"group”:{"_id":{“yaer”:{“ y e a r " : " year":" year":"snap_time”},“month”:{“ m o n t h " : " month":" month":"snap_time”}},“day”:{“ d a y O f M o n t h " : " dayOfMonth":" dayOfMonth":"snap_time}},“count”:{“KaTeX parse error: Expected 'EOF', got '}' at position 7: sum":1}̲}} ]) db.Dyna…project”:{“date”:{“KaTeX parse error: Expected '}', got 'EOF' at end of input: …ring":{"date":"snap_time”,“format”:”%Y-%m-%d %H"}},“human_id”:1}},
{“KaTeX parse error: Expected '}', got 'EOF' at end of input: …"_id":{"date":"date”},“humanid”:{“ a d d T o S e t " : " addToSet":" addToSet":"human_id”}}},
{“ u n w i n d " : " unwind":" unwind":"humanid”},
{"KaTeX parse error: Expected '}', got 'EOF' at end of input: …"_id":{"date":"_id.date"},“count”:{"$sum":1}}}
])
db.currentOp(
{
KaTeX parse error: Expected '}', got 'EOF' at end of input: … { "op" : { "in" : [ “remove” ] } }
]
}
)
db.setProfilingLevel(1,1000)
./bin/mongostat --host 10.15.117.94 --port 27018 -u admin -p hik12345 --authenticationDatabase admin
db.serverStatus().wiredTiger.cache
db.serverStatus().mem
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
function vehiclefindtest(n){
var start = (new Date()).getTime();
print(start);
for(var i = 0; i < n; i++){
var begintime = Math.floor(1546272000000 - i22222222 + Math.random()%3888000000);
var endtime = Math.floor(1554048000000 + i
11111111 - Math.random()%3888000000);
db.vehicle_coll.find({“snap_time”:{“ g t e " : n e w D a t e ( b e g i n t i m e ) , " gte":new Date(begintime)," gte":newDate(begintime),"lte”:new Date(endtime)}}).limit(100).sort({“snap_time”:-1});
}
var end = (new Date()).getTime();
print(end);
var times = end - start;
print(“times:” + times + “ms”);
}
db.adminCommand( { setParameter: 1, logLevel: 2 } )
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 })
db.runCommand({splitVector:“face.Dynamic_human”,keyPattern:{"_id":1},min:{"_id":ObjectId(“5da8636d15106ecae650e283”)},max:{"_id" : ObjectId(“5da8cb7815106ecae63ca480”)},maxChunkSize:200 })
{
“help”: “help for: splitVector Internal command.\n
examples:\n { splitVector : “blog.post” , keyPattern:{x:1} , min:{x:10} , max:{x:20}, maxChunkSize:200 }\n maxChunkSize unit in MBs\n May optionally specify ‘maxSplitPoints’ and ‘maxChunkObjects’ to avoid traversing the whole chunk\n \n { splitVector : “blog.post” , keyPattern:{x:1} , min:{x:10} , max:{x:20}, force: true }\n ‘force’ will produce one split point even if data is small; defaults to false\nNOTE: This command may take a while to run”,
“ok”: 1
}
db.getSiblingDB(“zoo”).salaries.aggregate( [
{ $match : { fiscal_year: { $gte : 2019 } } },
{ KaTeX parse error: Expected '}', got 'EOF' at end of input: … fiscal_year: "fiscal_year", dept: “$dept” }, salaries: { s u m : " sum: " sum:"salary" } } },
{ $merge : { into: { db: “reporting”, coll: “budgets” }, on: “_id”, whenMatched: “replace”, whenNotMatched: “insert” } }
] )
mongos> var cursor = db.aggregate([{ $currentOp : { allUsers: true } }, { KaTeX parse error: Expected 'EOF', got '}' at position 25: …"op":"remove"} }̲,{"project":{“opid”:1}}] );
mongos> var batchData = cursor.toArray();
mongos> batchData.forEach(function(myDoc){db.killOp(myDoc.opid);});
./bin/mongoexport -u admin -p a74d0d9faca5487c8847d8ae7f320336 -h 10.66.107.171 --port 30000 --authenticationDatabase admin -d face -c vehicle_alarm --type=csv --query=’{“plate_name”: “xxx”}’ --skip=10 --limit=20 --sort=’{_id: 1}’ --fields=_id,plate_name -o test.csv

db.serverStatus().metrics.repl.buffer.sizeBytes�����ӽ�db.serverStatus().metrics.repl.buffer.maxSizeBytes: ��Secondaryͬ���ͺ�����Ϊ���ϲ���д��̫�ߵ��£���ͨ������Secondary��replWriter�����߳�����������

openssl rand -base64 666 > mongodb.key
chmod 600 mongodb.key
db.createUser({user:“admin”,pwd:“hik12345”,roles:[{“role”:“root”,“db”:“admin”},{“role”:“readWriteAnyDatabase”,“db”:“admin”}]})
./bin/mongostat --host 10.15.117.165 --port 30001 -u admin -p hik12345 --authenticationDatabase admin 60

mongoDB�洢����
??? ˵��mongoDB��metadata��Ϣ���Ƚ���һ��mongoDB�Ĵ洢���mongoDB3.2.4֧��һ��5�֣�

?? WiredTiger��Ĭ�ϣ�
?? MMAPv1
?? InMomery
?? Encrypted
?? 3rd Party Engine
metadata��Ϣ
??? ���ļ���������˵��mongoDB��Ԫ���ݰ�����

?? Collection namespace
?? Index namespace
?? f r e e l i s t ? ? ? ? ? ? 1 � � 2 � � � � ֪ � ⣬ � ص � ˵ һ � � freelist ?????? 1��2����֪�⣬�ص�˵һ�� freelist??????12֪ص˵һfreelist������洢���DZ�ɾ����collection��index����Ϣ��

??? �ӹ�����˵��mongoDB��Ԫ���ݰ�����

??? 1.??? shard key��chunk range key��ӳ���ϵ

??? 2.??? chunk������key��ӳ���ϵ��

??? ��Щ��Ϣ�洢��config server�С�һ���û������������router server(mongos)�õ�metadata�󣬽��н�������ʼѰַ���ֵ�Ŀ�����ݵ�ӳ���ַ�����վͿ��Զ����ݽ�����ɾ�IJ��ˡ�

mongoDB�洢����
??? ˵��mongoDB��metadata��Ϣ���Ƚ���һ��mongoDB�Ĵ洢���mongoDB3.2.4֧��һ��5�֣�

?? WiredTiger��Ĭ�ϣ�
?? MMAPv1
?? InMomery
?? Encrypted
?? 3rd Party Engine
metadata��Ϣ
??? ���ļ���������˵��mongoDB��Ԫ���ݰ�����

?? Collection namespace
?? Index namespace
?? f r e e l i s t ? ? ? ? ? ? 1 � � 2 � � � � ֪ � ⣬ � ص � ˵ һ � � freelist ?????? 1��2����֪�⣬�ص�˵һ�� freelist??????12֪ص˵һfreelist������洢���DZ�ɾ����collection��index����Ϣ��

??? �ӹ�����˵��mongoDB��Ԫ���ݰ�����

??? 1.??? shard key��chunk range key��ӳ���ϵ

??? 2.??? chunk������key��ӳ���ϵ��

??? ��Щ��Ϣ�洢��config server�С�һ���û������������router server(mongos)�õ�metadata�󣬽��н�������ʼѰַ���ֵ�Ŀ�����ݵ�ӳ���ַ�����վͿ��Զ����ݽ�����ɾ�IJ���

MongoDBԪ���ݵĴ洢����
Ԫ������һ��Ԥ���ռ䣬�ڶ����ݿ��Ӧ�ó���ṹִ���޸�ʱ�������ݿ��������ݿ��Զ����¡�Ԫ������ϵͳ�и������������ļ��ϣ���ִ����ϸ�������ռ������ݷ�������Ҫ;����
Ԫ��������Ҫ����������Ϊ�����׶εĹ��ߡ��κ��ֵ�����Ҫ����;���Dz�ѯ���ڽṹ�������У�Ԫ���ݵ������Ǹ�������ͼ�ϵ�ÿ���ڵ���Զ����˵�������仰˵��������ͼ�ϵ����нڵ�Ķ���ͽ��͵ļ��Ͼ���Ԫ���ݣ�������Ԫ�����н�������һ�µĶ���������������������Ա���û���ͨ��Ч�ʡ�

MongoDB���������ݿ�һ������ר�Ŵ洢Ԫ���ݵ�ϵͳ����system.*namespaces��һ������Ķ������д洢���ݿ��ϵͳ��Ϣ��ͨ����Щ���û����Դ���˽����ݿ�ϵͳ�����ݿ����
�����������:
system.namespaces �洢�����ռ���Ϣ
system.indexes �洢������Ϣ
system.profile �洢�Ż�����Ϣ
system.users �洢�û���Ϣ
system.sources �洢���Ƽ���������Ϣ��״̬��Ϣ
�����������ռ��������Ϣ���洢��database.ns�ļ��У����Ҷ��û��Ƿ�װ��

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值