在 Google 云平台中将存储 class 从多区域更改为 Coldline
Changing Storage class from Multi-Regional to Coldline in Google Cloud Platform
我刚刚结束了 Google Cloud Platform 的 1 年免费试用期,现在我需要付费。
当我设置我的第一个项目时,我似乎将其设置为多区域。我只会在家里发生灾难性故障时使用 Google 云存储,我会丢失内部和外部硬盘驱动器上的数据(即火灾等)。我相信对于这种类型的备份,我只需要 Coldline 存储。我确实将我的项目更改为 Coldline,但它看起来只更改了新数据,而不是原始存储的数据,因为我仍在为多区域存储付费。
据我了解,我必须通过使用 "gsutil rewrite -s [STORAGE_CLASS] gs://[PATH_TO_OBJECT]"
覆盖数据或通过对象生命周期管理来更改对象存储 Class。我也不知道该怎么做,所以我需要帮助(我什至不确定在哪里输入这些命令或使用哪种方法(我不是程序员!!))。
我还在另一个 post 中看到我的 gsutil 命令需要最新的 4.22 或更高版本。我该如何检查?我还在这个 post 中看到 [PATH_TO_OBJECT] 是我的桶。我看到项目名称、项目 ID 和项目编号。我的存储桶的该字段中使用了哪些(如果有)?
感谢您的帮助
I also saw in another post that my gsutil command needs to up to date
4.22 or higher. How do I check this??
获取 gsutil 版本:
gsutil version
更新包含 gsutil 的 Cloud SDK:
Windows:
使用管理员权限打开命令提示符
gcloud components update
Linux:
gcloud components update
I see a Project Name, Project ID, and Project number. Which of these
(if any) are used in that field for My Bucket.
使用PROJECT_ID。获取您有权访问的项目列表。此命令将列出每个项目。
gcloud projects list
查看哪个是您的默认项目:
gcloud config list project
如果默认项目为空或错误,请使用以下命令。
设置默认项目:
gcloud config set project [PROJECT_ID]
From what I understand, I have to change the Object Storage Class
either my overwriting the data
假设您的存储桶名称是 mybucket
。
第 1 步:更改存储桶的默认存储 class:
gsutil defstorageclass set coldline gs://mybucket
第 2 步:手动更改每个对象的存储 class。如果您只想 select 几个文件,这是一个选项。
gsutil rewrite -s coldline gs://mybucket/objectname
第 3 步:验证现有的生命周期策略。如果存在现有策略,请相应地更改步骤 4。
gsutil lifecycle get gs://mybucket
第 4 步:更改存储桶的生命周期。此策略会将超过 7 天的所有文件移至冷线存储。
POLICY(写入 lifecycle.json):
{
"lifecycle": {
"rule": [
{
"action": {
"type": "SetStorageClass",
"storageClass": "COLDLINE"
},
"condition": {
"age": 7,
"matchesStorageClass": [
"MULTI_REGIONAL",
"STANDARD",
"DURABLE_REDUCED_AVAILABILITY"
]
}
}
]
}
}
命令:
gsutil lifecycle set lifecycle.json gs://mybucket
我刚刚结束了 Google Cloud Platform 的 1 年免费试用期,现在我需要付费。
当我设置我的第一个项目时,我似乎将其设置为多区域。我只会在家里发生灾难性故障时使用 Google 云存储,我会丢失内部和外部硬盘驱动器上的数据(即火灾等)。我相信对于这种类型的备份,我只需要 Coldline 存储。我确实将我的项目更改为 Coldline,但它看起来只更改了新数据,而不是原始存储的数据,因为我仍在为多区域存储付费。
据我了解,我必须通过使用 "gsutil rewrite -s [STORAGE_CLASS] gs://[PATH_TO_OBJECT]"
覆盖数据或通过对象生命周期管理来更改对象存储 Class。我也不知道该怎么做,所以我需要帮助(我什至不确定在哪里输入这些命令或使用哪种方法(我不是程序员!!))。
我还在另一个 post 中看到我的 gsutil 命令需要最新的 4.22 或更高版本。我该如何检查?我还在这个 post 中看到 [PATH_TO_OBJECT] 是我的桶。我看到项目名称、项目 ID 和项目编号。我的存储桶的该字段中使用了哪些(如果有)?
感谢您的帮助
I also saw in another post that my gsutil command needs to up to date 4.22 or higher. How do I check this??
获取 gsutil 版本:
gsutil version
更新包含 gsutil 的 Cloud SDK:
Windows: 使用管理员权限打开命令提示符
gcloud components update
Linux:
gcloud components update
I see a Project Name, Project ID, and Project number. Which of these (if any) are used in that field for My Bucket.
使用PROJECT_ID。获取您有权访问的项目列表。此命令将列出每个项目。
gcloud projects list
查看哪个是您的默认项目:
gcloud config list project
如果默认项目为空或错误,请使用以下命令。
设置默认项目:
gcloud config set project [PROJECT_ID]
From what I understand, I have to change the Object Storage Class either my overwriting the data
假设您的存储桶名称是 mybucket
。
第 1 步:更改存储桶的默认存储 class:
gsutil defstorageclass set coldline gs://mybucket
第 2 步:手动更改每个对象的存储 class。如果您只想 select 几个文件,这是一个选项。
gsutil rewrite -s coldline gs://mybucket/objectname
第 3 步:验证现有的生命周期策略。如果存在现有策略,请相应地更改步骤 4。
gsutil lifecycle get gs://mybucket
第 4 步:更改存储桶的生命周期。此策略会将超过 7 天的所有文件移至冷线存储。
POLICY(写入 lifecycle.json):
{
"lifecycle": {
"rule": [
{
"action": {
"type": "SetStorageClass",
"storageClass": "COLDLINE"
},
"condition": {
"age": 7,
"matchesStorageClass": [
"MULTI_REGIONAL",
"STANDARD",
"DURABLE_REDUCED_AVAILABILITY"
]
}
}
]
}
}
命令:
gsutil lifecycle set lifecycle.json gs://mybucket