管理计算池

计算池是一个或多个虚拟机 (VM) 节点的集合,Snowflake 会在这些节点上运行您的 Snowpark Container Services 作业和服务。

For more information about compute pools, see Snowpark Container Services: Working with compute pools.

本主题介绍如何使用服务执行以下任务:

For common operations, such as listing or dropping, Snowflake CLI uses snow object commands as described in Managing Snowflake objects.

创建计算池

To create a compute pool named “pool_1” composed of two CPUs with 4 GB of memory, enter a spcs pool create command similar to the following:

snow spcs compute-pool create "pool_1" --min-nodes 2 --max-nodes 2 --family "CPU_X64_XS"

For more information about instance families, see the SQL CREATE COMPUTE POOL command.

根据项目定义创建计算池

You can create a compute pool from a snowflake.yml project definition file and then executing the snow spcs compute-pool deploy command.

The following shows a sample snowflake.yml project definition file:

definition_version: 2
entities:
  my_compute_pool:
    type: compute-pool
    identifier:
      name: my_compute_pool
    min_nodes: 1
    max_nodes: 2
    instance_family: CPU_X64_XS
    auto_resume: true
    initially_suspended: true
    auto_suspend_seconds: 60
    comment: "My compute pool"
    tags:
      - name: my_tag
        value: tag_value

下表描述了计算池项目定义的属性。

Compute pool project definition properties

PropertyDefinition

type

requiredstring

Must be compute-pool.

identifier

optionalstring

实体的 Snowflake 标识符。该值可以采用以下形式:

  • 字符串标识符文本
identifier: my-compute-pool

Both unquoted and quoted identifiers are supported. To use quoted identifiers, include the surrounding quotes in the YAML value (for example, "My Compute Pool").

  • 对象
identifier:
  name: my-compute-pool
  schema: my-schema # optional
  database: my-db # optional

Note

An error occurs if you specify a schema or database and use a fully qualified name in the name property (such as mydb.schema1.my-app).

instance_family

requiredstring

Name of the instance family. For a list of available instance families, see the CREATE COMPUTE POOL INSTANCE_FAMILY parameter.

min_nodes

optionalstring

计算池的最小节点数。此值必须大于 0。

Default: 1

max_nodes

optionalint

Maximum number of nodes for the compute pool.

auto_resume

optionalboolean

在向计算池提交服务或作业时是否会自动恢复计算池。

Default: True

initially_suspended

optionalboolean

Whether the compute pool is created initially in the suspended state. If true, Snowflake doesn’t provision any nodes requested for the compute pool at the compute pool creation time.

Default: False

auto_suspend_seconds

optionalint

您希望 Snowflake 自动暂停计算池的不活动秒数。

Default: 3600

comment

optionalstring

Comments to associate with the compute pool.

tags

optionalTag sequence

Tag names and values for the compute pool. For more information, see Tag quotas

要创建计算池并将其部署到暂存区,请执行以下操作:

  1. 将当前目录更改为包含项目定义文件的目录。

  2. Run a snow spcs compute-pool deploy command similar to the following:

    snow spcs compute-pool deploy
    +---------------------------------------------------------------------+
    | key    | value                                                      |
    |--------+------------------------------------------------------------|
    | status | Compute pool MY_COMPUTE_POOL successfully created.         |
    +---------------------------------------------------------------------+

暂停和恢复计算池

Note

当前角色必须拥有计算池的 OPERATE 权限,才能暂停或恢复计算池。

要暂停计算池,请输入类似下面的命令:

snow spcs compute-pool suspend tutorial_compute_pool
+-------------------------------------------+
| key    | value                            |
|--------+----------------------------------|
| status | Statement executed successfully. |
+-------------------------------------------+

要恢复暂停的计算池,请输入类似下面的命令:

snow spcs compute-pool resume tutorial_compute_pool
+-------------------------------------------+
| key    | value                            |
|--------+----------------------------------|
| status | Statement executed successfully. |
+-------------------------------------------+

设置和取消设置计算池的属性或参数

Note

当前角色必须具有计算池的 MODIFY 权限才能设置属性。

要设置属性或参数,请输入类似下面的命令:

snow spcs compute-pool set tutorial_compute_pool --min-nodes 2 --max-nodes 4
+-------------------------------------------+
| key    | value                            |
|--------+----------------------------------|
| status | Statement executed successfully. |
+-------------------------------------------+

要将属性或参数重置为默认值,请输入类似下面的命令:

snow spcs compute-pool unset tutorial_compute_pool --auto-resume
+-------------------------------------------+
| key    | value                            |
|--------+----------------------------------|
| status | Statement executed successfully. |
+-------------------------------------------+

停止计算池中的所有服务

停止计算池会删除计算池上运行的所有服务,但不会停止计算池本身。

To stop a compute pool, enter a spcs compute-pool stop-all command similar to the following:

snow spcs compute-pool stop-all "pool_1"