跳到主要内容
版本:BYOC 开发指南

连接集群

本文介绍如何连接到 Zilliz Cloud 集群。

开始前

请确保已完成以下步骤:

📘说明

如果您更倾向于使用 RESTful API 而不是 SDK,需注意由于 HTTP 协议的单向通信模式,无法建立持续的连接。

连接到集群

集群启动后,通过集群公共 Endpoint 和 Token 连接到集群。

  • 公共 Endpoint:您可以通过 Zilliz Cloud web 控制台获取该信息。前往目标集群的集群详情页。在连接信息卡片上,复制集群的公共 Endpoint。

    connection-info-cn

  • **Token:**可以是 API 密钥或由用户名和密码组成的集群凭证

以下示例展示如何连接至集群。

# Connect using a MilvusClient object
from pymilvus import MilvusClient
CLUSTER_ENDPOINT="YOUR_CLUSTER_ENDPOINT" # Set your cluster endpoint
TOKEN="YOUR_CLUSTER_TOKEN" # Set your token

# Initialize a MilvusClient instance
# Replace uri and token with your own
client = MilvusClient(
uri=CLUSTER_ENDPOINT, # Cluster endpoint obtained from the console
token=TOKEN # a colon-separated cluster username and password
)