Gli*_*ide 6 cassandra datastax-enterprise datastax-java-driver
如果我有一个多DC集群,DC1和DC2,其中DC2仅用于故障转移.在客户端的驱动程序中,我使用域名定义联系点(foo1.net, foo2.net, and foo3.net).我有foo*指向DC1,如果我检测到任何DC1错误,我将使DNS路由foo*指向DC2.
这种方法似乎在纸上工作,但它实际上会起作用吗?这种方法有什么问题吗?
对于 DataStax Java 驱动程序 3.x,这将不起作用,因为仅在Cluster实例化开始时评估 DNS。
提供的联系点通过 InetAddress.getAllByName 使用 DNS进行解析Cluster.Builder.addContactPoint:
public Builder addContactPoint(String address) {
// We explicitly check for nulls because InetAdress.getByName() will happily
// accept it and use localhost (while a null here almost likely mean a user error,
// not "connect to localhost")
if (address == null)
throw new NullPointerException();
try {
addContactPoints(InetAddress.getAllByName(address));
return this;
} catch (UnknownHostException e) {
throw new IllegalArgumentException("Failed to add contact point: " + address, e);
}
}
Run Code Online (Sandbox Code Playgroud)
如果 DNS 在 的生命周期内发生更改Cluster,驱动程序将不会意识到这一点,除非您构造一个新Cluster.Builder实例并Cluster从中创建一个新实例。
我更喜欢将数据中心故障转移推到应用程序范围之外并进入架构的更高级别的设计。您不应让客户端应用程序负责故障转移,而应运行位于每个 C* 数据中心的客户端实例。当数据中心不可用时,您的应用程序负载均衡器/路由器/DNS 可以将流量引导到其他数据中心中的应用程序实例。
| 归档时间: |
|
| 查看次数: |
91 次 |
| 最近记录: |