Docs Home / Compass / Connect / Advanced Options

Advanced Connection Tab高级连接选项卡

The Advanced connection tab provides additional connection options for your deployment. “高级”连接选项卡为您的部署提供了其他连接选项。These options can be used with the General, Authentication, TLS / SSL, and Proxy / SSH Tunnel connection options.这些选项可以与常规身份验证TLS/SSL代理/SSH隧道连接选项一起使用。

Procedure过程

1

Open the New Connection modal.打开“新建连接”模式。

In the bottom panel of the Connections Sidebar, click Add New Connection to open the New Connection modal.在“连接”侧栏的底部面板中,单击“添加新连接”以打开“新建连接”模式。

If you already have connections listed in the Connections Sidebar, click the icon on the top right of the sidebar to open the New Connection modal.如果您已经在“连接”侧边栏中列出了连接,请单击侧栏右上角的图标以打开“新连接”模式。

2

Click Advanced Connection Options.单击“高级连接选项”。

New Advanced Connection Options
3

Click the Advanced tab.单击“高级”选项卡。

(Optional) Select a Read Preference from the following options:(可选)从以下选项中选择“读取首选项”:

Read Preference读取首选项Description描述
PrimaryDefault mode. All operations read from the current replica set primary. If the primary is unavailable, the operation fails.默认模式。从当前副本集主副本读取的所有操作。如果主服务器不可用,则操作失败。
Primary PreferredOperations read from the primary unless the primary is unavailable. If the primary is unavailable, operations read from secondary members.从主服务器读取操作,除非主服务器不可用。如果主成员不可用,则从辅助成员读取操作。
SecondaryAll operations read from the secondary members of the replica set. If the secondary is unavailable, the operation fails.从副本集的辅助成员读取的所有操作。如果辅助设备不可用,则操作失败。
Secondary PreferredOperations read from the secondary unless the secondary is unavailable. If the secondary is unavailable, operations read from the primary on sharded clusters.从次服务器读取操作,除非次服务器不可用。如果辅助服务器不可用,则在分片集群上从主服务器读取操作。
Nearest

Operations read from a random eligible replica set member, irrespective of whether that member is a primary or secondary, based on a specified latency threshold. The operation considers the following when calculating latency:根据指定的延迟阈值,从随机符合条件的副本集成员读取操作,无论该成员是主成员还是次成员。计算延迟时,操作会考虑以下因素:

Additional Optional Fields其他可选字段

Field字段Description描述
Replica Set Name副本集名称(Optional) Name of replica set.(可选)副本集的名称。
Default Authentication Database默认身份验证数据库(Optional) Authentication database used when authSource is not specified. For more information, see Authentication Options.(可选)未指定authSource时使用的身份验证数据库。有关详细信息,请参阅身份验证选项
URI OptionsURI选项Additional options to customize your connection. You specify these options as key-value pairs, and Compass automatically adds the key-value pairs to the connection string. For more information, see Connection String Options.自定义连接的其他选项。将这些选项指定为键值对,Compass会自动将键值对添加到连接字符串中。有关更多信息,请参阅连接字符串选项
4

Click Connect.单击“连接”。

Tip

To disconnect from your deployment, see Disconnect from MongoDB.要断开与部署的连接,请参阅断开与MongoDB的连接

Example示例

The following example specifies a connection with a read preference of Secondary Preferred in the Advanced tab. The Secondary Preferred read preference prevents queries from overloading the primary node.以下示例在“高级”选项卡中指定了一个读取首选项为“次要首选”的连接。“次要首选”读取首选项可防止查询使主节点过载。

Screenshot of Compass configured to connect with read preference of secondary preferred