在目錄 (例如 Apache Iceberg REST 目錄或 Apache Hive 目錄) 中建立命名空間,有助於在 Lakehouse 執行階段目錄中整理資料表。
事前準備
- 請參閱「關於 Lakehouse 執行階段目錄」,瞭解 Lakehouse 執行階段目錄的運作方式和服務限制。
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles. - Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
Verify that billing is enabled for your Google Cloud project.
Enable the BigLake API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM
role (roles/serviceusage.serviceUsageAdmin), which
contains the serviceusage.services.enable permission. Learn how to grant
roles.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
Verify that billing is enabled for your Google Cloud project.
Enable the BigLake API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM
role (roles/serviceusage.serviceUsageAdmin), which
contains the serviceusage.services.enable permission. Learn how to grant
roles.
必要的角色
如要取得建立命名空間所需的權限,請要求管理員在專案中授予您下列 IAM 角色:
-
全部:
- BigLake 管理員 (
roles/biglake.admin) - 儲存空間管理員 (
roles/storage.admin)
- BigLake 管理員 (
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
建立命名空間
在目錄中建立命名空間。
注意事項
建立命名空間時,您可以選擇指定要與命名空間建立關聯的 Cloud Storage 值區或路徑:
- 多值區 (
bl://) (建議):只要自訂位置位於目錄允許的位置 (default_location或restricted_locations),您就可以設定任何自訂位置。如果未指定位置,系統會在目錄的預設位置 (例如gs://{default_location}/{namespace_name}) 下建立命名空間。 單一 bucket (
gs://):系統會自動從目錄的單一 bucket 繼承命名空間位置。
控制台
在 Google Cloud 控制台中開啟「Lakehouse」Lakehouse頁面。
選取現有目錄,或建立目錄 (如果沒有的話)。
在選單列中,按一下「+ 建立命名空間」。
在「命名空間名稱」欄位中,輸入命名空間的專屬名稱。
在「位置」部分,視需要指定要與命名空間建立關聯的 Cloud Storage 值區或路徑。位置與倉庫 bucket 相符。
點選「建立」。
系統會建立命名空間,並顯示在目錄詳細資料清單中。
gcloud
在多 bucket (bl://) 目錄中建立命名空間 (建議做法)
如要在多值區目錄中建立命名空間 (可選擇指定自訂位置),請執行 gcloud biglake iceberg namespaces create 指令並加上 --properties 旗標:
gcloud biglake iceberg namespaces create NAMESPACE_NAME \ --project="PROJECT_ID" \ --catalog="CATALOG_ID" \ [--properties="location=LOCATION"]
更改下列內容:
NAMESPACE_NAME:命名空間名稱。PROJECT_ID:您的 Google Cloud 專案 ID。CATALOG_ID:目錄 ID。LOCATION:(選用) 要與命名空間建立關聯的自訂 Cloud Storage bucket 或路徑 (例如gs://my-bucket/my-path)。
在單一 bucket (gs://) 目錄中建立命名空間
如要在單一 bucket 目錄中建立命名空間,請省略 --properties 旗標。命名空間位置會自動從目錄的單一 bucket 繼承。
gcloud biglake iceberg namespaces create NAMESPACE_NAME \ --project="PROJECT_ID" \ --catalog="CATALOG_ID"
REST
如要使用 REST API 建立命名空間,請對 CreateIcebergNamespace 端點發出 POST 要求:
POST /iceberg/v1/restcatalog/v1/projects/PROJECT_ID/catalogs/CATALOG_ID/namespaces
要求主體必須包含有效的 Iceberg CreateNamespaceRequest JSON 酬載,定義命名空間 ID 和屬性:
{
"namespace": [
"NAMESPACE_NAME"
],
"properties": {
"location": "LOCATION"
}
}
更改下列內容:
PROJECT_ID:您的 Google Cloud 專案 ID。CATALOG_ID:目錄 ID。NAMESPACE_NAME:命名空間名稱。LOCATION:(選用) 要與命名空間建立關聯的自訂 Cloud Storage bucket 或路徑 (例如gs://my-bucket/my-path)。
後續步驟
- 瞭解如何管理命名空間 ACL。