Ceph distributed radosgw object Storage integrates the access Application of Swift and S3
* * Ceph distributed radosgw object storage integrates access applications of Swift and S3 * *
Make sure that the cluster status is normal: the configuration of the first half is based on the configuration of the upper part of https://blog.51cto.com/jdonghong/244175.
Install RGW instance
[root@master idc-cluster] # ceph-deploy install-- rgw client1 client2 client3
[root@master idc-cluster] # ceph-deploy rgw create client {1..3}
Add administrative node permissions
[root@master idc-cluster] # ceph-deploy admin client {1..3}
Create S3 user
[root@client1 ceph] # radosgw-admin user create-uid= "testuser"-display-name= "idc jerry"
[root@client1 ceph] # radosgw-admin user create-uid= "testuser"-display-name= "idc jerry"
{
"user_id": "testuser"
"display_name": "idc jerry"
"email":
"suspended": 0
"max_buckets": 1000
"auid": 0
"subusers": []
"keys": [
{
"user": "testuser"
"access_key": "VWWLX9UP2T9185XLXPF6"
"secret_key": "nwbZ9ufh4tWU8j8XtAoEdVv7WkMAkpRNms9Q39p5j"
}
]
"swift_keys": []
"caps": []
"op_mask": "read, write, delete"
"default_placement":
"placement_tags": []
"bucket_quota": {
"enabled": false
"max_size_kb":-1
"max_objects":-1
}
"user_quota": {
"enabled": false
"max_size_kb":-1
"max_objects":-1
}
"temp_url_keys": []
}
[root@master idc-cluster] # curl http://client1:7480-v
View all users
[root@client1 ceph] # radosgw-admin metadata list user
[
"testuser"
]
View user information
[root@client1 ceph] # radosgw-admin user info-- uid=testuser
View all buckets
[root@client1 ceph] # radosgw-admin bucket list
View the objects in the bucket
View Pool
[root@client1 ceph] # rados lspools
Test S3 interface
[root@BDDB ceph] # yum install python-boto
Create a test DEMO
[root@BDDB ceph] # cat s3_test.py
Import boto.s3.connection
Access_key = 'VWWLX9UP2T9185XLXPF6'
Secret_key = 'nwbZ9ufh4tWU8j8XtAoEdVv7WkMAkpRNms9Q39p5j'
Conn = boto.connect_s3 (
Aws_access_key_id=access_key
Aws_secret_access_key=secret_key
Host='client1', port=7480
Is_secure=False, calling_format=boto.s3.connection.OrdinaryCallingFormat ()
)
Bucket = conn.create_bucket ('my-new-bucket')
For bucket in conn.get_all_buckets ():
Print "{name} {created}" .format (
Name=bucket.name
Created=bucket.creation_date
)
Perform a test
[root@BDDB ceph] # python s3_test.py
Create a Swift user
To access the object gateway through Swift, we need a Swift user, and we create a subuser as a sub-user. Use the command
[root@client1 ~] # radosgw-admin user create-uid= "jerry"-subuser= "jerry": swift-- display-name= "idc_jerry"-- access=full-- email=jwenshan@163.com
[root@client1 ~] # radosgw-admin user create-uid= "jerry"-subuser= "jerry": swift-- display-name= "idc_jerry"-- access=full-- email=jwenshan@163.com
{
"user_id": "jerry"
"display_name": "idc_jerry"
"email": "jwenshan@163.com"
"suspended": 0
"max_buckets": 1000
"auid": 0
"subusers": [
{
"id": "jerry:swift"
"permissions": "full-control"
}
]
"keys": [
{
"user": "jerry"
"access_key": "L709JEL05ID5NU2N08TY"
"secret_key": "8XhbwWsWiLylOO9lahYI7WUJ3RpBpQAjmaXUUevp"
}
]
"swift_keys": [
{
"user": "jerry:swift"
"secret_key": "lePlwWwWk6enUqJXhM5hAAq7bI96EyBEDaRLyypG"
}
]
"caps": []
"op_mask": "read, write, delete"
"default_placement":
"placement_tags": []
"bucket_quota": {
"enabled": false
"max_size_kb":-1
"max_objects":-1
}
"user_quota": {
"enabled": false
"max_size_kb":-1
"max_objects":-1
}
"temp_url_keys": []
}
Create a key (this step is omitted because it was created directly together with a command above)
[root@client1] # radosgw-admin key create-subuser=jerry:swift-key-type=swift-gen-secret
{
"user_id": "jerry"
"display_name": "idc_jerry--access=full"
"email":
"suspended": 0
"max_buckets": 1000
"auid": 0
"subusers": [
{
"id": "jerry:swift"
"permissions":
}
]
"keys": [
{
"user": "jerry"
"access_key": "R97T9XMKI9FBYBSQ3C55"
"secret_key": "UgDVkoHRW9f8vGxAVGCS9smyUPn6YooxdNC04V83"
}
]
"swift_keys": [
{
"user": "jerry:swift"
"secret_key": "eQK89OYXPGIjFtI1Yk4gjABaO7PYph4HeJjbaDYO"
}
]
"caps": []
"op_mask": "read, write, delete"
"default_placement":
"placement_tags": []
"bucket_quota": {
"enabled": false
"max_size_kb":-1
"max_objects":-1
}
"user_quota": {
"enabled": false
"max_size_kb":-1
"max_objects":-1
}
"temp_url_keys": []
}
Test the Swift interface (find another client node to test)
Need to test SWIFT client installation dependency package
Yum install python-setuptools
Easy_install pip
Pip install python-swiftclient
Premise: remember to create the bucket first, otherwise it is not convenient for follow-up observation and application (execute script)
[root@BDDB ceph] # cat s3_test.py
Import boto.s3.connection
Access_key = "L709JEL05ID5NU2N08TY"
Secret_key = "8XhbwWsWiLylOO9lahYI7WUJ3RpBpQAjmaXUUevp"
Conn = boto.connect_s3 (
Aws_access_key_id=access_key
Aws_secret_access_key=secret_key
Host='client2', port=7480
Is_secure=False, calling_format=boto.s3.connection.OrdinaryCallingFormat ()
)
Bucket = conn.create_bucket ('isc_tong') # this example executes the script twice to create two buckets idc_tong and isc_tong
For bucket in conn.get_all_buckets ():
Print "{name} {created}" .format (
Name=bucket.name
Created=bucket.creation_date
)
Perform the test:
[root@BDDB ceph] # swift-A http://client2:7480/auth/1.0-U jerry:swift-K "lePlwWwWk6enUqJXhM5hAAq7bI96EyBEDaRLyypG" list
Idc_tong
[root@BDDB ceph] # swift-A http://client2:7480/auth/1.0-U jerry:swift-K "lePlwWwWk6enUqJXhM5hAAq7bI96EyBEDaRLyypG" stat
[root@BDDB ceph] # swift-A http://client2:7480/auth/1.0-U jerry:swift-K "lePlwWwWk6enUqJXhM5hAAq7bI96EyBEDaRLyypG" list
Successful test of swift interface access object storage.
Additional configuration by introducing environment variables (to facilitate configuration management):
[root@BDDB ceph] # export ST_USER=jerry:swift
[root@BDDB ceph] # export ST_AUTH= http://client1:7480/auth/1.0
[root@BDDB ceph] # export ST_KEY= "lePlwWwWk6enUqJXhM5hAAq7bI96EyBEDaRLyypG"
[root@BDDB ceph] # swift stat idc_tong
Upload files to tong:
[root@BDDB ceph] # swift upload idc_tong ceph.conf
[root@BDDB ceph] # swift stat idc_tong
[root@BDDB ceph] # swift stat idc_tong
Account: v1
Container: idc_tong
Objects: 1
Bytes: 369
Read ACL:
Write ACL:
Sync To:
Sync Key:
X-Timestamp: 1567152118.91934
X-Container-Bytes-Used-Actual: 4096
X-Storage-Policy: default-placement
X-Trans-Id: tx00000000000000000001a-005d68e068-d368-default
Accept-Ranges: bytes
Content-Type: text/plain; charset=utf-8
Effect display:
View the contents stored in the bucket:
[root@BDDB ceph] # swift list idc_tong
[root@BDDB ceph] # ls
Ceph.client.admin.keyring ceph.conf rbdmap s3_test.py tmpGnDYcT
[root@BDDB ceph] # swift upload idc_tong s3_test.py
S3_test.py
[root@BDDB ceph] # swift list idc_tong
Ceph.conf
S3_test.py
Download (Using the download Command)
[root@BDDB data] # swift download idc_tong ceph.conf