简体   繁体   English

建立与OrientDB的连接的最佳方法

[英]The best way to create connection to OrientDB

I create a connection to the database is as follows: 我创建到数据库的连接如下:

ODatabaseDocumentTx db = new ODatabaseDocumentTx("remote:host1/test")
    .open("admin", "admin");

I have 2 nodes of DB. 我有2个DB节点。 When I shutdown node, which was in constructor, then throws exception: 当我关闭在构造函数中的节点时,然后引发异常:

Database 'plocal:/root/orientdb/databases/test' is closed

Of course, I can catch this exception and create new connection to another server, but I think, this is wrong. 当然,我可以捕获此异常并创建与另一台服务器的新连接,但是我认为这是错误的。

Is there way to create connection to full DB, not to single node of cluster? 有没有办法创建到完整数据库的连接,而不是到集群的单个节点的连接?

If you run 2 servers in cluster the switch is supposed to be automatic and transparent. 如果您在群集中运行2台服务器,则该交换机应该是自动且透明的。 But start 2 nodes using dserver.sh/bat instead of server.sh/bat and assure two nodes see each other. 但是,请使用dserver.sh/bat而不是server.sh/bat启动2个节点,并确保两个节点能够看到对方。 Look at this tutorial: https://github.com/orientechnologies/orientdb/wiki/Tutorial%3A-setup-a-distributed-database 查看本教程: https : //github.com/orientechnologies/orientdb/wiki/Tutorial%3A-setup-a-distributed-database

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

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