使用 MongoDB.Driver 库的 Cosmos DB 故障转移
Cosmos DB failover with MongoDB.Driver library
我有一个应用程序正在使用 MongoDB.Driver 库 (2.7.3) 连接到 Azure 上的 CosmosDB。 Cosmos 帐户设置为复制到另一个区域的辅助帐户以进行灾难恢复。我 运行 遇到的一个问题是,当我们对 Cosmos 帐户进行故障转移时,我们会失去连接并在写入数据时出现以下错误:
A timeout occured after 30000ms selecting a server using
CompositeServerSelector{ Selectors =
MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector,
LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000
} }. Client view of cluster state is { ClusterId : "1", ConnectionMode
: "Automatic", Type : "ReplicaSet", State : "Connected", Servers : [{
ServerId: "{ ClusterId : 1, EndPoint :
"Unspecified/myCosmosAccount.documents.azure.com:10255" }",
EndPoint: "Unspecified/myCosmosAccount.documents.azure.com:10255",
State: "Connected", Type: "ReplicaSetOther", Tags: "{ region : North
Europe }", WireVersionRange: "[0, 2]" }] }
我知道可以在 MongoDB 连接字符串中指定多个服务器,但是我不清楚如何使用只有一个帐户端点的 Cosmos DB 来实现这一点。我当前的连接字符串是这样的:
mongodb://myCosmosAccount:Key@myCosmosAccount.documents.azure.com:10255/myCosmosDatabase?ssl=true
这是否可以使用此库,或者我是否需要切换到使用 Cosmos DB SDK 来改进灾难恢复?
我需要添加:replicaSet=globaldb
到我的连接字符串的末尾,所以它现在看起来像这样:
mongodb://myCosmosAccount:Key@myCosmosAccount.documents.azure.com:10255/myCosmosDatabase?ssl=true&replicaSet=globaldb
我有一个应用程序正在使用 MongoDB.Driver 库 (2.7.3) 连接到 Azure 上的 CosmosDB。 Cosmos 帐户设置为复制到另一个区域的辅助帐户以进行灾难恢复。我 运行 遇到的一个问题是,当我们对 Cosmos 帐户进行故障转移时,我们会失去连接并在写入数据时出现以下错误:
A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "Automatic", Type : "ReplicaSet", State : "Connected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/myCosmosAccount.documents.azure.com:10255" }", EndPoint: "Unspecified/myCosmosAccount.documents.azure.com:10255", State: "Connected", Type: "ReplicaSetOther", Tags: "{ region : North Europe }", WireVersionRange: "[0, 2]" }] }
我知道可以在 MongoDB 连接字符串中指定多个服务器,但是我不清楚如何使用只有一个帐户端点的 Cosmos DB 来实现这一点。我当前的连接字符串是这样的:
mongodb://myCosmosAccount:Key@myCosmosAccount.documents.azure.com:10255/myCosmosDatabase?ssl=true
这是否可以使用此库,或者我是否需要切换到使用 Cosmos DB SDK 来改进灾难恢复?
我需要添加:replicaSet=globaldb
到我的连接字符串的末尾,所以它现在看起来像这样:
mongodb://myCosmosAccount:Key@myCosmosAccount.documents.azure.com:10255/myCosmosDatabase?ssl=true&replicaSet=globaldb