什么是subdomain方式
rgw提供s3 rest接口進(jìn)行數(shù)據(jù)讀寫(xiě),有兩種方式:
subdomain方式:<bucket>.example.com
ordinary方式:example.com/<bucket>
環(huán)境
假設(shè)rgw所在機(jī)器ip 為10.0.0.1
用另一臺(tái)機(jī)器運(yùn)行s3-tests,假設(shè)ip為10.0.0.2
步驟
- 為rgw配置rgw dns name配置項(xiàng)
修改ceph.conf,增加rgw dns name = example.com配置項(xiàng),然后重啟radosgw - 為s3-tests和s3cmd所在機(jī)器配置example.com的泛域名解析
$ yum install dnsmasq
$ vim /etc/dnsmasq.conf
$ cat /etc/dnsmasq.conf
listen-address=127.0.0.1
address=/.example.com/10.0.0.1
cache-size=2048
resolv-file=/etc/dnsmasq.resolv.conf
$ cp /etc/resolv.conf /etc/dnsmasq.resolv.conf
$ vim /etc/resolv.conf
$ cat /etc/resolv.conf
nameserver 127.0.0.1
systemctl start dnsmasq
nscd -i hosts
# test
curl a.example.com
curl example.com
- 配置s3cmd
在.s3cfg中修改兩項(xiàng):
host_base = example.com
# 注意:s不能忽略
host_bucket = %(bucket)s.example.com
- 配置s3-tests
修改S3TEST_CONF對(duì)應(yīng)的配置文件
[DEFAULT]
host = example.com
port = 80
is_secure = no
calling_format = subdomain
[fixtures]
# 注意:bucket的完整name一定不能以'-'結(jié)尾
# 在這里,如果s3tests不能正確為bucket prefix追加結(jié)尾,
# 會(huì)導(dǎo)致s3-tests-{random}-.example的域名無(wú)法解析。
bucket prefix = s3-tests-{random}-