`
liyonghui160com
  • 浏览: 775521 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

mongodb 3.2

阅读更多

 

 

mongodb的驱动包:

https://docs.mongodb.com/ecosystem/drivers/java/

https://github.com/mongodb/mongo-csharp-driver/tree/master

 

 

1、单独启动:

./mongod -port=27017 -fork -bind_ip=192.168.149.90 -dbpath=/export/App/mongodb-linux-x86_64-3.2.10/data -logpath=/export/App/mongodb-linux-x86_64-3.2.10/log/mongodb.log -pidfilepath=/export/App/mongodb-linux-x86_64-3.2.10/pid/mongo.pid &

 

 

各个参数详见:https://my.oschina.net/pwd/blog/399374

配置文件:https://docs.mongodb.com/manual/reference/configuration-options/

 

 

2、replSet:

2.1 mongod --replSet "rs0"

2.2 mongo

rs.initiate()

rs.add("mongodb1.example.net:20017")

rs.add("mongodb2.example.net:20017")

投票节点

rs.addArb("m1.example.net:30000")

删除节点:

rs.remove("mongod3.example.net")

 

https://docs.mongodb.com/manual/tutorial/deploy-replica-set/

 

3、master-slave:

3.1 mongod --master --dbpath /data/masterdb/ &

3.2 mongod --slave --source <masterhostname><:<port>> --dbpath /data/slavedb/ &

Configuration:

rs.printReplicationInfo()

 

4、shard

4.1 config servers:mongod --configsvr --replSet configReplSet --port <port> --dbpath <path>

4.2 mongos --configdb configReplSet/<cfgsvr1:port1>,<cfgsvr2:port2>,<cfgsvr3:port3>

4.3 mongo --host <hostname of machine running mongos> --port <port mongos listens on>

    sh.addShard("mongodb0.example.net:27017")

 

db.printShardingStatus()

 

https://docs.mongodb.com/manual/tutorial/deploy-sharded-cluster-hashed-sharding/

https://docs.mongodb.com/manual/tutorial/deploy-sharded-cluster-ranged-sharding/

 

 

用户控制:

 

show users;

use admin;

db.createUser({user:"dba",pwd:"dba",roles:[{role:"userAdminAnyDatabase",db:"admin"}]});

db.dropUser("dba")

 

use test;

db.createUser({user:"dba",pwd:"dba",roles:["readWrite"]});

 

连接命令:./mongo -u buru -p 12345678 --authenticationDatabase admin

 

https://docs.mongodb.com/manual/reference/method/js-user-management/

 

 

操作命令

./mongo 192.168.149.90:27017

监控:

./mongostat -h 192.168.149.90

 

关闭 mongoDB?千万不要 kill -9 pid,可以 kill -2 pid 或 db.shutdownServer()

 

详细的请大家仔细看文档吧

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics