了解rgw内部实现的时候发现,bucket有两种metadata,一个叫bucket,一个叫bucket instance
通过下面命令可以查看到metadata的类型
# radosgw-admin metadata list
[
"bucket",
"bucket.instance",
"otp",
"user"
]
实际bucket是以bucket名称命名的metadata,而bucket instance是以bucket内部id命名的metadata。
# radosgw-admin metadata list bucket
[
"abc",
"test1",
"u2dir1",
"image",
"test",
"test2",
"u2dir2",
"file",
"123"
]
# radosgw-admin metadata list bucket.instance
[
"123:92a8697d-a145-44de-acd3-10f4147b07e2.44697.2",
"test2:92a8697d-a145-44de-acd3-10f4147b07e2.44697.3",
"image:92a8697d-a145-44de-acd3-10f4147b07e2.44697.4",
"abc:92a8697d-a145-44de-acd3-10f4147b07e2.44785.1",
"file:92a8697d-a145-44de-acd3-10f4147b07e2.44697.5",
"test1:92a8697d-a145-44de-acd3-10f4147b07e2.44697.1",
"test:92a8697d-a145-44de-acd3-10f4147b07e2.44294.1",
"u2dir2:92a8697d-a145-44de-acd3-10f4147b07e2.44294.3",
"u2dir1:92a8697d-a145-44de-acd3-10f4147b07e2.44294.2"
]
bucket对应内部的类型是RGWBucketEntryPoint,其只保存的bucket概要信息。
bucket instance对应内部的数据类型是RGWBucketInfo,其保存的是bucket的详细信息。
# radosgw-admin metadata get bucket:test
{
"key": "bucket:test",
"ver": {
"tag": "_G_IFZpA7rdMI9sa7cXe1BJk",
"ver": 1
},
"mtime": "2020-08-18 02:36:02.676678Z",
"data": {
"bucket": {
"name": "test",
"marker": "92a8697d-a145-44de-acd3-10f4147b07e2.44294.1",
"bucket_id": "92a8697d-a145-44de-acd3-10f4147b07e2.44294.1",
"tenant": "",
"explicit_placement": {
"data_pool": "",
"data_extra_pool": "",
"index_pool": ""
}
},
"owner": "user1",
"creation_time": "2020-08-18 02:36:00.161773Z",
"linked": "true",
"has_bucket_info": "false"
}
}
# radosgw-admin metadata get bucket.instance:test:92a8697d-a145-44de-acd3-10f4147b07e2.44294.1
{
"key": "bucket.instance:test:92a8697d-a145-44de-acd3-10f4147b07e2.44294.1",
"ver": {
"tag": "_CwY-Mon5aKwmDK2pzuuJwnR",
"ver": 1
},
"mtime": "2020-08-18 02:36:02.673609Z",
"data": {
"bucket_info": {
"bucket": {
"name": "test",
"marker": "92a8697d-a145-44de-acd3-10f4147b07e2.44294.1",
"bucket_id": "92a8697d-a145-44de-acd3-10f4147b07e2.44294.1",
"tenant": "",
"explicit_placement": {
"data_pool": "",
"data_extra_pool": "",
"index_pool": ""
}
},
"creation_time": "2020-08-18 02:36:00.161773Z",
"owner": "user1",
"flags": 0,
"zonegroup": "a2c80c4d-1687-457a-a454-e121c3038e25",
"placement_rule": "default-placement",
"has_instance_obj": "true",
"quota": {
"enabled": false,
"check_on_raw": false,
"max_size": -1,
"max_size_kb": 0,
"max_objects": -1
},
"num_shards": 0,
"bi_shard_hash_type": 0,
"requester_pays": "false",
"has_website": "false",
"swift_versioning": "false",
"swift_ver_location": "",
"index_type": 0,
"mdsearch_config": [],
"reshard_status": 0,
"new_bucket_instance_id": ""
},
"attrs": [
{
"key": "user.rgw.acl",
"val": "AgKBAAAAAwISAAAABQAAAHVzZXIxBQAAAFVzZXIxBANjAAAAAQEAAAAFAAAAdXNlcjEPAAAAAQAAAAUAAAB1c2VyMQUDNgAAAAICBAAAAAAAAAAFAAAAdXNlcjEAAAAAAAAAAAICBAAAAA8AAAAFAAAAVXNlcjEAAAAAAAAAAAAAAAAAAAAA"
}
]
}
}
bucket和bucket instance都保存在meta pool的 root 命名空间中
# rados ls -p default.rgw.meta -N root
abc
.bucket.meta.123:92a8697d-a145-44de-acd3-10f4147b07e2.44697.2
test1
.bucket.meta.test2:92a8697d-a145-44de-acd3-10f4147b07e2.44697.3
.bucket.meta.test5:92a8697d-a145-44de-acd3-10f4147b07e2.61333.1
.bucket.meta.image:92a8697d-a145-44de-acd3-10f4147b07e2.44697.4
.bucket.meta.test5-2:92a8697d-a145-44de-acd3-10f4147b07e2.105801.1
.bucket.meta.abc:92a8697d-a145-44de-acd3-10f4147b07e2.44785.1
test5-1
.bucket.meta.file:92a8697d-a145-44de-acd3-10f4147b07e2.44697.5
.bucket.meta.test1:92a8697d-a145-44de-acd3-10f4147b07e2.44697.1
.bucket.meta.test5-1:92a8697d-a145-44de-acd3-10f4147b07e2.62015.1
image
test5
.bucket.meta.test:92a8697d-a145-44de-acd3-10f4147b07e2.44294.1
test
test5-2
test2
总结
bucket以bucket name作为名称,保存的bucket概要信息,其中包含bucket内部ID。
bucket instance以bucket内部id命名,保存bucket的详细信息。
二者都保存在<.rgw.meta> pool的 root命名空间中。
至于为什么这么设计,还没有完全理解。如果bucket名称是唯一,为什么还要有一个内部ID?