Ucloud網絡文件系統s3fs介紹

1、功能說明:

s3fs 工具支持將Bucket掛載到本地,像使用本地文件系統同樣直接操做對象存儲中的對象。html

2、s3fs 使用方法:

2.1配置密鑰文件:

在/etc/目錄中建立passwd-s3fs 文件。文件格式爲[API 公鑰:API 祕鑰]mysql

[root@localhost ~]# cat /etc/passwd-s3fs 
RTdB5Tv0i+45+YDNv6cOmCU9XsEFJcBlTUbJjKHkOXuqRCK3f69e1Q==:/WyeyWQDNUVi8kHktkLxa6pHqVQYfKeCei/qGNbry1H4JHOYw2ZUrDyy7AFDwTSJ
[root@localhost ~]# chmod 600  /etc/passwd-s3fs

祕鑰生成方法參考下面的文檔:
https://docs.ucloud.cn/uai-train/basic/key
Ucloud網絡文件系統s3fs介紹c++

公私鑰以下:git

PublicKey:RTdB5Tv0i+45+YDNv6cOmCU9XsEFJcBlTUbJjKHkOXuqRCK3f69e1Q==
PrivateKey:/WyeyWQDNUVi8kHktkLxa6pHqVQYfKeCei/qGNbry1H4JHOYw2ZUrDyy7AFDwTSJ

2.2CentOS 6和centos7編譯s3fs,而且安裝該程序:

https://github.com/s3fs-fuse/s3fs-fuse
git clone https://github.com/s3fs-fuse/s3fs-fuse.gitgithub

安裝所須要的依賴:redis

yum install automake gcc-c++ git libcurl-devel libxml2-devel   fuse-devel make openssl-devel fuse unzip -y

克隆s3fs-fuse版本庫:sql

[root@localhost s3fs]# git clone https://github.com/s3fs-fuse/s3fs-fuse.git
正克隆到 's3fs-fuse'...

remote: Enumerating objects: 71, done.
remote: Counting objects: 100% (71/71), done.
remote: Compressing objects: 100% (54/54), done.
remote: Total 6016 (delta 37), reused 38 (delta 16), pack-reused 5945
接收對象中: 100% (6016/6016), 3.67 MiB | 36.00 KiB/s, done.
處理 delta 中: 100% (4162/4162), done.

編譯安裝:centos

cd s3fs-fuse
./autogen.sh  
./configure  
make  
make install

s3fs --version #查看 s3fs版本號:瀏覽器

[root@localhost s3fs-fuse]# which s3fs
/usr/local/bin/s3fs
[root@localhost s3fs-fuse]# s3fs --version 
Amazon Simple Storage Service File System V1.86 (commit:0b60aa8) with OpenSSL
Copyright (C) 2010 Randy Rizun <rrizun@gmail.com>
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.

能夠看s3fs的版本號,到此,s3fs已經安裝成功。服務器

特別備註:

在執行第五步,./configure的過程當中,可能會遇到如下的問題。彙總爲:
報錯: configure: error: Package requirements (fuse >= 2.8.4 libcurl >= 7.0 libxml-2.0 >= 2.6 ) were not met:
緣由: fuse 版本太低,此時,您須要手動安裝 fuse 2.8.4及以上版本,安裝命令示例以下:

yum -y remove fuse-devel #卸載當前版本的fuse
wget https://github.com/libfuse/libfuse/releases/download/fuse_2_9_4/fuse-2.9.4.tar.gz
tar -zxvf fuse-2.9.4.tar.gz
cd fuse-2.9.4
./configure
make
make install
export
PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/:/usr/local/lib/pkgconfig
modprobe fuse #掛載 fuse 內核模塊
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig #更新動態連接庫
pkg-config --modversion fuse #查看 fuse 版本號,當看到 「2.9.4」 時,表示
fuse2.9.4 安裝成功

2.3說明:

官網文檔:
https://docs.ucloud.cn/ufile/s3/s3_introduction
目前只支持的掛載地域

接入域名           (Endpoint)
地域             外網Endpoint                           內網Endpoint
中國-北京二        s3-cn-bj.ufileos.com                  internal.s3-cn-bj.ufileos.com
中國-上海         s3-cn-sh2.ufileos.com                 internal.s3-cn-sh2.ufileos.com
中國-廣州         待支持                               internal.s3-cn-gd.ufileos.com
中國-香港         s3-hk.ufileos.com                     internal.s3-hk.ufileos.com
越南-胡志明        s3-vn-sng.ufileos.com                 internal.s3-vn-sng.ufileos.com
尼日利亞-拉各斯      s3-afr-nigeria.ufileos.com            internal.s3-afr-nigeria.ufileos.com
韓國-首爾         s3-kr-seoul.ufileos.com               internal.s3-kr-seoul.ufileos.com
巴西-聖保羅        bra-saopaulo.ufileos.com              待支持
美國-洛杉磯        s3-us-ca.ufileos.com                  internal.s3-us-ca.ufileos.com
注意: 目前中國-北京二,中國-香港,越南-胡志明,韓國-首爾,巴西-聖保羅地域已經支持https協議,其餘地域後續支持 (全部地域內網不支持https)

參數說明以下:

s3fs ${UFileBucketName} ${LocalFilePath}
-o url={UFileS3URl} -o passwd_file=~/.passwd-s3fs
-o dbglevel=info
-o curldbg,use_path_request_style,allow_other
-o retries=1 //錯誤重試次數
-o multipart_size="8" //分片上傳的大小爲 8MB,目前僅支持該值 -o
multireq_max="8" //當上傳的文件大於 8MB 是採用分片上傳,目前UFile 的 S3
接入層不容許 PUT 單個文件超過 8MB,因此該值建議必填
-f //表示前臺執行,後臺執行則省略
-o parallel_count="32" //並行操做數,能夠提升分片併發操做,建議不要超過 128

注意:
存儲空間名稱不帶域名後綴,好比UFile空間名稱顯示爲[wbbj-test.cn-bj.ufileos.com],則${UFileBucketName}=wbbj-test

[root@localhost video]# s3fs wbbj-test  /data/www/video -o url=http://s3-cn-bj.ufileos.com  -o passwd_file=/etc/passwd-s3fs -o dbglevel=info -o curldbg,use_path_request_style,allow_other -o retries=1 -o multipart_size="8" -o multireq_max="8" -o parallel_count="32"

下圖說明已經掛載成功:

Ucloud網絡文件系統s3fs介紹

cp文件到此目錄/data/www/video下
[root@mysql-redis105 video]# cp /root/1105.sql ./
[root@mysql-redis105 video]# pwd
/data/www/video
[root@mysql-redis105 video]# ls
1105.sql

控制檯查看bukets存儲,發現文件1105.sql已經放到了buckets
在控制檯bukets wbbj_test存儲新建一個txt文件夾

Ucloud網絡文件系統s3fs介紹
Ucloud網絡文件系統s3fs介紹

服務器查看有文件txt01生成:
Ucloud網絡文件系統s3fs介紹

瀏覽器能夠經過以下格式下載文件:
http://${bucket名字}.${Endpoint}/${key名字},相似UFile目前使用的URL形式

http://wbbj-test.s3-cn-bj.ufileos.com/test001/1.txt

卸載掛載目錄:umount /data/www/video

相關文章
相關標籤/搜索