[英]How to connect to mongodb EC2 instance, using JAVA Driver + SSH pem key
Good afternoon. 下午好。 I'm using Mongodb 2.6.7 + Java driver ( IntelliJ).
我正在使用Mongodb 2.6.7 + Java驱动程序(IntelliJ)。
Presently i have cluster RF5 4 inst.+1arbiter. 目前我有集群RF5 4 inst。+ 1arbiter。 I would like to connect to my primary using ssh, but i don't have any idea how to do it...
我想使用ssh连接到我的主服务器,但是我不知道该怎么做...
to connect to local host i'm using - MongoClient client = new MongoClient( new ServerAddress("localhost", 27003)), but how can i made connection to concert IP address using my xxx.pem key? 连接到我正在使用的本地主机-MongoClient client = new MongoClient(new ServerAddress(“ localhost”,27003)),但是如何使用我的xxx.pem密钥连接到Concert IP地址?
Thank You in advance, hope for quick reply 预先谢谢您,希望快速回复
You need to set-up an ssh tunnel. 您需要设置ssh隧道。 Once the tunnel is set-up, you can connect to your end of the ssh tunnel.
一旦建立了隧道,就可以连接到ssh隧道的末端。
You can set-up the tunnel outsied of your application using the ssh client of your operating system. 您可以使用操作系统的ssh客户端设置应用程序之外的隧道。 Or you can use a ssh java library like JSCH and set-up the tunnel from your java application.
或者,您可以使用诸如JSCH之类的ssh Java库,并通过Java应用程序设置隧道。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.