Ceph使用系列之——Ceph RGW使用

本文分享主題是《Ceph使用系列之——Ceph RGW使用》,歡迎關注。

Ceph RGW介紹

Ceph對象網關是在librados之上構建的對象存儲接口,旨在爲應用程序提供通往Ceph存儲集羣的RESTful網關,Ceph對象存儲使用Ceph對象網關守護進程(radosgw),它是用於與Ceph存儲羣集進行交互的HTTP服務器。其有多種體現方式,Ceph老版本使用的,如:apache2、Nginx等,Ceph在Hammer版本後使用civetweb替換原有版本apache2並作爲默認的http服務器,而在Nautilus版本時又換成了默認的beast作爲http服務端。

 

由它提供OpenStack Swift和Amazon S3兼容的接口,介紹如下:

 

  • S3兼容口:該對象存儲接口其與Amazon S3 RESTful API的大部分子集兼容。

  • Swift兼容口:該對接存儲接口與OpenStack Swift API的大部分子集兼容。

 

S3和Swift API共享同一個命名空間,所以可以使用兩種API訪問相同的數據。

其實除了上面提到兩種訪問接口外,Ceph還有一個管理接口admin API ,其通過rest api的方式對對象存儲進行管理,命令行形式爲radosgw-admin,可以用來執行創建用戶、刪除用戶、列出用戶等操作,示意圖如下:

 

 

使用radosgw-admin管理RGW

 

Ceph RGW對象存儲中有以下四個概念:

 

用戶:對象存儲應⽤用的使⽤用者,一個⽤用戶擁有一個或多個存儲桶。RGW向您提供的⽤用戶帳戶包括了AK(AccessKeyId)和SK(SecretAccessKeyID)。通過使⽤用 AK 和 SK 對稱加密的⽅方法來驗證某個請求的發送者身份。

 

  • 桶:桶(Bucket)是RGW中存儲對象的容器。對象存儲提供了基於桶和對象的扁平化存儲方式,桶中的所有對象都處於同一邏輯層級,去除了文件系統中的多層級樹形目錄結構。

  • 對象:對象(Object)是RGW中數據存儲的基本單位,一個對象實際是一個文件的數據與其相關屬性信息(元數據)的集合體。用戶上傳至RGW的數據都以對象的形式保存在桶中。

  • 訪問密鑰(AK/SK):RGW支持通過AK/SK認證方式進行認證鑑權,即使用Access Key ID(AK)/Secret Access Key(SK)加密的方法來驗證某個請求發送者身份。

 

 

用戶賬戶有兩種類型:

 

  • 用戶:是作爲s3接口用戶;

  • 子用戶:是作爲swift接口用戶,子用戶附屬於用戶。

 

radosgw-admin創建用戶。

#radosgw-admin user create --uid="testuser" --display-name="First User"{    "user_id": "testuser",    "display_name": "First User",    "email": "",    "suspended": 0,    "max_buckets": 1000,    "subusers": [],    "keys": [        {            "user": "testuser",            "access_key": "H1YNZV2D6E1X5PGAOSZ7",            "secret_key": "MasCiG6OJvEpXRTye4Ptz13SAI2dv5s3zUDXLO26"        }    ],    "swift_keys": [],    "caps": [],    "op_mask": "read, write, delete",    "default_placement": "",    "default_storage_class": "",    "placement_tags": [],    "bucket_quota": {        "enabled": false,        "check_on_raw": false,        "max_size": -1,        "max_size_kb": 0,        "max_objects": -1    },    "user_quota": {        "enabled": false,        "check_on_raw": false,        "max_size": -1,        "max_size_kb": 0,        "max_objects": -1    },    "temp_url_keys": [],    "type": "rgw",    "mfa_ids": []}

 

創建子用戶。

 

#radosgw-admin subuser create --uid=testuser --subuser=testuser:swift --access=full{    "user_id": "testuser",    "display_name": "First User",    "email": "",    "suspended": 0,    "max_buckets": 1000,    "subusers": [        {            "id": "testuser:swift",            "permissions": "full-control"        }    ],    "keys": [        {            "user": "testuser",            "access_key": "H1YNZV2D6E1X5PGAOSZ7",            "secret_key": "MasCiG6OJvEpXRTye4Ptz13SAI2dv5s3zUDXLO26"        }    ],    "swift_keys": [        {            "user": "testuser:swift",            "secret_key": "yahhi4lK5eJIw0cMg0cSm1ylRcncbAEGzQoximrw"        }    ],    "caps": [],    "op_mask": "read, write, delete",    "default_placement": "",    "default_storage_class": "",    "placement_tags": [],    "bucket_quota": {        "enabled": false,        "check_on_raw": false,        "max_size": -1,        "max_size_kb": 0,        "max_objects": -1    },    "user_quota": {        "enabled": false,        "check_on_raw": false,        "max_size": -1,        "max_size_kb": 0,        "max_objects": -1    },    "temp_url_keys": [],    "type": "rgw",    "mfa_ids": []}

 

查看用戶。

 

# radosgw-admin  user list[    "user-rgw",    "rgw",    "admin",    "test",    "testuser"]

 

查看用戶詳細信息。

 

# radosgw-admin   user info --uid test{    "user_id": "test",    "display_name": "test",    "email": "",    "suspended": 0,    "max_buckets": 1000,    "subusers": [],    "keys": [...................................................

 

更多可使用-h查看。

 

#radosgw-admin -husage: radosgw-admin <cmd> [options...]commands:  user create                create a new user  user modify                modify user  user info                  get user info  user rm                    remove user  user suspend               suspend a user  user enable                re-enable user after suspension  user check                 check user info  user stats                 show user stats as accounted by quota subsystem  user list                  list users  caps add                   add user capabilities  caps rm                    remove user capabilities  subuser create             create a new subuser  subuser modify             modify subuser  subuser rm                 remove subuser  key create                 create access key  key rm                     remove access key  bucket list                list buckets (specify --allow-unordered for..............................................

 

使用Ceph Dashboard操作RGW

 

Ceph Dashboard現在支持如下三個功能:

 

  • 查看RGW主機

  • 管理用戶

  • 管理桶

 

Ceph Dashboard現在還不支持上傳下載對象,只能通過s3或swift接口實現,詳細可參見下文。

 

以下爲查看RGW主機界面。

 

 

新建用戶。

 

 

創建子用戶。

 

 

 

 

可以看到子用戶附屬於用戶。

 

 

創建桶界面。

 

 

使用s3接口操作RGW

 

5.1:安裝s3cmd

 

要想使用s3接口訪問rgw,需要先安裝aws s3cmd命令行客戶端工具,s3cmd 是一款 Amazon S3 命令行工具。它不僅能上傳、下載、同步,還能設置權限。

下載並s3cmd工具。

 

因爲s3cmd是使用python寫的,所以要先安裝pip工具。

 

# yum -y install python-pip

 

安裝s3cmd,因爲pip默認使用國外源,容易下載失敗,所以加了臨時使用國內源的命令,使用-i指定國內源地址。

 

#pip install s3cmd -i https://pypi.tuna.tsinghua.edu.cn/simple

 

查看s3cmd版本。

​​​​​​​

#s3cmd --versions3cmd version 2.1.0

 

配置s3cmd配置文件, 該命令會在/root目錄下,創建.s3cfg文件。文件內容包括嚮導式中填寫的內容。也可以一直下一步生成空的配置文件,直接編輯配置文件,也可以按嚮導提示填入內容。​​​​​​​​​​​​​​

​​​​​​​

#s3cmd --configureEnter new values or accept defaults in brackets with Enter.Refer to user manual for detailed description of all options. Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.Access Key: YC57G2R9XJIMNG825UQPSecret Key: PEDoHiveAUhEciOeeKFYLkaArlhtSy5mBMfWhWesDefault Region [US]:  Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.S3 Endpoint [s3.amazonaws.com]: 192.168.123.172:7480 Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be usedif the target S3 system supports dns based buckets.DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: 192.168.123.172:7480/%(bucket) Encryption password is used to protect your files from readingby unauthorized persons while in transfer to S3Encryption password: Path to GPG program [/usr/bin/gpg]:  When using secure HTTPS protocol all communication with Amazon S3servers is protected from 3rd party eavesdropping. This method isslower than plain HTTP, and can only be proxied with Python 2.7 or newerUse HTTPS protocol [Yes]: noOn some networks all internet access must go through a HTTP proxy.Try setting it here if you can't connect to S3 directlyHTTP Proxy server name:  New settings:  Access Key: YC57G2R9XJIMNG825UQP  Secret Key: PEDoHiveAUhEciOeeKFYLkaArlhtSy5mBMfWhWes  Default Region: US  S3 Endpoint: 192.168.123.172:7480  DNS-style bucket+hostname:port template for accessing a bucket: 192.168.123.172:7480/%(bucket)  Encryption password:   Path to GPG program: /usr/bin/gpg  Use HTTPS protocol: False  HTTP Proxy server name:   HTTP Proxy server port: 0 Test access with supplied credentials? [Y/n] Please wait, attempting to list all buckets...Success. Your access key and secret key worked fine :-) Now verifying that encryption works...Not configured. Never mind. Save settings? [y/N] yConfiguration saved to '/root/.s3cfg'

 

生產了s3cf配置文件,如果哪些設置有錯誤,也可以直接編輯該配置文件。

 #vi /root/.s3cfg [default]access_key = YC57G2R9XJIMNG825UQPaccess_token = PEDoHiveAUhEciOeeKFYLkaArlhtSy5mBMfWhWescloudfront_host = 192.168.123.172:7480host_base = 192.168.123.172:7480host_bucket = 192.168.123.172:7480/%(bucket)

5.2:測試s3接口訪問

 

測試 S3 訪問。

   #yum install python-boto

 

新建 Python 腳本。

   #vi s3test.py

 

添加下面的內容到該文件中。

​​​​​​​

#!/usr/bin/python# -*- coding:utf-8 -*- import boto.s3.connection access_key = 'YC57G2R9XJIMNG825UQP'secret_key ='PEDoHiveAUhEciOeeKFYLkaArlhtSy5mBMfWhWes'conn = boto.connect_s3(        aws_access_key_id=access_key,        aws_secret_access_key=secret_key,        host='ceph-node1',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,            )

 

將 host替換爲你配置了網關服務的主機的主機名,比如 gateway host.將access_key替換爲正確的值,將secret_key替換爲正確的值。

 

運行這個腳本

 

#python s3test.py

 

輸出類似下面的內容,說明使用s3接口連接rgw對象成功。

​​​​​​​

# python s3test.py ceph-rgw 2020-05-03T08:29:44.240Zmy-new-bucket 2020-03-14T10:21:03.179Znew-bucket-510d1576 2020-03-16T13:20:59.151Znew-bucket-6c11b821 2020-03-14T10:37:11.406Znextcloud 2020-05-03T04:32:28.547Zrgw-test 2020-05-02T13:17:02.184Ztest 2020-03-12T14:55:47.827Ztest3 2020-03-14T10:45:54.065Ztest4 2020-03-14T10:46:03.714Ztest5 2020-03-14T10:46:37.318Ztest6 2020-03-14T10:47:46.755Ztest7 2020-03-14T10:51:50.559Ztest8 2020-03-14T10:53:02.755Ztest9 2020-05-02T14:15:04.193Z

 

5.3:使用s3cmd操作rgw

 

使用s3cmd創建桶。

​​​​​​​

# s3cmd mb s3://ceph-rgwBucket 's3://ceph-rgw/' created

 

上傳文件到rgw對象存儲。​​​​​​​​​​​​​​

​​​​​​​

#s3cmd put prometheus-2.16.0.linux-amd64.tar.gz s3://ceph-rgwWARNING: Could not refresh roleWARNING: Could not refresh roleWARNING: Could not refresh roleupload: 'prometheus-2.16.0.linux-amd64.tar.gz' -> 's3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gz'  [part 1 of 4, 15MB] [1 of 1] 15728640 of 15728640   100% in    0s    29.05 MB/s  doneWARNING: Could not refresh roleupload: 'prometheus-2.16.0.linux-amd64.tar.gz' -> 's3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gz'  [part 2 of 4, 15MB] [1 of 1] 15728640 of 15728640   100% in    0s    36.41 MB/s  doneWARNING: Could not refresh roleupload: 'prometheus-2.16.0.linux-amd64.tar.gz' -> 's3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gz'  [part 3 of 4, 15MB] [1 of 1] 15728640 of 15728640   100% in    0s    36.27 MB/s  doneWARNING: Could not refresh roleupload: 'prometheus-2.16.0.linux-amd64.tar.gz' -> 's3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gz'  [part 4 of 4, 11MB] [1 of 1] 12422595 of 12422595   100% in    0s    31.92 MB/s  doneWARNING: Could not refresh role

 

查看桶中的對象。

​​​​​​​

 #s3cmd ls s3://ceph-rgwWARNING: Could not refresh roleWARNING: Could not refresh role2020-05-03 08:48  59608515   s3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gz

 

下載對象

​​​​​​​

#s3cmd get s3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gz prometheus-2.16.0.linux-amd64.tar.gz.bakdownload: 's3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gz' -> 'prometheus-2.16.0.linux-amd64.tar.gz.bak'  [1 of 1] 59608515 of 59608515   100% in    0s   142.89 MB/s  done

 

刪除桶中的對象,可以使用rm或del命令。

​​​​​​​

#s3cmd rm s3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gzWARNING: Could not refresh roleWARNING: Could not refresh roledelete: 's3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gz'

 

查看對象佔用空間大小

​​​​​​​

#s3cmd du -H s3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gz56.8471097946M 1 objects s3://ceph-rgw/prometheus-2.16.0.linux-amd64.tar.gz

 

更多命令請參考s3cmd幫助。

 

使用s3fs訪問RGW

 

S3fs是基於FUSE的文件系統,允許Linux和Mac Os X 掛載S3的存儲桶在本地文件系統,S3fs能夠保持對象原來的格式,S3FS是POSIX的大子集,包括讀/寫文件、目錄、符號鏈接、模式、uid/gid和擴展屬性,與AmazonS3、Google雲存儲和其他基於S3的對象存儲兼容。

 

對於原來使用本地目錄訪問數據的應用程序,比如使用本地磁盤或網絡共享盤保存數據的應用系統,如果用戶希望把數據放到S3上,則需要修改數據的訪問方式,比如修改爲使用S3 SDK 或CLI訪問S3中存儲的數據。爲了讓用戶原來的應用系統能在不做修改的情況下直接使用 S3服務,需要把S3存儲桶作爲目錄掛載到用戶服務器的本地操作系統上。常用的掛載工具有S3fs和SubCloud等,本文主要演示s3fs使用。

 

S3fs是基於FUSE的文件系統,允許Linux和Mac Os X 掛載S3的存儲桶在本地文件系統,S3fs能夠保持對象原來的格式。

 

溫馨提醒:

 

利用S3fs可以方便的把S3存儲桶掛載在用戶本地操作系統目錄中,但是由於S3fs實際上是依託於Amazon S3服務提供的目錄訪問接口,所以不能簡單的把S3fs掛載的目錄和本地操作系統目錄等同使用。用戶使用S3f3掛載S3存儲桶和直接訪問S3服務有類似的使用場景。適用於對不同大小文件對象的一次保存(上傳),多次讀取(下載)。不適用於對已保存文件經常做隨機修改,因爲每次在本地修改並保存文件內容都會導致S3fs上傳新的文件到Amazon S3去替換原來的文件。從訪問性能上來說,通過操作系統目錄方式間接訪問Amazon S3存儲服務的性能不如直接使用SDK或CLI接口訪問效率高。

 

安裝s3fs

​​​​​​​

#yum install epel-release#yum install s3fs-fuse

 

查看版本

​​​​​​​

#s3fs --versionAmazon Simple Storage Service File System V1.86 (commit:unknown) with OpenSSLCopyright (C) 2010 Randy Rizun <[email protected]>License GPL2: GNU GPL version 2 <https://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.

 

配置密鑰

 

密鑰文件可以存放在以下兩個地址:

 

  • 用戶家目錄下./passwd-s3fs((i.e. ${HOME}/.passwd-s3fs))

  •  /etc/passwd-s3fs 文件

 

命令格式:s3fs [S3存儲桶名] [本地目錄名] -o passwd_file=[密鑰文件名] -o url=[RGW地址] -o use_path_request_style

 

生成掛載目錄,該目錄必需爲空目錄。

 

 #mkdir /home/s3fs

 

使用s3fs掛載桶

 

#s3fs ceph-rgw /home/s3fs -o passwd_file=~/.passwd-s3fs -o use_path_request_style -o url=http://192.168.123.172:7480

 

  • url(必需):對象網關服務ip以及端口號

  • passwd_file:如果密鑰文件在以上提到的兩個地方存儲,則不用此選項

  • use_path_request_style(必需):使用路徑訪問方式,否者不能正常掛載桶。

 

查看是否掛載成功

​​​​​​​

#df -hFilesystem               Size  Used Avail Use% Mounted ondevtmpfs                 967M     0  967M   0% /devtmpfs                    981M     0  981M   0% /dev/shmtmpfs                    981M  8.8M  972M   1% /runtmpfs                    981M     0  981M   0% /sys/fs/cgroup/dev/mapper/centos-root   17G  2.1G   15G  12% //dev/sda1               1014M  176M  839M  18% /boottmpfs                    981M   24K  981M   1% /var/lib/ceph/osd/ceph-8tmpfs                    981M   24K  981M   1% /var/lib/ceph/osd/ceph-4tmpfs                    981M   24K  981M   1% /var/lib/ceph/osd/ceph-1tmpfs                    981M   24K  981M   1% /var/lib/ceph/osd/ceph-9tmpfs                    197M     0  197M   0% /run/user/0s3fs                     256T     0  256T   0% /home/s3fs

 

查看目錄內容

​​​​​​​

#cd /home/s3fs/# lsprometheus-2.16.0.linux-amd64.tar.gz

 

開機自動掛載

 

添加如下內容到fstab文件中。

  •  
  •  
#vi /etc/fstabs3fs#ceph-rgw /home/s3fs  fuse _netdev,allow_other,use_path_request_style,url=http://192.168.123.172:7480 0 0

 

-o allow_other參數用於設置掛載目錄可以被任意登陸服務器的用戶使用,且可以將該掛載目錄用於創建NFS/SMB共享。

 

卸載目錄

 

#umount /home/s3fs/

 

其它命令請參考s3fs幫助。

 

利用S3fs可以把共享的 S3存儲桶直接掛載在用戶服務器本地目錄下,應用不需要做修改就可以直接使用S3存儲服務,這種方式可以作爲臨時解決方案將傳統應用快速遷移到RGW平臺,然後逐步調整S3數據訪問實現方式,最終修改爲使用SDK或CLI方式高效並更加安全地訪問S3存儲服務。

 

使用S3 Browser訪問RGW

 

打開s3 browser,點擊"add new account"。

 

 

輸入以下內容,注意簽名版本爲V4。

 

 

查看rgw對象存儲中所有的桶。

 

 

使用swift接口操作RGW

 

安裝swift命令行工具,配置swift安裝源,因爲swift是openstack一個組件,所以此處配置爲openstack源,當然也有直接安裝swift的命令,不用配置openstack源,不過本人沒有使用那個方法安裝成功,本文還是使用配置OpenStack源的方法。

​​​​​​​

#vi openstack.repo [openstack]name=openstackbaseurl=https://mirrors.cloud.tencent.com/centos/7.7.1908/cloud/x86_64/openstack-train/gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

安裝swift命令工具。

 

#yum install python2-swiftclient

 

查看swiftclient版本。

​​​​​​​

#swift --versionpython-swiftclient 3.8.1

 

查看子用戶名稱和密鑰。

​​​​​​​

 #radosgw-admin user info --uid testuser[    "user-rgw",    "rgw",    "admin",    "test10",    "test",    "testuser"]#radosgw-admin user info --uid testuser................................................................................"swift_keys": [        {            "user": "testuser:swift",            "secret_key": "yahhi4lK5eJIw0cMg0cSm1ylRcncbAEGzQoximrw"        }    ],..................................................................................

 

使用swift命令查看rgw對象存儲狀態。

​​​​​​​

#swift -A http://192.168.123.172:7480/auth/v1.0 -U testuser:swift -K "yahhi4lK5eJIw0cMg0cSm1ylRcncbAEGzQoximrw" stat                                    Account: v1                                 Containers: 0                                    Objects: 0                                      Bytes: 0Objects in policy "default-placement-bytes": 0  Bytes in policy "default-placement-bytes": 0   Containers in policy "default-placement": 0      Objects in policy "default-placement": 0        Bytes in policy "default-placement": 0                              Accept-Ranges: bytes                                 Connection: Keep-Alive                                X-Timestamp: 1588493556.96500                X-Account-Bytes-Used-Actual: 0                                 X-Trans-Id: tx0000000000000000003c8-005eae7cf4-f2b7f-default                               Content-Type: text/plain; charset=utf-8                     X-Openstack-Request-Id: tx0000000000000000003c8-005eae7cf4-f2b7f-default

 

但上面每次需要輸入很長的命令,所以可以通過設置環境變量減少每次輸入的命令,當然想要永久生效需要把以下內容存儲在用戶的環境變量文件中,如.bashrc文件中。

把下面的USER和KEY替換成實際的值。

​​​​​​​

#export ST_AUTH=http://production01.acme.com/auth/v1.0export ST_USER=user01export ST_KEY=password

現在就可以通過簡短命令操作對象存儲了。

創建桶

 

#swift post bucket

 

上傳文件到桶中

 

創建桶並上傳文件到rgw桶中

​​​​​​​

#swift upload bucket ceph-iscsi-config-2.7-1.el7.noarch.rpm#swift list bucketceph-iscsi-config-2.7-1.el7.noarch.rpm

 

溫馨提醒:

 

upload命令上傳文件到指定的桶中,如果存在桶名稱則直接上傳到指定的桶中,如果沒有存在桶名稱,則新建桶並上傳對象到此桶中

查看指定桶中的對象,不加桶名稱即查看所有。

 #swift list bucket

 

從指定桶下載對象

#swift download bucket ceph-iscsi-config-2.7-1.el7.noarch.rpmceph-iscsi-config-2.7-1.el7.noarch.rpm [auth 0.004s, headers 0.008s, total 0.009s, 17.761 MB/s]

​​​​​​​

查看指定桶中的對象。

​​​​​​​

#swift stat bucket ceph-iscsi-config-2.7-1.el7.noarch.rpm               Account: v1             Container: bucket                Object: ceph-iscsi-config-2.7-1.el7.noarch.rpm          Content Type: application/x-rpm        Content Length: 94632         Last Modified: Tue, 05 May 2020 14:42:34 GMT                  ETag: 86f3c320ed3b5c2ea8389710c31b7997            Meta Mtime: 1583988649.031517         Accept-Ranges: bytes            Connection: Keep-Alive           X-Timestamp: 1588689754.31758            X-Trans-Id: tx0000000000000000000ce-005eb1801f-fc7b1-defaultX-Openstack-Request-Id: tx0000000000000000000ce-005eb1801f-fc7b1-default

 

刪除對象。​​​​​​​

 #swift delete bucket ceph-iscsi-config-2.7-1.el7.noarch.rpmceph-iscsi-config-2.7-1.el7.noarch.rpm

更多命令請參考swift幫助。

使用CloudBerry 訪問RGW

 打開cloudberry explorer。

 

 

設置賬號。

 

 

點擊增加存儲。

 

 

按以下內容輸入詳細,使用第三節創建的testuser:swift子用戶以及密鑰。

 

溫馨提醒:

 

注意地址欄中的auth關鍵字,這個必須要有否者連接不上

 

注意keystone version中使用的是“do not user”

 

Nextcloud網盤應用訪問Ceph RGW

 

10.1:nextcloud介紹

 

上面演示了使用很多圖形或命令行工具操作使用RGW對象存儲,其實RGW使用最多的還是通過應用程序使用它,本節使用一個網盤應用軟件Nextcloud,配置其後端存儲使用RGW對象存儲,爲用戶提供網盤應用,用戶上傳的文件實現是存儲在了RGW對象存儲中,示意圖如下:

 

 

10.2:安裝nextcloud

 

爲了簡化安裝步驟,本文使用snap工具安裝nextcloud.

 

配置epel源。

 

#yum install epel-release

 

安裝snapd工具。

 

#yum install snapd

 

配置snapd socket。

 

#systemctl enable --now snapd.socket

 

配置軟鏈接

 

 # ln -s /var/lib/snapd/snap /snap

 

通過snap安裝nextcloud。

 

 # snap install nextcloud

 

查看源已通過snap安裝的nextcloud應用。

​​​​​​​

#snap listName       Version      Rev    Tracking  Publisher   Notescore       16-2.44.3    9066   stable    canonical✓  corenextcloud  18.0.4snap1  20498  stable    nextcloud✓  -

 

snap安裝的nextcloud默認使用80端口,輸入IP地址打開nextcloud配置界面。

 

設置用戶名和密碼,點擊完成。

 

 

10.3:配置nextcloud

 

安裝完成打開nextcloud使用界面。

 

 

配置nextcloud使用rgw存儲,點擊應用按鈕。

 

 

在已禁用應用中選擇“external storage support",點擊啓用。

 

完成後點擊設置查看左側功能菜單出現”外部存儲“。

 

 

創建nextcloud桶。

​​​​​​​

# s3cmd mb s3://nextcloudBucket 's3://nextcloud/' created

 

查看桶。

​​​​​​​

# s3cmd ls |grep nextcloud2020-05-03 04:32  s3://nextcloud

 

配置nextcloud使用s3訪問rgw對象存儲,填寫目錄名稱,並勾選啓用路徑,當左邊出現綠色的圖標表示連接成功。

 

 

溫馨提醒:

 

啓用路徑樣式後,將使用發出請求http://hostname.domain/bucket。只有這格式的才能對接成功(默認爲http://bucket.hostname.domain)。

 

回到nextcloud界面,看到出現rgw目標,只有上傳到該目錄的文件纔會使用s3接口存儲到rgw存儲中。

 

上傳文件到rgw目錄後,查看對應桶中的對象。

 

 

至此nextcloud使用s3對接使用rgw完成,當然nextcloud也支持使用swift接口對接nextcloud,但只能是在OpenStack中安裝的swift,不能是單獨的swift,因爲nextcloud配置swift接口的界面中必須寫keystone版本。

 

當然RGW的使用還不止上文中提到的這些,RGW還有Multisite場景,其涉及的內容比較多。

 

 


 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章