最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

mongo单台设备分片--2

来源:动视网 责编:小采 时间:2020-11-09 16:06:46
文档

mongo单台设备分片--2

mongo单台设备分片--2:mongo单台设备分片--2 mongodb please create an index over the sharding key before sharding 使用单一索引,如果collection中没有索引,就会报错 config={_id:shard1,members:[{_id: 0, host: 127.0.0.1:
推荐度:
导读mongo单台设备分片--2:mongo单台设备分片--2 mongodb please create an index over the sharding key before sharding 使用单一索引,如果collection中没有索引,就会报错 config={_id:shard1,members:[{_id: 0, host: 127.0.0.1:


mongo单台设备分片--2 mongodb please create an index over the sharding key before sharding 使用单一索引,如果collection中没有索引,就会报错 config={_id:shard1,members:[{_id: 0, host: 127.0.0.1:27018},{_id: 1, host: 127.0.0.1:27019},{_id: 2,

mongo单台设备分片--2

mongodb please create an index over the sharding key before sharding

使用单一索引,如果collection中没有索引,就会报错

config={_id:'shard1',members:[{_id: 0, host: '127.0.0.1:27018'},{_id: 1,
host: '127.0.0.1:27019'},{_id: 2, host: '127.0.0.1:27020'},{_id: 3, host: '127.0.0.1:27021'}]}

rs.initiate(config);

rs.add({"_id" : 4,host : "127.0.0.1:27022",arbiterOnly:true});

config={_id:'shard2',members:[{_id: 0, host: '127.0.0.1:27028'},{_id: 1,
host: '127.0.0.1:27029'},{_id: 2, host: '127.0.0.1:27030'},{_id: 3, host: '127.0.0.1:27031'}]}

rs.initiate(config);

rs.add({"_id" : 4,host : "127.0.0.1:27032",arbiterOnly:true});

config={_id:'shard3',members:[{_id: 0, host: '127.0.0.1:27038'},{_id: 1,
host: '127.0.0.1:27039'},{_id: 2, host: '127.0.0.1:27040'},{_id: 3, host: '127.0.0.1:27041'}]}

rs.initiate(config);

rs.add({"_id" : 4,host : "127.0.0.1:27042",arbiterOnly:true});

sudo mongod --configsvr --dbpath /data/mongo/ReplicaSetData-shard1/
config --port 20000 --logpath /data/mongo/ReplicaSetData-shard1/config.log --logappend --fork

sudo mongod --configsvr --dbpath /data/mongo/ReplicaSetData-shard2/
config --port 20001 --logpath /data/mongo/ReplicaSetData-shard2/config.log --logappend --fork

sudo mongod --configsvr --dbpath /data/mongo/ReplicaSetData-shard3/
config --port 20002 --logpath /data/mongo/ReplicaSetData-shard3/config.log --logappend --fork

sudo mongos --configdb 127.0.0.1:20000,127.0.0.1:20001,127.0.0.1:
20002 --port 30000 --chunkSize 5 --logpath /data/mongo/ReplicaSetData-
shard-log/mongos.log --logappend --fork

db.runCommand( { addshard : "shard1/127.0.0.1:27018,127.0.0.1:27019,
127.0.0.1:27020,127.0.0.1:
27021,127.0.0.1:27022",name:"s1",maxsize:20480} );

db.runCommand( { addshard : "shard2/127.0.0.1:27028,127.0.0.1:27029,
127.0.0.1:27030,127.0.0.1:27031,
127.0.0.1:27032",name:"s2",maxsize:20480} );

db.runCommand( { addshard : "shard3/127.0.0.1:27038,127.0.0.1:27039,
127.0.0.1:27040,127.0.0.1:27041,
127.0.0.1:27042",name:"s3",maxsize:20480} );

db.runCommand( { listshards : 1 } )

db.runCommand( { enablesharding : "cooler" } );

db.runCommand( { shardcollection : "cooler.c1",key : {id: 1} } )

for (var i = 1; i <= 200003; i++) db.c1.save({id:i,value1:"12345670",
value2:"12345670",value3:
"12345670",value4:"12345670"});

db.printShardingStatus()

db.c1.stats()

文档

mongo单台设备分片--2

mongo单台设备分片--2:mongo单台设备分片--2 mongodb please create an index over the sharding key before sharding 使用单一索引,如果collection中没有索引,就会报错 config={_id:shard1,members:[{_id: 0, host: 127.0.0.1:
推荐度:
标签: 设备 mongo 分片
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top