您好,登錄后才能下訂單哦!
這篇文章給大家介紹如何采用libs3進(jìn)行簡單的ceph radosgw測試和使用,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
一般情況下推薦使用s3cmd工具進(jìn)行ceph對象存儲的體驗(yàn)與測試,但是我需要提供C/C++的sdk包,所以將注意力集中在了libs3上,并采用libs3的命令進(jìn)行測試,效果與s3cmd類似。命令參數(shù)稍有不同。欲深入理解請閱讀源碼,本文作入門級使用說明。
github libs3源碼下載路徑
請采用git clone的方式從服務(wù)器下載源碼。
源碼下載后目錄如下:
# ll -h total 136K drwxr-xr-x 2 root root 4.0K Jan 8 13:59 archlinux drwxr-xr-x 7 root root 4.0K Jan 8 13:59 build -rw-r--r-- 1 root root 653 Jan 5 14:57 ChangeLog -rw-r--r-- 1 root root 7.5K Jan 5 14:57 COPYING drwxr-xr-x 2 root root 4.0K Jan 8 13:59 debian -rw-r--r-- 1 root root 35K Jan 5 14:57 doxyfile -rw-r--r-- 1 root root 14K Jan 5 14:57 GNUmakefile -rw-r--r-- 1 root root 9.7K Jan 5 14:57 GNUmakefile.mingw -rw-r--r-- 1 root root 9.9K Jan 5 14:57 GNUmakefile.osx drwxr-xr-x 3 root root 4.0K Jan 8 13:59 inc -rw-r--r-- 1 root root 2.4K Jan 5 14:57 INSTALL -rw-r--r-- 1 root root 2.2K Jan 5 14:57 libs3.spec -rw-r--r-- 1 root root 846 Jan 5 14:57 LICENSE drwxr-xr-x 2 root root 4.0K Jan 8 13:59 mswin -rw-r--r-- 1 root root 126 Jan 5 14:57 README drwxr-xr-x 2 root root 4.0K Feb 19 11:10 src drwxr-xr-x 2 root root 4.0K Jan 8 13:59 test -rw-r--r-- 1 root root 3.0K Jan 5 14:57 TODO
簡單說明: inc 頭文件 src 實(shí)現(xiàn)文件 build 用于存放編譯好的庫、可執(zhí)行文件
執(zhí)行命令make install即可編譯安裝
# make install /usr/bin/s3: Installing executable /usr/lib/libs3.so.2.0: Installing shared library /usr/lib/libs3.so.2: Linking shared library /usr/lib/libs3.so: Linking shared library /usr/lib/libs3.a: Installing static library /usr/include/libs3.h: Installing header
這里要注意的是,在使用s3命令的時(shí)候,需要先設(shè)置參數(shù):
export S3_ACCESS_KEY_ID="JD1**************TCI4" export S3_SECRET_ACCESS_KEY="88sAejI*************F4oHTLnqD" export S3_HOSTNAME="183.*.*.*"
對象存儲主要有如下幾個(gè)關(guān)鍵操作: 羅列用戶所有的bucket
羅列某個(gè)bucket下的對象
創(chuàng)建bucket
刪除bucket 向某個(gè)bucket中上傳對象 刪除bucket中的某個(gè)對象 下載某個(gè)bucket中的對象
下面針對這些操作進(jìn)行一一說明:
# s3 -u list Bucket Created -------------------------------------------------------- -------------------- big_rd_test_bucket 2016-02-04T06:18:04Z mytest 2016-03-18T01:24:53Z new_bucket1 2016-03-15T05:05:35Z rd_test_bucket_fifty_mb 2016-03-17T22:56:56Z wr_new_test_bucket_fifty 2016-03-18T01:10:00Z wr_test_bucket_fifty_mb 2016-03-18T00:30:38Z
# s3 -u list new_bucket1 Key Last Modified Size -------------------------------------------------- -------------------- ----- 16 2016-03-15T05:11:08Z 3496 ADBlockSetup.zip 2016-03-17T18:21:04Z 4.55M ZoneData 2016-03-17T23:20:51Z 564M eclipse-java-mars-R-win32-x86_64.zip 2016-03-18T00:23:25Z 163M nginx-1.6.3.tar.gz 2016-03-17T23:17:24Z 786K virtual machine.big.rar 2016-03-18T01:12:36Z 3.86G virtual machine.rar 2016-03-18T00:31:29Z 1.93G
# s3 -u create xuwenqiang Bucket successfully created. # s3 -u list Bucket Created -------------------------------------------------------- -------------------- wr_test_bucket_fifty_mb 2016-03-18T00:30:38Z write_test_bucket1 2016-03-20T18:23:53Z xuwenqiang 2016-03-21T04:30:06Z
通過list命令可以發(fā)現(xiàn),BUCKET xuwenqiang被成功創(chuàng)建。
# s3 -u delete xuwenqiang # s3 -u list Bucket Created -------------------------------------------------------- -------------------- wr_new_test_bucket_fifty 2016-03-18T01:10:00Z wr_test_bucket_fifty_mb 2016-03-18T00:30:38Z write_test_bucket1 2016-03-20T18:23:53Z
通過命令可以發(fā)現(xiàn)BUCKET xuwenqiang已不存在
# s3 -u put new_bucket1/newkey1 filename=CephS3.o 111392 bytes remaining (12% complete) ... 95008 bytes remaining (25% complete) ... 78624 bytes remaining (38% complete) ... 62240 bytes remaining (51% complete) ... 45856 bytes remaining (64% complete) ... 29472 bytes remaining (76% complete) ... 13088 bytes remaining (89% complete) ...
# s3 -u list new_bucket1 Key Last Modified Size -------------------------------------------------- -------------------- ----- 1 2016-03-21T00:34:46Z 1.00G 10 2016-03-20T18:29:10Z 50M 11 2016-03-20T18:29:28Z 50M 12 2016-03-20T18:29:31Z 50M # s3 -u delete write_new_bucket1/1 # s3 -u list new_bucket1 Key Last Modified Size -------------------------------------------------- -------------------- ----- 10 2016-03-20T18:29:10Z 50M 11 2016-03-20T18:29:28Z 50M 12 2016-03-20T18:29:31Z 50M 13 2016-03-20T18:29:28Z 50M 14 2016-03-20T18:29:29Z 50M 15 2016-03-20T18:29:30Z 50M 16 2016-03-20T18:29:30Z 50M
本例子從BUCKET new_bucket1中下載ID為10的文件到本地,命名為currenttest
# s3 -u get new_bucket1/10 filename=currenttest
# ll -h total 3.8G ...... -rw-r--r-- 1 root root 19K Feb 6 16:42 CephS3Test-WS.cpp -rw-r--r-- 1 root root 50M Mar 21 20:36 currenttest ......
#4 附錄
使用前請?jiān)O(shè)置環(huán)境變量
如果使用的http協(xié)議,請帶上-u選項(xiàng)
我基于Libs3做了一個(gè)簡易版的SDK,主要接口就是上述操作,不過將操作命令轉(zhuǎn)換為接口即可。
關(guān)于如何采用libs3進(jìn)行簡單的ceph radosgw測試和使用就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。