共計 2129 個字符,預計需要花費 6 分鐘才能閱讀完成。
bucket 刪除中的細節有哪些,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
問題描述
社區群里有人說刪除 bucket 以后還有部分數據殘留,用的 ceph 10.2.x 版本做的驗證
測試用例
from boto.s3.connection import S3Connection
import boto
conn = boto.connect_s3(
aws_access_key_id = ,
aws_secret_access_key = ,
host = s3.cephbook.com ,
port = 80,
is_secure = False,
calling_format = boto.s3.connection.OrdinaryCallingFormat(),
)
bucket = conn.create_bucket(foo)
#bucket.delete()
刪除前
root@demohost:/home/user# rados ls -p rgw.root
.bucket.meta.foo:70af9a54-20bb-480b-92f4-cbdeef0b775c.217357.1
刪除后
root@demohost:/home/user# rados ls -p rgw.root
.bucket.meta.foo:70af9a54-20bb-480b-92f4-cbdeef0b775c.217357.1
# 殘留
原因分析
對 meta file 的刪除操作需要根據是否開啟了多集群同步來決定
# src/rgw/rgw_rados.cc
op_ret = store- delete_bucket(s- bucket, ot);# 入口
....
/* if the bucket is not synced we can remove the meta file */
if (!is_syncing_bucket_meta(bucket)) {
RGWObjVersionTracker objv_tracker;
string entry = bucket.get_key();
r= rgw_bucket_instance_remove_entry(this, entry, objv_tracker);
if (r 0) {
return r;
}
/* remove bucket index objects*/
map int, string ::const_iterator biter;
for (biter = bucket_objs.begin(); biter != bucket_objs.end(); ++biter) { index_ctx.remove(biter- second);
}
}
滿足下面 4 種情況是不會進行 meta file 的刪除操作
當前 period 不是最新版本 zonegroup 為非 master zonegroup
當前集群只有單個 zonegroup,且只有一個 zone 當前 zone 不是 master zone
/**
* Check to see if the bucket metadata could be synced
* bucket: the bucket to check
* Returns false is the bucket is not synced
*/
bool RGWRados::is_syncing_bucket_meta(rgw_bucket bucket)
/* no current period */
if (current_period.get_id().empty()) {
return false;
}
/* zonegroup is not master zonegroup */
if (!get_zonegroup().is_master) {
return false;
}
/* single zonegroup and a single zone */
if (current_period.is_single_zonegroup(cct, this) get_zonegroup().zones.size() == 1) {
return false;
}
/* zone is not master */
if (get_zonegroup().master_zone.compare(zone_public_config.id) != 0) {
return false;
}
return true;
}
解決方案
rados 命令手工刪除對應的 obj,但是要注意相應的 bucket 一定是不再需要的,最好是在多個集群上確認最終操作,確保數據一致性。
修改集群配置,滿足上面 4 點需求之一。
最后非標準操作去刪除 bucket 可能破壞底層數據一致性,起手無悔,一定要慎重。
看完上述內容,你們掌握 bucket 刪除中的細節有哪些的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注丸趣 TV 行業資訊頻道,感謝各位的閱讀!
正文完