Basic ReplicaSet Deployment of MongoDB
来源:互联网 发布:淘宝买的京东e卡假的 编辑:程序博客网 时间:2024/06/06 20:04
the deployment consists of three members in localhost, here considering the situation from converting a standalone mongod instance(mongodb enterprise edition 3.2), and enables access control.
simple deployment procedure
(1)a ready and standalone mongodb instance
(2)create separate data directory for three members
(3)(optional)create config file with specific startup option, resembling as an example
...net: bindIp: 127.0.0.1replication: replSetName: "dev_rs"security: keyFile: "key file path"...
(4) start up mongod with -f option if using (3)
mongod --port port_num -f config_file --auth
(5)connect server instance by mongo client
mongo --port port_num
some notes:
- if enabling access control, need to make internal authentication when a certain member is in RECOVERING status.
access control
at the beginning, create first user as user administrator in db system in two ways below,
(1)start up mongod instance without access control
(2)with –auth CLI args, enabling during mongod startup
Under the circumstance, a localhost exception is provided
general instructions for both:
use admin#Note: the user with userAdmin or userAdminAnyDatabasedb.createUser(user_doc,writeConcern)
for example, in admin database, create the user called admin_user with built-in role called userAdminAnyDatabase.
use admin[admin|db].createUser({user:'admin_user',pwd:'***',roles:[{role:'userAdminAnyDatabase',db:'admin'}|'userAdminAnyDatabase']
after that operations, you can manipulate users and roles in any databases of current db system.
basic user management
(1)create a user
for example, create a user in db called testdev
use testdevdb.createUser({user:'test_user',pwd:'***',roles:[{role:'read',db:'admin'},'readWrite']})
at this time, the user test_user with specific built-in roles almost CRUD data.
basic role management
(1)create a user-defined role
As existing built-in roles may not implement desired set of privileges, you can also create some new ones.
Conventions:
(1.1)A role is uniquely determined by combination of database and role name
(1.2)Except for roles created in the admin database, a role can only include privileges that apply to its database and can only inherit from other roles in its database
(1.3)centralized Role data in system.roles collection in admin db.
for example,simply create a role called f_role for specific collection called testcol in testdev db
use testdevdb.createRole({role:'f_role', #only grant find privilege to the roleprivileges:[ { resource:{db:'testdev',collection:'testcol'}, actions:['find'] }],roles:[]})
(2)grant a role to a user
db.grantRolesToUser( 'test_user', [ {role:'role_name',db:'admin'}, 'f_role' #only as illustration ])
(3)update a role
for example, update existing role called cols_role with a new privilege
use testdevdb.updateRole('cols_role',{#as update document object privileges:[ { resource:{db:'testdev',collection:''}, actions:['listCollections'] } ], roles:[]})
collection-level access control
sometimes, need to limit user operations to specific collections by specific privileges and scope.
for example, a user called test_user_1 with only has find and show collections privileges in testdev.
here, make an assumption that test_user_1 has been there, then grant two roles called f_role and cols_role to the user, that is it.
through simple action above, you have limited access to testdev db.
(Notes: the article mainly focuses on deploying test/dev environment locally, testing/verifying/contributing code for mongoengine. )
- Basic ReplicaSet Deployment of MongoDB
- MongoDB ReplicaSet
- 安装MongoDB配置ReplicaSet
- Mongodb ReplicaSet + Sharding集群实现
- 关于mongodb的replicaSet模式----mongodb
- Mongodb的安装、主从配置、replicaSet配置
- mongoDB single db convert to replicaSet
- Mongodb中replicaset的搭建以及部署
- Mongodb在replicaset的secondary上补建索引
- MongoDB---简单的几步搭建ReplicaSet
- Mongodb的安装、主从配置、replicaSet配置
- Mongodb的安装、主从配置、replicaSet配置
- Mongodb的安装、主从配置、replicaSet配置
- Mongodb的安装、主从配置、replicaSet配置
- 【MongoDB】The basic operation of Mongodb, Insert\Query\Delete\Update
- 【MongoDB】The basic operation of Index in MongoDB
- 【MongoDB】The basic operation of Index in MongoDB
- MongoDB - basic
- 支持向量机(SVM)简介
- 汪国新湖北诗书画院隆重举行别样的文化之旅——2017长阳地标·城市定向挑战系列赛
- PHP转盘抽奖接口实例_PHP教程
- eMMC之分区管理、总线协议和工作模式
- jdk下载、安装及环境变量配置
- Basic ReplicaSet Deployment of MongoDB
- 杭电acm 1370Biorhythms
- 百度股市通日k数据接口
- Toast自定义显示时间以及自定义显示位置
- Java语言程序设计(基础篇)课后答案
- 汪国新委员、郑桂兰董事长参加“保护黄河万里直播行动”北京启动
- Java操作远程Hbase详细步骤
- 恶意页面http://px.media-serving.com/或者http://goto.peak-adx.com 乱弹出来 在Mac OS X
- 中文乱码的产生原因