您的位置:首页 > 其它

Ceph对象存储测试中遇到的bucket名称的大小写问题

2017-05-16 11:20 316 查看

Ceph对象存储测试中遇到的bucket名称的大小写问题

在安装好Ceph对象存储时,就遇到过s3cmd创建bucket时名称的问题导致创建不成功的问题,具体情况是这样的:

我在s3cmd中执行:

[root@ceph-client home]#s3cmd mb s3://my-test-bucket1

ERROR: [Errno -2] Name or service not known

ERROR: Connection Error: Error resolving a server hostname.

Please check the servers address specified in 'host_base', 'host_bucket', 'cloudfront_host', 'website_endpoint'

但是如果这样执行就通过了:

[root@ceph-client home]# s3cmd mb s3://My-test-bucket1
Bucket 's3://My-test-bucket1/' created

但是更加奇怪的是我使用python编写程序创建bucket时,却不是这种情况,而是恰好相反,不能创建带有大写字母的bucket:

#-- coding: utf-8 --

import boto

import boto.s3.connection

access_key = '2O3HASV93KW7QS920QF6'

secret_key = 'VK7kkbukQEu5Z2bRRy7kgIBa0rHsaRfsEZVvBRXH'

conn = boto.connect_s3(

        aws_access_key_id = access_key,

        aws_secret_access_key = secret_key,

        host = 'rgw-node1.up.com',port = 7480,

        is_secure=False,               # uncomment if you are not using ssl

        calling_format = boto.s3.connection.OrdinaryCallingFormat(),

        )

        

bucket = conn.create_bucket('My-bucket11')

执行结果:

[root@ceph-client home]# python connCeph.py 

Traceback (most recent call last):

  File "connCeph.py", line 18, in <module>

    bucket = conn.create_bucket('My-bucket11')

  File "/usr/lib/python2.7/site-packages/boto-2.46.1-py2.7.egg/boto/s3/connection.py", line 603, in create_bucket

    check_lowercase_bucketname(bucket_name)

  File "/usr/lib/python2.7/site-packages/boto-2.46.1-py2.7.egg/boto/s3/connection.py", line 59, in check_lowercase_bucketname

    raise BotoClientError("Bucket names cannot contain upper-case " \

boto.exception.BotoClientError: BotoClientError: Bucket names cannot contain upper-case characters when using either the sub-domain or virtual hosting calling format.

很明显错误中已经提示红色标识,python会去检查小写bucket名称,那么我使用python创建了小写的名称的bucket

        

bucket = conn.create_bucket('my-new-bucket11')

这是可以成功的。

那么问题又来了,当我ls,put等上cmd命令去操作python创建的bucket时报了以下错误:

[root@ceph-client home]# s3cmd ls s3://my-new-bucket1

ERROR: [Errno -2] Name or service not known

ERROR: Connection Error: Error resolving a server hostname.

Please check the servers address specified in 'host_base', 'host_bucket', 'cloudfront_host', 'website_endpoint'

[root@ceph-client home]# 

不知道为什么会这样?

由于想到需要使用s3cmd去查询比较方便,或者为了能解决这个问题或者至少找到一个替换的方案,于是,我使用了“_”来命名,此时皆大欢喜:

[root@ceph-client home]# s3cmd mb s3://my_test_15

Bucket 's3://my_test_15/' created

python程序中:

bucket = conn.create_bucket('my_bucket15')

[root@ceph-client home]# s3cmd ls

2017-05-16 03:17  s3://my_bucket15

2017-05-16 03:16  s3://my_test_15

目前我只能解决到这里,因为书本上或者网上其他的帖子中安装好s3cmd,连接ceph对象网关时,创建bucket都是s3cmd mb s3://my-new-bucket1,

所以我很疑惑,可能需要更加理解.s3cfg这个文件的含义吧。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ceph s3cmd bucket