[Account] Account / DB / Cluster table === ###### tags: `Slurm / Account` ###### tags: `Slurm`, `HPC`, `Linux`, `Slinky`, `SlinkyProject`, `slurmdb`, `Account`, `sacctmgr`, `Cluster`, `cluster_table`, `Association` <br> [TOC] <br> ## Cluster 表格 (cluster_table) | 欄位名稱 | 資料型別 | 限制條件 | 說明 | |---------|---------|---------|------| | `creation_time` | `bigint unsigned` | `not null` | 建立時間戳記 | | `mod_time` | `bigint unsigned` | `default 0 not null` | 最後修改時間戳記 | | `deleted` | `tinyint` | `default 0` | 軟刪除標記 | | **`name`** | **`tinytext`** | **`not null`** | **Cluster 名稱(主鍵)** | | `id` | `smallint` | - | Cluster ID | | `control_host` | `tinytext` | `not null default ''` | 控制節點主機名稱 | | `control_port` | `int unsigned` | `not null default 0` | 控制節點連接埠 | | `last_port` | `int unsigned` | `not null default 0` | 最後使用的連接埠 | | `rpc_version` | `smallint unsigned` | `not null default 0` | RPC 版本 | | `classification` | `smallint unsigned` | `default 0` | 分類 | | `dimensions` | `smallint unsigned` | `default 1` | 維度 | | `flags` | `int unsigned` | `default 0` | 旗標設定 | | `federation` | `tinytext` | `not null` | 所屬聯邦名稱 | | `features` | `text` | `not null default ''` | 特性 | | `fed_id` | `int unsigned` | `default 0 not null` | 聯邦 ID | | `fed_state` | `smallint unsigned` | `not null` | 聯邦狀態 | - **索引鍵:** `PRIMARY KEY (name(42))` <br> --- ## 每個 Cluster 有各自的 Association 表格 從原始碼可以看到(`accounting_storage_mysql.c:1136-1190`): > https://github.com/SchedMD/slurm/blob/master/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c#L1136-L1190 ```c extern int create_cluster_assoc_table( mysql_conn_t *mysql_conn, char *cluster_name) { // ... 定義 assoc_table_fields ... char table_name[200]; // 表格命名格式:"{cluster_name}_assoc_table" snprintf(table_name, sizeof(table_name), "\"%s_%s\"", cluster_name, assoc_table); if (mysql_db_create_table(mysql_conn, table_name, assoc_table_fields, ", primary key (id_assoc), " "unique index udex (user(42), acct(42), " "`partition`(42)))") == SLURM_ERROR) return SLURM_ERROR; return SLURM_SUCCESS; } ``` #### 表格命名規則 - **格式**: `{cluster_name}_assoc_table` - **範例**: - Cluster 名稱為 `hpc1` → Association 表格為 `hpc1_assoc_table` - Cluster 名稱為 `production` → Association 表格為 `production_assoc_table` #### 其他 Cluster 專屬表格 除了 Association 表格外,每個 cluster 還有其他專屬表格: | 表格名稱格式 | 說明 | |-------------|------| | `{cluster_name}_assoc_table` | Association 關聯表 | | `{cluster_name}_assoc_day_table` | 每日 Association 使用量統計 | | `{cluster_name}_assoc_hour_table` | 每小時 Association 使用量統計 | | `{cluster_name}_assoc_month_table` | 每月 Association 使用量統計 | | `{cluster_name}_job_table` | 作業記錄表 | | `{cluster_name}_step_table` | 作業步驟表 | | `{cluster_name}_event_table` | 事件記錄表 | | `{cluster_name}_wckey_table` | WCKey 表 | | ... | 其他相關表格 | <br> --- ## Notes 1. **Cluster name 存放在全局的 `cluster_table` 的 `name` 欄位中** 2. **每個 cluster 有各自獨立的 Association 表格**,命名格式為 `{cluster_name}_assoc_table` 3. 這種設計允許: - 在同一個 Slurm 資料庫中管理多個獨立的 cluster - 每個 cluster 有自己的 accounting 資料空間 - 透過 `cluster_table` 統一管理所有 cluster 的基本資訊 <br> {%hackmd vaaMgNRPS4KGJDSFG0ZE0w %}