客户端登录
/opt/cloud/mongodb/bin/mongo -host x.xx.x.x --port 8635 -u rwuser -p xxxx --authenticationsDatabase admin
管理员账号登录
use admin
db.auth("dbadmin","xxx")
1,创建数据库
use pipeline
#查看数据库
show dbs
2,创建用户
use pipeline
db.createUser( {user: "pipeline",pwd: "123456",roles: [{role: "userAdminAnyDatabase", db: "pipeline"}],passwordDigestor: "server"})
db.grantRolesToUser("pipeline",[{role: "dbOwner",db: "cache"}]);
3,对实例启用分片
use admin
db.runCommand({enableSharding; "pipeline"})
4,创建集合,并对集合分片
use pipeline
db.createCollection("JobDetail")
sh.shardCollecton("pipeline.JobDetail", {"_id",1})
5,查看分片情况
db.getCollection("JobDetail").getShardDistribution();
6,创建索引
db.JobDetail.createIndex({"pipeline_id": 1},{backgr