mongoDB命令
2015-06-25 19:18
716 查看
删除数据库后(不知道是不是要每个moongod都删除liu)
进入admin 不用新建数据库liu
直接db.runCommand( { enablesharding : “liu” } );
db.runCommand( { shardcollection :“liu.docs”,key:{"name":"hashed"} } );
db.runCommand( { enablesharding :“<dbname>” } );
db.runCommand( { shardcollection :“<namespace>”,key : <shardkeypatternobject> });
db.c2.drop()
db.createCollection('c2')
db.c2.ensureIndex({LOG_DATE:"hashed"})
sh.shardCollection("mydb.c2",{"LOG_DATE": "hashed"})
chunksize:
use config
db.settings.find()
db.settings.save( { _id:"chunksize",value: <sizeInMB> } )
sh.enableSharding("<database>")
sh.getBalancerState()
sh.stopBalancer()
sh.startBalancer()
mongostat -h 192.168.137.104:30000
MongoDatabase database = server.GetDatabase("admin");
CommandDocument cd = new CommandDocument
{
{"listshards","1"}
};
CommandResult cr=database.RunCommand(cd);
Console.WriteLine(cr.Response);
MongoDatabase database1 = server.GetDatabase("liu");
database1.CreateCollection("docs");
MongoCollection collection =database1.GetCollection<Entity>("docs");
var keys = new IndexKeysBuilder();
keys.Hashed("name");
collection.CreateIndex(keys);
1.Determine what you will use for the shardkey. Your selection of the shard key affects the efficiency of sharding.
See the selection considerations listed inthe Considerations for Selecting Shard Key.
2.If the collection already contains datayou must create an index on the shard key using ensureIndex().
If the collection is empty then MongoDBwill create the index as part of the sh.shardCollection() step.
3.Enable sharding for a collection byissuing the sh.shardCollection() method in the mongo shell. The method uses thefollowing syntax:
sh.shardCollection("<database>.<collection>",shard-key-pattern)
Mongos 锁的问题 ,需要时间处理
This is not really an error message: it'smore of an informational
message. It indicates that a 'mongos' process attempted to start a
balancing round while one was already inprogress. This is a normal part
of sharded operation, and this message can besafely ignored.
进入admin 不用新建数据库liu
直接db.runCommand( { enablesharding : “liu” } );
db.runCommand( { shardcollection :“liu.docs”,key:{"name":"hashed"} } );
db.runCommand( { enablesharding :“<dbname>” } );
db.runCommand( { shardcollection :“<namespace>”,key : <shardkeypatternobject> });
db.c2.drop()
db.createCollection('c2')
db.c2.ensureIndex({LOG_DATE:"hashed"})
sh.shardCollection("mydb.c2",{"LOG_DATE": "hashed"})
chunksize:
use config
db.settings.find()
db.settings.save( { _id:"chunksize",value: <sizeInMB> } )
sh.enableSharding("<database>")
sh.getBalancerState()
sh.stopBalancer()
sh.startBalancer()
mongostat -h 192.168.137.104:30000
MongoDatabase database = server.GetDatabase("admin");
CommandDocument cd = new CommandDocument
{
{"listshards","1"}
};
CommandResult cr=database.RunCommand(cd);
Console.WriteLine(cr.Response);
MongoDatabase database1 = server.GetDatabase("liu");
database1.CreateCollection("docs");
MongoCollection collection =database1.GetCollection<Entity>("docs");
var keys = new IndexKeysBuilder();
keys.Hashed("name");
collection.CreateIndex(keys);
1.Determine what you will use for the shardkey. Your selection of the shard key affects the efficiency of sharding.
See the selection considerations listed inthe Considerations for Selecting Shard Key.
2.If the collection already contains datayou must create an index on the shard key using ensureIndex().
If the collection is empty then MongoDBwill create the index as part of the sh.shardCollection() step.
3.Enable sharding for a collection byissuing the sh.shardCollection() method in the mongo shell. The method uses thefollowing syntax:
sh.shardCollection("<database>.<collection>",shard-key-pattern)
Mongos 锁的问题 ,需要时间处理
This is not really an error message: it'smore of an informational
message. It indicates that a 'mongos' process attempted to start a
balancing round while one was already inprogress. This is a normal part
of sharded operation, and this message can besafely ignored.
相关文章推荐
- 分享微信开发Html5轻游戏中的几个坑
- Android之获取手机上的图片和视频缩略图thumbnails
- PHP添加yaf xhprof mongodb 同理
- mongodb安装
- 数据库链接字符串查询网站
- 如何在 Ubuntu 上安装 MongoDB
- DB2实例管理
- DB2实例管理
- 保障MySQL数据安全的14个最佳方法
- mysql问答汇集
- 创建一个空的IBM DB2 ECO数据库的方法
- Access 2000 数据库 80 万记录通用快速分页类
- 开通一个数据库失败的原因的和解决办法
- 一个简单的asp数据库操作类
- CentOS下DB2数据库安装过程详解
- EasyASP v1.5发布(包含数据库操作类,原clsDbCtrl.asp)第1/2页
- sql2008 还原数据库解决方案
- Oracle 数据库自动存储管理-安装配置
- Oracle 数据库 临时数据的处理方法