我在运行系统中使用MongoDB和Robomongo,我使用Robomongo作为客户端,我在不同的系统上安装了MongoDB,我将其视为服务器,我想将系统的Robomongo(作为客户端)连接到其他系统上的MongoDB(服务器).我应该遵循哪些步骤来实现相同的目标?任何线索都会有所帮助.提前致谢
Sha*_*han 20
编辑:注释掉bind_ip可能会使您的系统容易受到安全漏洞的影响,请参阅https://docs.mongodb.com/manual/administration/security-checklist/#limit-network-exposure 添加更多IP更好打开你的系统到一切.
您需要编辑/etc/mongod.conf文件的bind_ip变量以包含您正在使用的计算机的IP,或者完全取消它.
我能够使用以下mongod.conf连接,我注释掉了bind_ip和未注释的端口.
# mongod.conf
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongod.log
logappend=true
port = 27017
# Listen to local interface only. Comment out to listen on all
interfaces.
#bind_ip = 127.0.0.1
# Disables write-ahead journaling
# nojournal = true
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#diaglog = 0
# Ignore query hints
#nohints = true
# Enable the HTTP interface (Defaults to port 28017).
#httpinterface = true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# Disable data file preallocation.
#noprealloc = true
# Specify .ns file size for new databases.
# nssize = <size>
# Replication Options
# in replicated mongo databases, specify the replica set name here
#replSet=setname
# maximum size in megabytes for replication operation log
#oplogSize=1024
# path to a key file storing authentication info for connections
# between replica set members
#keyFile=/path/to/keyfile
Run Code Online (Sandbox Code Playgroud)
在尝试连接之前不要忘记重启mongod服务:
service mongod restart
Run Code Online (Sandbox Code Playgroud)
从robomongo我使用以下连接设置:
连接选项卡:
地址:[VPS IP]:27017
SSH标签:
SSH地址:[VPS IP]:22
SSH用户名:[启用sudo的用户名]
SSH验证方法:密码
用户密码:Supersecret
首先,您必须mongod在终端中运行命令,确保命令正确执行.
然后在新的终端选项卡运行mongo命令.
然后打开Robomongo GUI并使用默认设置创建新连接.
希望这将解决您的问题
干杯!!