mongodb shard
发表于:2025-01-20 作者:千家信息网编辑
千家信息网最后更新 2025年01月20日,serverA:172.16.200.200/data/mongodb/db/{shard1_200,shard2_200,shard3_200,config}/data1/logs/mongodb/
千家信息网最后更新 2025年01月20日mongodb shardserverA:172.16.200.200
/data/mongodb/db/{shard1_200,shard2_200,shard3_200,config}
/data1/logs/mongodb/
serverB:172.16.200.201
/data/mongodb/db/{shard1_201,shard2_201,shard3_201,config}
/data1/logs/mongodb/
serverC:172.16.200.202
/data/mongodb/db/{shard1_202,shard2_202,shard3_202,config}
/data1/logs/mongodb/
serverA:./mongod --shardsvr --replSet shard1 --port 29001 --dbpath=/data/mongodb/db/shard1_200/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard1_200.log --logappend --fork --nohttpinterface -directoryperdb
serverB:
./mongod --shardsvr --replSet shard1 --port 29001 --dbpath=/data/mongodb/db/shard1_201/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard1_201.log --logappend --fork --nohttpinterface --directoryperdbserverC:
./mongod --shardsvr --replSet shard1 --port 29001 --dbpath=/data/mongodb/db/shard1_202/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard1_202.log --logappend --fork --nohttpinterface -directoryperdb
登陆mongo./mongo --port 29001> config = {_id: 'shard1', members: [
... {_id: 0, host: '172.16.200.200:29001',priority:1},
... {_id: 1, host: '172.16.200.201:29001',priority:0},
... {_id: 2, host: '172.16.200.202:29001',arbiterOnly:true}]};
{
"_id" : "shard1",
"members" : [
{
"_id" : 0,
"host" : "172.16.200.200:29001",
"priority" : 1
},
{
"_id" : 1,
"host" : "172.16.200.201:29001",
"priority" : 0
},
{
"_id" : 2,
"host" : "172.16.200.202:29001",
"arbiterOnly" : true
}
]
}
> rs.initiate(config);
{
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}
>
shard1:SECONDARY>
shard1:SECONDARY> serverA:./mongod --shardsvr --replSet shard2 --port 29002 --dbpath=/data/mongodb/db/shard2_200/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard2_201.log --logappend --fork --nohttpinterface --directoryperdbserverB:
./mongod --shardsvr --replSet shard2 --port 29002 --dbpath=/data/mongodb/db/shard2_201/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard2_201.log --logappend --fork --nohttpinterface --directoryperdbserverC:./mongod --shardsvr --replSet shard2 --port 29002 --dbpath=/data/mongodb/db/shard2_202 --oplogSize 10240 --logpath=/data1/logs/mongodb/shard2_202.log --logappend --fork --nohttpinterface --directoryperdb登录mong./mongo --port 29002[root@serverA bin]# ./mongo --port 29002
MongoDB shell version: 2.6.0
connecting to: 127.0.0.1:29002/test
> config = {_id: 'shard2', members: [
... {_id: 0, host: '172.16.200.200:29002',priority:1},
... {_id: 1, host: '172.16.200.201:29002',priority:0},
... {_id: 2, host: '172.16.200.202:29002',arbiterOnly:true}]};
{
"_id" : "shard2",
"members" : [
{
"_id" : 0,
"host" : "172.16.200.200:29002",
"priority" : 1
},
{
"_id" : 1,
"host" : "172.16.200.201:29002",
"priority" : 0
},
{
"_id" : 2,
"host" : "172.16.200.202:29002",
"arbiterOnly" : true
}
]
}
> rs.initiate(config);
{
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}
>
shard2:SECONDARY>shard2:PRIMARY> serverA:./mongod --shardsvr --replSet shard3 --port 29003 --dbpath=/data/mongodb/db/shard3_200/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard3_200.log --logappend --fork --nohttpinterface --directoryperdb
serverB:./mongod --shardsvr --replSet shard3 --port 29003 --dbpath=/data/mongodb/db/shard3_201/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard3_201.log --logappend --fork --nohttpinterface --directoryperdbserverC:./mongod --shardsvr --replSet shard3 --port 29003 --dbpath=/data/mongodb/db/shard3_202/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard3_202.log --logappend --fork --nohttpinterface --directoryperdb[root@serverA bin]# ./mongo --port 29003
MongoDB shell version: 2.6.0
connecting to: 127.0.0.1:29003/test
> config = {_id: 'shard3', members: [
... {_id: 0, host: '172.16.200.200:29003',priority:1},
... {_id: 1, host: '172.16.200.201:29003',priority:0},
... {_id: 2, host: '172.16.200.202:29003',arbiterOnly:true}]};
{
"_id" : "shard3",
"members" : [
{
"_id" : 0,
"host" : "172.16.200.200:29003",
"priority" : 1
},
{
"_id" : 1,
"host" : "172.16.200.201:29003",
"priority" : 0
},
{
"_id" : 2,
"host" : "172.16.200.202:29003",
"arbiterOnly" : true
}
]
}
> rs.initiate(config);
{
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}
>
shard3:SECONDARY>
shard3:SECONDARY>
shard3:SECONDARY>
shard3:PRIMARY> 启动configserverA:./mongod --configsvr --dbpath=/data/mongodb/db/config/ --port 29000 --logpath=/data1/logs/mongodb/config_200.log --logappend --fork --nohttpinterface --directoryperdb
serverB:./mongod --configsvr --dbpath=/data/mongodb/db/config/ --port 29000 --logpath=/data1/logs/mongodb/config_201.log --logappend --fork --nohttpinterface --directoryperdbserverC:./mongod --configsvr --dbpath=/data/mongodb/db/config/ --port 29000 --logpath=/data1/logs/mongodb/config_202.log --logappend --fork --nohttpinterface --directoryperdb启动mongosserverA:
./mongos --configdb 172.16.200.200:29000,172.16.200.201:29000,172.16.200.202:29000 --port 27001 --chunkSize 8 --logpath=/data1/logs/mongodb/mongos_200.log --logappend --fork --nohttpinterface
serverB:./mongos --configdb 172.16.200.200:29000,172.16.200.201:29000,172.16.200.202:29000 --port 27001 --chunkSize 8 --logpath=/data1/logs/mongodb/mongos_201.log --logappend --fork --nohttpinterfaceserverC:./mongos --configdb 172.16.200.200:29000,172.16.200.201:29000,172.16.200.202:29000 --port 27001 --chunkSize 8 --logpath=/data1/logs/mongodb/mongos_202.log --logappend --fork --nohttpinterface
配置sharding ./mono --port 27001mongos> use admin
switched to db admindb.runCommand( { addshard:"shard1/172.16.200.200:29001,172.16.200.201:29001,172.16.200.202:29001",name:"s1"} );
{ "shardAdded" : "s1", "ok" : 1 }
mongos> db.runCommand( { addshard:"shard2/172.16.200.201:29002,172.16.200.202:29002,172.16.200.200:29002",name:"s2"} );
{ "shardAdded" : "s2", "ok" : 1 }
mongos> db.runCommand( { addshard:"shard3/172.16.200.202:29003,172.16.200.200:29003,172.16.200.201:29003",name:"s3"} )
{ "shardAdded" : "s3", "ok" : 1 }
mongos> [root@serverA bin]# ./mongo --port 27001
MongoDB shell version: 2.6.0
connecting to: 127.0.0.1:27001/test
mongos>
mongos> show dbs
admin 0.016GB
config 0.016GB
congig (empty)mongos> use configswitched to db config
mongos> show collections
changelog
chunks
collections
databases
lockpings
locks
mongos
settings
shards
system.indexes
tags
version
/data/mongodb/db/{shard1_200,shard2_200,shard3_200,config}
/data1/logs/mongodb/
serverB:172.16.200.201
/data/mongodb/db/{shard1_201,shard2_201,shard3_201,config}
/data1/logs/mongodb/
serverC:172.16.200.202
/data/mongodb/db/{shard1_202,shard2_202,shard3_202,config}
/data1/logs/mongodb/
serverA:./mongod --shardsvr --replSet shard1 --port 29001 --dbpath=/data/mongodb/db/shard1_200/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard1_200.log --logappend --fork --nohttpinterface -directoryperdb
serverB:
./mongod --shardsvr --replSet shard1 --port 29001 --dbpath=/data/mongodb/db/shard1_201/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard1_201.log --logappend --fork --nohttpinterface --directoryperdbserverC:
./mongod --shardsvr --replSet shard1 --port 29001 --dbpath=/data/mongodb/db/shard1_202/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard1_202.log --logappend --fork --nohttpinterface -directoryperdb
登陆mongo./mongo --port 29001> config = {_id: 'shard1', members: [
... {_id: 0, host: '172.16.200.200:29001',priority:1},
... {_id: 1, host: '172.16.200.201:29001',priority:0},
... {_id: 2, host: '172.16.200.202:29001',arbiterOnly:true}]};
{
"_id" : "shard1",
"members" : [
{
"_id" : 0,
"host" : "172.16.200.200:29001",
"priority" : 1
},
{
"_id" : 1,
"host" : "172.16.200.201:29001",
"priority" : 0
},
{
"_id" : 2,
"host" : "172.16.200.202:29001",
"arbiterOnly" : true
}
]
}
> rs.initiate(config);
{
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}
>
shard1:SECONDARY>
shard1:SECONDARY> serverA:./mongod --shardsvr --replSet shard2 --port 29002 --dbpath=/data/mongodb/db/shard2_200/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard2_201.log --logappend --fork --nohttpinterface --directoryperdbserverB:
./mongod --shardsvr --replSet shard2 --port 29002 --dbpath=/data/mongodb/db/shard2_201/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard2_201.log --logappend --fork --nohttpinterface --directoryperdbserverC:./mongod --shardsvr --replSet shard2 --port 29002 --dbpath=/data/mongodb/db/shard2_202 --oplogSize 10240 --logpath=/data1/logs/mongodb/shard2_202.log --logappend --fork --nohttpinterface --directoryperdb登录mong./mongo --port 29002[root@serverA bin]# ./mongo --port 29002
MongoDB shell version: 2.6.0
connecting to: 127.0.0.1:29002/test
> config = {_id: 'shard2', members: [
... {_id: 0, host: '172.16.200.200:29002',priority:1},
... {_id: 1, host: '172.16.200.201:29002',priority:0},
... {_id: 2, host: '172.16.200.202:29002',arbiterOnly:true}]};
{
"_id" : "shard2",
"members" : [
{
"_id" : 0,
"host" : "172.16.200.200:29002",
"priority" : 1
},
{
"_id" : 1,
"host" : "172.16.200.201:29002",
"priority" : 0
},
{
"_id" : 2,
"host" : "172.16.200.202:29002",
"arbiterOnly" : true
}
]
}
> rs.initiate(config);
{
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}
>
shard2:SECONDARY>shard2:PRIMARY> serverA:./mongod --shardsvr --replSet shard3 --port 29003 --dbpath=/data/mongodb/db/shard3_200/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard3_200.log --logappend --fork --nohttpinterface --directoryperdb
serverB:./mongod --shardsvr --replSet shard3 --port 29003 --dbpath=/data/mongodb/db/shard3_201/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard3_201.log --logappend --fork --nohttpinterface --directoryperdbserverC:./mongod --shardsvr --replSet shard3 --port 29003 --dbpath=/data/mongodb/db/shard3_202/ --oplogSize 10240 --logpath=/data1/logs/mongodb/shard3_202.log --logappend --fork --nohttpinterface --directoryperdb[root@serverA bin]# ./mongo --port 29003
MongoDB shell version: 2.6.0
connecting to: 127.0.0.1:29003/test
> config = {_id: 'shard3', members: [
... {_id: 0, host: '172.16.200.200:29003',priority:1},
... {_id: 1, host: '172.16.200.201:29003',priority:0},
... {_id: 2, host: '172.16.200.202:29003',arbiterOnly:true}]};
{
"_id" : "shard3",
"members" : [
{
"_id" : 0,
"host" : "172.16.200.200:29003",
"priority" : 1
},
{
"_id" : 1,
"host" : "172.16.200.201:29003",
"priority" : 0
},
{
"_id" : 2,
"host" : "172.16.200.202:29003",
"arbiterOnly" : true
}
]
}
> rs.initiate(config);
{
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}
>
shard3:SECONDARY>
shard3:SECONDARY>
shard3:SECONDARY>
shard3:PRIMARY> 启动configserverA:./mongod --configsvr --dbpath=/data/mongodb/db/config/ --port 29000 --logpath=/data1/logs/mongodb/config_200.log --logappend --fork --nohttpinterface --directoryperdb
serverB:./mongod --configsvr --dbpath=/data/mongodb/db/config/ --port 29000 --logpath=/data1/logs/mongodb/config_201.log --logappend --fork --nohttpinterface --directoryperdbserverC:./mongod --configsvr --dbpath=/data/mongodb/db/config/ --port 29000 --logpath=/data1/logs/mongodb/config_202.log --logappend --fork --nohttpinterface --directoryperdb启动mongosserverA:
./mongos --configdb 172.16.200.200:29000,172.16.200.201:29000,172.16.200.202:29000 --port 27001 --chunkSize 8 --logpath=/data1/logs/mongodb/mongos_200.log --logappend --fork --nohttpinterface
serverB:./mongos --configdb 172.16.200.200:29000,172.16.200.201:29000,172.16.200.202:29000 --port 27001 --chunkSize 8 --logpath=/data1/logs/mongodb/mongos_201.log --logappend --fork --nohttpinterfaceserverC:./mongos --configdb 172.16.200.200:29000,172.16.200.201:29000,172.16.200.202:29000 --port 27001 --chunkSize 8 --logpath=/data1/logs/mongodb/mongos_202.log --logappend --fork --nohttpinterface
配置sharding ./mono --port 27001mongos> use admin
switched to db admindb.runCommand( { addshard:"shard1/172.16.200.200:29001,172.16.200.201:29001,172.16.200.202:29001",name:"s1"} );
{ "shardAdded" : "s1", "ok" : 1 }
mongos> db.runCommand( { addshard:"shard2/172.16.200.201:29002,172.16.200.202:29002,172.16.200.200:29002",name:"s2"} );
{ "shardAdded" : "s2", "ok" : 1 }
mongos> db.runCommand( { addshard:"shard3/172.16.200.202:29003,172.16.200.200:29003,172.16.200.201:29003",name:"s3"} )
{ "shardAdded" : "s3", "ok" : 1 }
mongos> [root@serverA bin]# ./mongo --port 27001
MongoDB shell version: 2.6.0
connecting to: 127.0.0.1:27001/test
mongos>
mongos> show dbs
admin 0.016GB
config 0.016GB
congig (empty)mongos> use configswitched to db config
mongos> show collections
changelog
chunks
collections
databases
lockpings
locks
mongos
settings
shards
system.indexes
tags
version
登录
登陆
配置
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
通州区网络技术咨询热线
软件开发最流行的是哪类
高中生在手机上怎么学习软件开发
软件开发方向考研哪个学校好
网络安全技术与实践刘建伟ppt
网络安全常识性知识
国家涉密软件开发甲级
小米数据库异常
如果在数据库中已有同名的表
网络安全等保定级和系统建设顺序
怎么下access数据库
计算机中记录病毒的数据库
网课系统软件开发需求
数据库备份文件怎么打开
ccd视觉检测软件开发
服务器被锁定
网络安全法三原则
福建智慧养老软件开发哪儿好
网络安全需要注意的事项英语s
方舟起源重生服务器
宜宾兴文县棋牌软件开发
从td数据库到hive
win10服务器管理工具
集团网络安全事件通报
平舆县统计局网络安全
加强网络安全信息问答题
网上请假审批与管理系统数据库
软件开发的开会主题
中央网络安全和信息领导
我的世界一点16.5服务器