所以我想转储在另一台服务器上运行的mongoDB集合。采取的步骤如下:
1.在管理员中创建用户名和密码
$ 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
答案 0 :(得分:1)
您应该使用选项CurrentDate <- Sys.Date()
# The number of the week relative to the year
weeknum <- as.integer( format(CurrentDate, format="%U") )
# Find the minimum week of the month relative to the year
mindatemonth <- as.Date( paste0(format(CurrentDate, "%Y-%m"), "-01") )
weeknummin <- as.integer( format(mindatemonth, format="%U") ) # the number of the week of the first week within the month
# Calculate the number of the week relative to the month
weeknum <- weeknum - (weeknummin - 1) # this is as an integer
# With the following you can convert the integer to the same format of
# format(CurrentDate, format="%U")
formatC(weeknum, width = 2, flag = "0")
,以便对整个通信进行加密。如果您不选择该选项,攻击者就有可能侦听您的通信并从数据库中提取数据。
使用此选项时,您应该是安全的,无需采取其他步骤。