【发布时间】:2019-02-08 13:58:34
【问题描述】:
所以我想转储在另一台服务器上运行的 mongoDB 集合。以下是采取的步骤:
1.在admin中创建用户名和密码
$ db.createUser(
{
user: "username1",
pwd: "password1",
roles: [
{ role: "userAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" },
{ role: "dbAdminAnyDatabase", db: "admin" },
{ role: "clusterAdmin", db: "admin" }
]
}
)
2。然后在mongod.conf(/etc/mongod.conf)bindIp字段中添加数据库服务器的私有ip(x.x.x.x)
bindIp: 127.0.0.1,x.x.x.x
3。然后按如下方式运行 mongodump:
$ mongodump --host x.x.x.x:27017 -d database_name -c collection_name --out path_to_mongoDump -u username1 -p password1 --authenticationDatabase admin
以上将集合转储到指定位置的应用服务器没有任何问题。
上述方法是否安全?或者有没有更好的方法来完成上述操作?
谢谢。
参考链接:
1.What does the --bindip configuration option in mongodb does?
2.How to connect to MongoDB EC2 instance
3.How to secure MongoDB with username and password
4.Mongodump from remote server
【问题讨论】:
标签: mongodb