搭建Ceph集群过程省略,参考如下:
https://blog.csdn.net/mengshicheng1992/article/details/120567117
1、安装RGW节点
在Deploy节点上安装RGW节点:
ceph-deploy install --rgw node1.ceph.local
ceph-deploy install --rgw node2.ceph.local
ceph-deploy install --rgw node3.ceph.local
2、初始化RGW节点
在Deploy节点上初始化RGW节点:
cd /root/cluster/
ceph-deploy rgw create node1.ceph.local
ceph-deploy rgw create node2.ceph.local
ceph-deploy rgw create node3.ceph.local
3、查看服务
在Deploy节点上查看服务:
curl http://node1.ceph.local:7480 -v
1、创建S3用户
在Deploy节点上创建S3用户:
radosgw-admin user create --uid="mengshicheng" --display-name="First User"
记录密钥
"access_key": "OBHEXZB5LUYYQ67USHGK",
"secret_key": "H9BQlVAPVZe6wOk3Za6YCOyhNuMQ5ndDCcA0THmW"
2、安装S3客户端
在Client节点上安装S3客户端:
yum -y install python-boto
3、测试S3接口
在Client节点上测试S3接口:
cat > s3.py << EOF
#_*_ coding:utf-8 _*_
import boto.s3.connection
access_key = 'OBHEXZB5LUYYQ67USHGK'
secret_key = 'H9BQlVAPVZe6wOk3Za6YCOyhNuMQ5ndDCcA0THmW'
# 新建S3连接
conn = boto.connect_s3(
aws_access_key_id = access_key,
aws_secret_access_key = secret_key,
host = 'node1.ceph.local', port=7480,
is_secure=False, calling_format = boto.s3.connection.OrdinaryCallingFormat(),
)
# 新建Bucket
bucket = conn.create_bucket('my-s3-bucket')
# 显示Bucket
for bucket in conn.get_all_buckets():
print "{name}\t{created}".format(
name = bucket.name,
created = bucket.creation_date,
)
# 新建文件,并写入内容
key = bucket.new_key('file.txt')
key.set_contents_from_string('Hello World!')
# 列出Bucket文件
for key in bucket.list():
print "{name}\t{size}\t{modified}".format(
name = key.name,
size = key.size,
modified = key.last_modified,
)
EOF
python s3.py