通过 Java 接口远程访问 ArangoDB [英] Remote access to ArangoDB through Java Interface

查看:29
本文介绍了通过 Java 接口远程访问 ArangoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个使用 ArangoDB 作为后端数据库的 Java 应用程序(使用 ArangoDB Java-Driver/Interface 访问 ArangoDB).

I have developed a Java application that uses ArangoDB as backend database (Used ArangoDB Java-Driver/Interface to access ArangoDB).

一切都很好,直到我的 ArangoDB 和应用程序驻留在同一台机器上.

Everything is good until my ArangoDB and Application resides on same machine.

一旦我将 ArangoDB 移动到远程机器(专用服务器),我的应用程序就无法访问它:(

Once i moved ArangoDB to remote machine(Dedicated Server), my application is unable to access it :(

我在一些属性文件中提供了我的远程机器详细信息(ArangoDB 服务器),并在创建 ArangoDriver 对象时将该文件位置提供给 ArangoConfigure 构造函数.但我仍然无法访问 ArangoDB :(

I have given my remote machine details(ArangoDB Server) in some properties file and feeding that file location to ArangoConfigure Constructor while creating ArangoDriver Object. But still i'm unable to access ArangoDB :(

我的代码的小片段如下:

Small snippet of my code is below:

protected static ArangoConfigure getConfiguration() {
        //ArangoConfigure configure = new ArangoConfigure();
        ArangoConfigure configure = new
ArangoConfigure("/Volumes/Official/ZLabs/arangodb.properties");
                configure.init();

        return configure;   }

    protected static ArangoDriver getArangoDriver(ArangoConfigure
configuration) {        return new ArangoDriver(configuration);     }

请在这方面帮助我.

等待您的回复.

谢谢&此致,- 马希

Thanks & Best Regards, - Mahi

推荐答案

如果 Aranngodb Java 驱动程序无法打开或解析 /Volumes/Official/ZLabs/arangodb.properties,它会发出一条日志消息.

If the Aranngodb Java driver fails to open or parse /Volumes/Official/ZLabs/arangodb.properties it issues a log message.

如果 arangodb 属性看起来像这样:

If arangodb properties looks like that:

port=8529
host=192.168.22.17
user=root
password=OpenSesame
enableCURLLogger=false

您开始走上 OSI 模型来调试 TCP 连接问题,以避免可能的连接问题到防火墙、路由等.一种使用常用的telnet命令来测试服务器的可用性:

You start walking up the OSI model to debug TCP connection problems to evade possible connection issues due to firewals, routing etc. One uses the commonly available telnet command to test the availability of the server:

telnet 192.168.22.17 8529
Trying 192.168.22.17...

如果它永远留在那里,你很可能有防火墙过滤掉你,你最终会得到:

If it sits there forever, you most probably have a firewall filtering you away, you finaly will get:

telnet: Unable to connect to remote host: Connection timed out

如果它立即退出:

telnet: Unable to connect to remote host: Connection refused

服务器似乎没有应答.

在服务器端,您可以检查服务是否绑定了您尝试连接的端口(8529):

On the server side you then can check whether the service has bound the port (8529) you're trying to connect:

netstat -alpnt |grep 8529
tcp        0      0 0.0.0.0:8529            0.0.0.0:*               LISTEN      19912/arangod   

如果您看到它绑定了 127.0.0.1:8529,您将无法远程连接它,需要像这样更改 arangod.conf:

If you instead see it binding 127.0.0.1:8529 you won't be able to connect it remotely and need to change arangod.conf like this:

[server]
endpoint = tcp://0.0.0.0:8529

然后重启ArangoDB.然后,您应该能够看到如下内容:

And then restart ArangoDB. Then, you should be able to see something like this:

telnet 192.168.22.17 8529
Trying 192.168.22.17...
Connected to 192.168.22.17.
Escape character is '^]'. <start to type now: >
GET / HTTP/1.0

<server should reply:>
HTTP/1.1 301 Moved Permanently
Location: /_db/_system/_admin/aardvark/index.html
Content-Type: text/html
Server: ArangoDB
Connection: Close
Content-Length: 197

<html><head><title>Moved</title></head><body><h1>Moved</h1>
<p>This page has moved to <a href="/_db/_system/_admin/aardvark/index.html">/_db/_system/_admin/aardvark/index.html</a>.
</p></body></html>Connection closed by foreign host.

这篇关于通过 Java 接口远程访问 ArangoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆