惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
IT之家
IT之家
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
L
LangChain Blog
博客园 - Franky
美团技术团队
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
小众软件
小众软件
Y
Y Combinator Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News

又见苍岚

COLMAP PatchMatch Stereo 算法详解 事件驱动的状态机框架:从理论到工程实践 Git 在国内网络环境下无法 Push 的排查与修复 —— 配置 Clash 代理 分段五次多项式插值原理详解 路径插值方法深度对比研究 Claude Code 使用指南 OpenClaw 记忆管理与技能创建指南 CBS(Conflict-Based Search)算法详解 A* 算法及其变种详解 OpenClaw 配置多 Agents Windows Powershell 无法加载文件,因为在此系统上禁止运行脚本问题的解决方案 MaxClaw 安装流程 大模型 AI 名词介绍 AList 网盘聚合工具简介 Protobuf 简介与测试 Claude Code 简介以及 GLM 4.7 模型接入 Github 歌词下载工具 163MusicLyrics Python __getattr__ 懒加载 Python TypedDict 机器人仿真平台 Gazebo 安装记录 机器人仿真平台 Gazebo 简介 多机器人路径规划问题(Multi-Agent Path Finding, MAPF)简介 Python exifread 读取修改过的 jpeg 信息错误问题修复 3D 坐标系变换的理解 3D 旋转矩阵基本概念 MongoDB Compass 介绍 Python 环境管理工具 uv Flutter 开发指南 Snipaste 安装下载与黑屏问题解决方案 全局路径规划算法记录
MongoDB 分片实战 GridFS
Yiwei Zhang · 2024-10-22 · via 又见苍岚

1. --shardsvr

2. --directoryperdb

3. --replSet shard1

4. --wiredTigerCacheSizeGB 2

5. --auth

回到刚刚的 mongosh,这时在 vvd 数据库中查看 collections 可以看到 fs.chunksfs.files集合,表明 GridFS 数据添加成功:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
[direct: mongos] vvd> sh.status()
shardingVersion
{ _id: 1, clusterId: ObjectId('67177b0f7478e63cb9a618a5') }
---
shards
[
{
_id: 'shard1',
host: 'shard1/shard1:27018',
state: 1,
topologyTime: Timestamp({ t: 1729592126, i: 2 })
},
{
_id: 'shard2',
host: 'shard2/shard2:27018',
state: 1,
topologyTime: Timestamp({ t: 1729593951, i: 2 })
},
{
_id: 'shard3',
host: 'shard3/shard3:27018',
state: 1,
topologyTime: Timestamp({ t: 1729593958, i: 2 })
}
]
---
active mongoses
[ { '7.0.12': 1 } ]
---
autosplit
{ 'Currently enabled': 'yes' }
---
balancer
{
'Currently enabled': 'yes',
'Failed balancer rounds in last 5 attempts': 0,
'Currently running': 'no',
'Migration Results for the last 24 hours': 'No recent migrations'
}
---
databases
[
{
{
database: {
_id: 'vvd',
primary: 'shard3',
partitioned: false,
version: {
uuid: UUID('5ffbe210-fe2a-4b96-8b98-f568eab7fbec'),
timestamp: Timestamp({ t: 1729594145, i: 1 }),
lastMod: 1
}
},
collections: {
'vvd.fs.chunks': {
shardKey: { files_id: 'hashed', n: 1 },
unique: false,
balancing: true,
chunkMetadata: [
{ shard: 'shard1', nChunks: 2 },
{ shard: 'shard2', nChunks: 2 },
{ shard: 'shard3', nChunks: 2 }
],
chunks: [
{ min: { files_id: MinKey(), n: MinKey() }, max: { files_id: Long('-6148914691236517204'), n: MinKey() }, 'on shard': 'shard3', 'last modified': Timestamp({ t: 1, i: 0 }) },
{ min: { files_id: Long('-6148914691236517204'), n: MinKey() }, max: { files_id: Long('-3074457345618258602'), n: MinKey() }, 'on shard': 'shard3', 'last modified': Timestamp({ t: 1, i: 1 }) },
{ min: { files_id: Long('-3074457345618258602'), n: MinKey() }, max: { files_id: Long('0'), n: MinKey() }, 'on shard': 'shard1', 'last modified': Timestamp({ t: 1, i: 2 }) },
{ min: { files_id: Long('0'), n: MinKey() }, max: { files_id: Long('3074457345618258602'), n: MinKey() }, 'on shard': 'shard1', 'last modified': Timestamp({ t: 1, i: 3 }) },
{ min: { files_id: Long('3074457345618258602'), n: MinKey() }, max: { files_id: Long('6148914691236517204'), n: MinKey() }, 'on shard': 'shard2', 'last modified': Timestamp({ t: 1, i: 4 }) },
{ min: { files_id: Long('6148914691236517204'), n: MinKey() }, max: { files_id: MaxKey(), n: MaxKey() }, 'on shard': 'shard2', 'last modified': Timestamp({ t: 1, i: 5 }) }
],
tags: []
}
}
}
]
1
2
3
4
5
6
7
8
use admin
db.createUser(
{
user:"root",
pwd:"passwd",
roles:["root"]
}
)
1
2
3
4
5
6
7
8
9
10
11
12
13
db.createUser({
user:"manager",
pwd:"passwd",
customData:{
name:'vvd',
email:'zywvvd@mail.ustc.edu.cn',
age:33,
},
roles:[
{role:"readWrite",db:"test_db"},
'read'// 对其他数据库有只读权限,对 test_db 是读写权限
]
})
1
2
3
4
5
6
7
8
9
10
11
12
db.createUser({
user:"filereader",
pwd:"passwd",
customData:{
name:'reader',
email:'reader@test.cn',
age:18,
},
roles:[
{role:"read",db:"test_db"}
]
})