当前位置:网站首页>Mongodb initialization operation
Mongodb initialization operation
2022-07-28 18:22:00 【Water and moon are clear and bright】
Client login
/opt/cloud/mongodb/bin/mongo -host x.xx.x.x --port 8635 -u rwuser -p xxxx --authenticationsDatabase admin
Administrator account login
use admin
db.auth("dbadmin","xxx")
1, Create database
use pipeline
# view the database
show dbs
2, Create user
use pipeline
db.createUser( {user: "pipeline",pwd: "123456",roles: [{role: "userAdminAnyDatabase", db: "pipeline"}],passwordDigestor: "server"})
db.grantRolesToUser("pipeline",[{role: "dbOwner",db: "cache"}]);
3, Enable sharding for instances
use admin
db.runCommand({enableSharding; "pipeline"})
4, Create set , And fragment the set
use pipeline
db.createCollection("JobDetail")
sh.shardCollecton("pipeline.JobDetail", {"_id",1})
5, Check the fragmentation
db.getCollection("JobDetail").getShardDistribution();
6, Create index
db.JobDetail.createIndex({"pipeline_id": 1},{background:true,name:"idx_pipeline_id"});
7, Query specified time data
db.JobDetail.find({"createTime": ($gt:ISOdate("2021-08-17 00:00:00Z"),$lt:ISOdate("2021-08-17 00:00:00Z"))}).count();
8, The batch operation
db.JobDetail.find({"status": "pending"})
db.JobDetail.find({"status": "pending"}).forEach(
function(item){
db.JobDetail.update({"_id": item._id},{$set{"status":"completed"}})
}
)
边栏推荐
- 电源适配器 全球定义
- USB Type-C 详解
- Go的walk库报错
- 7-8 romantic profile (25 points) achievements + new problem solving ideas
- Yu Chengdong: Huawei is trying to cope with the US chip ban
- Seven steps, in-depth interpretation of data meaning
- The revenue of Shanghai silicon industry in the first half of the year was 850million yuan, an increase of 30.53% year on year! Various product certifications are accelerating
- 业绩增长强劲!闻泰科技上半年净利17亿元,同比暴增767.19%!
- 视频号运营有这个工具就够了
- 高温天气户外活动有讲究!市民盛夏健身安全指引来了
猜你喜欢

"Cloud strategy" will become an important pillar of enterprise digital transformation

7-8 romantic profile (25 points) achievements + new problem solving ideas

【译】创意编码之噪音

Tensorflow2.0 (XII) -- realize simple RNN and LSTM networks

The growth path of hardware engineers (0) -- Understanding components

Tensorflow2.0 (XI) -- understanding LSTM network

What role does low code play in the digital transformation?

个人制作:AD库、元件库、封装库及3D模型,免费

ADS仿真 之 直流仿真示例

Leetcode--45. jumping game II (greed)
随机推荐
Through private channels such as official account, direct the live broadcast of video number
Personal production: ad library, component library, packaging library and 3D model, free of charge
solidity转账函数的实现(基于transfer)
C WPF normal project suddenly prompts that the name "initializecomponent" does not exist in the current context
通过公众号等私域渠道,为视频号直播引流
Association between enterprise wechat and video Number
USB Type-C 之CC线简介
Tensorflow2.0 (XI) -- understanding LSTM network
MongoDB初始化操作
Go的walk库报错
Outdoor activities in hot weather are exquisite! Here comes the safety guide for citizens' fitness in midsummer
云容器与云原生
WordPress prompt error in establishing database connection
Sales of video related products increased by 88%
This tool is enough for video number operation
Busybox latest version (busybox APK)
Video Number Xiaobai starting operation guide
Digital filter (II) -- minimum phase delay system and all pass system
示波器简介
The revenue of Shanghai silicon industry in the first half of the year was 850million yuan, an increase of 30.53% year on year! Various product certifications are accelerating