我正在做一些POC我已经使用H2作为DB。现在,为了扩展我计划将其放在云端,但我不确定如何让多个实例监听一个H2服务器? 我想到的一件事是在其中一个实例中创建一个tcp服务器,然后让其他实例与此实例通信,唯一的问题是如何在Cloud Foundry中公开端口?
final String[] args = new String[] {
"-tcpPort", "8092",
"-tcpAllowOthers","true" };
org.h2.tools.Server server = org.h2.tools.Server.createTcpServer(args).start();
有人可以分享一些我可以用来公开这个tcp服务的例子吗?
答案 0 :(得分:2)
The correct solution is to use a shared persistent database for your application instances. Configuring TCP-based container-to-container routing would be far more complicated, and still leave you with a solution that is not resilient.