简体   繁体   English

使用Robo 3T连接到远程MongoDB

[英]Use Robo 3T to connect to remote MongoDB

I'm trying to use Robomongo (or Robo 3T) under Mac to control my mongodb in the remote Ubuntu & Nginx server. 我正在尝试在Mac下使用Robomongo(或Robo 3T)在远程Ubuntu&Nginx服务器中控制我的mongodb。

Normally, I need to ssh xxx.xx.xx.xx in a terminal with a username and a password to connect to the server. 通常,我需要在带有用户名和密码的终端中使用ssh xxx.xx.xx.xx来连接服务器。 in /etc/nginx/sites-enabled/myweb.io , there is listen 443 ssl . /etc/nginx/sites-enabled/myweb.io ,有listen 443 ssl

In Robo 3T, I tried to set up the connection with Use SSH tunnel . 在Robo 3T中,我尝试Use SSH tunnel建立连接。 I tried the port number 443 or 80 . 我尝试使用端口号44380 But it gave me an error: Error: Resource temporarily unavailable. Error when starting up SSH session: -13. (Error #35) 但这给了我一个错误: Error: Resource temporarily unavailable. Error when starting up SSH session: -13. (Error #35) Error: Resource temporarily unavailable. Error when starting up SSH session: -13. (Error #35)

Does anyone know how to fix this? 有谁知道如何解决这一问题?

在此处输入图片说明

The correct setting is 正确的设置是

1) under SSH , check User SSH tunnel , use port 22 1)在SSH下,检查User SSH tunnel ,使用端口22

2) and under Connection , write 127.0.0.1:27017 2)并在“ Connection下,输入127.0.0.1:27017

Connect to remote MongoDB using Roto3t 使用Roto3t连接到远程MongoDB

Firstly, we should check the standard URI connection scheme for mongodb 首先,我们应该检查mongodb的标准URI连接方案

mongodb://[username:password@]host1[:port1][,...hostN[:portN]]][/[database][?options]]

We make a SSH Connection to the remote MongoDB on Cloudfoundry 我们通过SSH ConnectionCloudfoundry上的远程MongoDB

in my case cf ssh -L port_forwarding:HOST_NAME:Port NAME_OF_APP 在我的情况下cf ssh -L port_forwarding:HOST_NAME:Port NAME_OF_APP

(1) In the Connection tab in Robo3T we choose (1)在Robo3T的“ Connection选项卡中,我们选择

Type: direct connection
Name: choose_any_connection_name
Address: localhost and port is 'port_forwarding' we choose in the SSH connection we made.

(2) in the Authentication tab, we should add database , username , password , and Auth Machanism: SCRAM-SHA-1 (2)在“ Authentication选项卡中,我们应该添加databaseusernamepasswordAuth Machanism: SCRAM-SHA-1

(3) in the SSH Tab we will uncheck use SSH tunnel as we made it manually. (3)在“ SSH选项卡中,我们将取消选中手动创建的“ use SSH tunnel Now, if you click test the connection should be successfully done. 现在,如果单击测试,则连接应该成功完成。

Note : If we use Studio 3T it will parse the URI and fill all these fields for us. 注意 :如果我们使用Studio 3T ,它将解析URI并为我们填写所有这些字段。

I've done few configurations on my Ubuntu 18 Vagrant box in order to successfully connect MongoDB remotely using Robo 3T GUI. 为了在使用Robo 3T GUI远程成功连接MongoDB的过程中,我在Ubuntu 18 Vagrant盒上做了一些配置。 I've explained in the following steps. 我已经按照以下步骤进行了说明。

  1. On Ubuntu server, to open mongo shell run: 在Ubuntu服务器上,打开mongo shell运行:
     $ mongo 
  2. Inside mongo shell, type following command to create new a admin user. 在mongo shell中,键入以下命令以创建新的admin用户。

     > use admin; > db.createUser({user:"admin", pwd:"password", roles:[{ role: "root", db: "admin" }]}); 
  3. By default mongodb is configured to allow connections only from localhost(IP 127.0.0.1). 默认情况下,mongodb配置为仅允许来自本地主机(IP 127.0.0.1)的连接。 We need to allow remote connections from any ip address. 我们需要允许来自任何IP地址的远程连接。 The following change should only be done in your development server. 以下更改仅应在开发服务器中进行。 Open up etc/mongod.conf file and do the following change. 打开etc / mongod.conf文件并进行以下更改。

     # network interfaces net: port: 27017 bindIp: 0.0.0.0 #default value is 127.0.0.1 

    Also in the same mongod.conf file uncomment security option and add authorization option as shown below. 同样在同一mongod.conf文件中,取消注释安全性选项并添加授权选项,如下所示。

     security: authorization: enabled 
  4. Save and exit the mongod.conf file and restart mongodb server. 保存并退出mongod.conf文件,然后重新启动mongodb服务器。

     $ sudo servcie mongod restart 
  5. Download and install Robo 3T GUI tool. 下载并安装Robo 3T GUI工具。

  6. On Robo 3T GUI, in the connection settings, you need to do few changes as shown on below screen shots. 在Robo 3T GUI的连接设置中,您需要进行一些更改,如下面的屏幕截图所示。

在此处输入图片说明

Enter mongodb admin database username and password which you have created earlier. 输入您之前创建的mongodb admin数据库用户名和密码。

在此处输入图片说明

Here, I have entered my Ubuntu 18 Vagrant box ssh credentials. 在这里,我输入了Ubuntu 18 Vagrant box ssh凭证。

在此处输入图片说明

Save the changes and press connect icon to see if the connection is working fine. 保存更改,然后按连接图标以查看连接是否正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM