×

幫助中心

常見問題
域名類
?  域名介紹
?  注冊/續(xù)費
?  域名管理
?  域名過戶
?  域名轉移
?  增值服務
?  域名交易
?  通用網址
?  產品更新日志
郵局類
?  產品簡介
?  產品管理
?  郵件客戶端
?  郵箱用戶操作指南
?  郵箱管理員操作指南
?  產品使用手冊
?  代理商控制臺操作指南
?  產品更新日志
云虛機類
?  購買與升級
?  FTP
?  主機管理
?  技術問題
?  數據庫
?  產品更新日志
ECS云主機類
?  產品更新日志
會員類
?  會員注冊
?  信息修改
?  忘記密碼
?  賬戶實名認證
?  產品更新日志
財務類
?  后付費計費
?  在線支付
?  線下匯款
?  發(fā)票問題
?  匯款單招領
?  退款問題
?  充值業(yè)務
?  產品更新日志
ICP備案
?  備案問題快速咨詢通道
?  備案介紹
?  備案賬號
?  ICP備案前準備內容
?  ICP備案流程
?  ICP備案操作指導
?  ICP備案信息查看
?  備案合規(guī)核查要求
?  資料下載
?  公安聯網備案與經營性備案
?  各地管局備案通知
?  常見問題
服務類
?  ICP備案
?  小新服務
?  產品更新日志
網站定制類
?  網站定制問題
?  網站訪問問題
新辦公類
?  常見問題
?  操作手冊下載
云推送
?  云推送常見問題
速成建站
?  網站訪問問題
?  網站使用問題
?  產品更新日志
SSL證書
?  SSL證書常見問題
?  產品更新日志
新網云產品類
?  新網云WEB應用防火墻
?  新網云DDoS防護
?  云數據庫
?  云產品運維
?  內容分發(fā)網絡CDN
?  對象存儲 S3
?  網絡
資料下載
新手上路

US3FS 文件掛載工具

  • 作者:
  • 文章來源:新網
  • 點擊數:0
  • 更新時間:2024-03-27 10:29:41

US3FS是一個在Linux/Windows系統(tǒng)環(huán)境中,將S3的存儲空間(Bucket)掛載到本地掛載點的工具,掛載成功后,您可以像操作本地文件一樣操作存儲空間(Bucket)中的文件。



軟件版本:

linux: v2.0.2

windows: v1.6.8


運行環(huán)境:


Linux:
Ubuntu 16.04 及以上 (可通過cat /etc/issue查看)

CentOS 7.0 及以上 (可通過cat /etc/redhat-release查看)


Windows:

開啟WinFsp服務

image

主要功能

支持POSIX文件系統(tǒng)的大部分功能,如讀;順序寫;權限;UID/GID。


使用US3的分片上傳功能上傳大文件。
支持Etag和MD5校驗,保證數據一致性。



使用限制
不支持隨機寫/追加寫
rename非原子操作
不支持硬/軟鏈接
多個客戶端掛載同一個US3 Bucket時,需要用戶自行維護數據一致性。

不支持讀取歸檔類型的文件




運行環(huán)境

US3FS基于Linux下fuse和Windows平臺下winfsp實現,您的機器需要支持fuse或winfsp。


建議您將US3FS運行在以下環(huán)境中:

Linux:

ceontos 7.0及以上 (可通過cat /etc/redhat-release查看)

ubuntu 16.04及以上 (可通過cat /etc/issue查看)


Windows:

下載WinFsp Installer

根據官方說明 進行安裝


下載鏈接

Linux下載鏈接 或

curl -o us3fs https://ufile-release.cn-bj.ufileos.com/us3fs/us3fs_2.0.2CopyErrorSuccess

Windows下載鏈接


配置賬號訪問信息


Linux

編輯/etc/us3fs/us3fs.yaml并增加如下信息(如果沒有該目錄需要自行創(chuàng)建):

access_key: ************************************secret_key: ************************************endpoint: ufile.cn-north-02.ucloud.cnhosts: []CopyErrorSuccess

冒號后有單個空格

access_key: 公鑰,支持token秘鑰和api秘鑰兩種模式,要有覆蓋上傳權限

secret_key: 私鑰,支持token秘鑰和api秘鑰兩種模式,要有覆蓋上傳權限

endpoint: 訪問域名。填寫域名為地域域名,并非具體的存儲空間域名。

hosts: 指定訪問點IP列表,不會走DNS解析邏輯獲取US3接入層IP。如果指定個數小于3個不會生效。 如: hosts: [10.9.254.190, 117.50.123.23, 117.50.123.29, 117.50.123.8]

hosts指定的IP列表,在遇到異常(網絡不可達)IP節(jié)點時會在5s檢測周期內自動標記剔除,新的請求不受影響,但已經發(fā)起的請求且使用異常網絡的鏈接,由于TCP采用退避指數重試算法,默認重試次數為15次,所以最壞情況要到15min左右才能檢測異常,建議在使用該參數時,修改Linux參數net.ipv4.tcp.retries2(或修改系統(tǒng)文件/proc/sys/net/ipv4/tcp_retries2)為6,可使如網絡不可達異常在25s左右能檢測到,從而剔除已建立異常鏈接;此外由于目前鏈接?;钐綔y邏輯會占用一定量的文件描述符,建議調整系統(tǒng)設置,請參考場景問題 中的系統(tǒng)日志出現too many open file問題項解決。

當需要在一臺機器上掛載多個Bucket時,可以通過--passwd=passwd_file指定賬號信息(默認路徑為 /etc/us3fs/us3fs.yaml,不需要指定)。

下載US3FS后。使用chmod +x us3fs增加可執(zhí)行權限,如果需要直接執(zhí)行,可將us3fs移動到/bin目錄下。示例:

chmod +x us3fs./us3fs --passwd=passwd_file <bucket> <mountpoint> # 移動到可執(zhí)行目錄下 mv us3fs /bin/us3fsus3fs --passwd=passwd_file <bucket> <mountpoint>CopyErrorSuccess


Windows

配置信息內同linux,配置路徑自定義。

下載好可執(zhí)行文件后移動到us3fs的工作目錄(自定義),然后通過按鍵windows+R打開運行窗口,輸入cmd進入命令行工具界面(后續(xù)支持圖形化界面),進入可執(zhí)行文件us3fs.exe 所在路徑。示例:

# 進入可執(zhí)行文件所在盤符,這里是D盤 C:\Users\Administrator> D: # 進入可執(zhí)行文件所在路徑 D:\>cd us3fsD:\us3fs>dir驅動器 D 中的卷沒有標簽。卷的序列號是 5CAF-F66B D:\us3fs 的目錄 2021/09/09 21:16 <DIR> . 2021/09/09 21:16 <DIR> .. 2021/09/09 19:13 19,475,146 us3fs.exe 2021/08/26 11:29 157 us3fs.yaml 2 個文件 19,475,303 字節(jié) 2 個目錄 213,768,716,288 可用字節(jié) # 進行掛載操作 # * 這里掛載到x盤,并且指定uid,gid為0的用戶,日志級別為debug,預讀窗口為32MiB,掛載的US3桶名為rickwu D:\us3fs>us3fs.exe --passwd=us3fs.yaml -o debug --uid=0 --gid=0 --level=debug --readahead=32m <bucket> x:CopyErrorSuccess

注意目前Windows下掛載只能前臺掛載




使用方式

掛載
us3fs [global options] <bucket> <mountpoint>CopyErrorSuccess

卸載
umount <mountpoint>CopyErrorSuccess

參數<bucket>和<mountpoint>必須依次作為最后兩個參數,否則其他參數不能生效

windows 對cmd執(zhí)行Ctrl+C


配置訪問權限

us3fs掛載的默認訪問權限為當前掛載用戶,如果需要允許其他用戶/用戶組訪問掛載點,可以使用如下參數:

-o allow_other:允許任何用戶都可以訪問文件。

--uid=xxx:指定默認的用戶

--gid=xxx:指定默認的用戶組

--mp_mask: 用來設置掛載點的權限掩碼,只有當allow_other選項設置后,該選項才生效,默認值為0000。使用方式基本于umask命令一致;例如需要設置掛載點的權限為770,則使用參數 -o allow_other --mp_mask 0007;**注意root用戶會忽略非root用戶掛載時設置的mp_mask**。

可通過id命令獲取用戶的uid/gid信息,示例如下:

// 在ubuntu賬戶下掛載默認用戶和用戶組為www的us3fsubuntu:~$ id www uid=1001(www) gid=1001(www) groups=1001(www) ubuntu:~$ us3fs --uid=1001 --gid=1001 -o allow_other <bucket> <mountpoint>CopyErrorSuccess

mp_mask 配置示例如下:

掛載目錄權限mp_mask
rwxrwxrwx0000
rwxrwx---0007
rwx------0077
rwxr--r--0033
rwxrwxr--0003
rwxr-xr-x0022


如果掛載出現以下問題


stderr:/bin/fusermount: option allow_other only allowed if 'user_allow_other' is set in /etc/fuse.confCopyErrorSuccess

在/etc/fuse.conf中增加user_allow_other。

windows下只支持--uid和--gid

設置掛載只讀

掛載時時指定-o ro。

windows下不支持

開啟日志

--level=info/debug/error 開啟指定級別的us3fs日志
--debug_fuse 開啟用戶態(tài)fuse日志
    centos 日志在/var/log/messages
    ubuntu 日志在/var/log/syslog
掛載時指定-f,us3fs會以前臺模式掛載,日志會輸出到屏幕上。

版本更新

執(zhí)行如下命令:

us3fs --updateCopyErrorSuccess

更新后的可執(zhí)行文件放在/bin/目錄下

windows無效


使用幫助

通過us3fs -h查看us3fs支持的參數

Linux

us3fs - a single posix file system based on us3USAGE us3fs [global options] bucket mountpointVersion US3FS Version: v2.0.2 Commit ID: 223949d Build: 2024-01-24:10:32:50 Go Version: go1.17.13 linux/amd64FUSE -o value Specify fuse/winfsp option --entry_timeout value How long to cache dentry for inode for fuse. (default: 5m0s) --attr_timeout value How long to cache inode attr for fuse (default: 5m0s) --disable_async_read Disable all read (even read-ahead) operations asynchronously --wb Enable writeback mode, which is turned off by default --max_background value Specify the max_background parameter of fuse kernel(>=7.13), currently fuse usespace supports up to 1024 (default: 64) --congestion_threshold value Specify the congestion_threshold parameter of fuse kernel(>=7.13), currently fuse usespace supports up to 768 (default: 48) --async_dio Enable the async_dio parameter of fuse kernel, async_dio is disabled by default --keep_pagecache Turn on pagecache, when the file is opened, it will be decided whether to update according to the modification time of the inode, so please pay attention to the attr_timeout and dcache_timeout parameters will have a certain impact on thisOS --dcache_timeout value How long to cache dentry for us3fs (default: 5m0s) --retry value Number of times to retry a failed I/O (default: 5) --parallel value Number of parallel I/O thread (default: 32) --disable_remove Disable remove op, such as unlink, rmdir, rename --debug Set debug level for fuse/winfsp --level value Set log level: error/warn/info/debug (default: "info") --log_dir value Set log dir --log_max_age value Set log max age (default: 72h0m0s) --log_rotation_time value Set log rotation time (default: 1h0m0s) --enable_load_dentries enable auto init dentries in memory --cache_db value specify cache db path, e.g.: dbtype:dbpath --local_write write file to local and upload async --max_local_file_size value specify local file max size (default: "32m") --read_after_write_finish read operation will wait all write operation done --finish_write_when_release all written data will be uploaded when release --readahead value Readahead size. e.g.: 1m/1k/1 (default: "0") --max_cache_per_file value Max cache per file when enable readahead. e.g.: 32m/64m/128m (default: "1024m") --etag value Check etag for part. value is percent(0~100) (default: 50) --passwd value specify access file (default: "/etc/us3fs/us3fs.yaml") --enable_md5 Enalbe md5 in http header --uid value Specify default uid (default: 0) --gid value Specify default gid (default: 0) --mp_mask value Specify mountpoint mask (default: 0) --disable_check_vdir disable detection of virtual directories --update Update us3fs to /bin/us3fs -n Doesn't check access when mount us3fs -l Enable local cache for small file -p value Specify local cache location (default: "/tmp/us3fs/") --prefix value Specify bucket prefix path --open_rename Use rename api rather than copy and delete --gfl Enable get_file_list --direct_read Enable cache bypass read --perf_dump value How long to output the performance dump (default: 1h0m0s) --skip_ne_dir_lookup Skip non-essential directory checking, such as files ending in ".log",".png",".jpg", etc. --storage_class value Storage type, including "STANDARD", "IA" (default: "STANDARD") --enable_remote_cache --cache_dirs value specify cache db path, e.g.: /tmp/read-cache1,/tmp/read-cache2 --cache_size_limit value specify cache size limit, unit is GB (default: 4) --master_addr value master server addr --data_port value if data_port is specified, then other clients will connect it to get chunk data (default: 0) --page_size value (default: 1048576) --fuse_session_cnt value (default: 0) MISC --help, -h show help -f foregroundCopyErrorSuccess

Windows

us3fs - a single posix file system based on us3USAGE us3fs [global options] bucket mountpointVersion US3FS Version: v1.6.8 Commit ID: c87ec9c Build: 2022-08-17:11:01:05 Go Version: go1.16.3 linux/amd64WinFSP -o value Specify fuse/winfsp option --dir_info_timeout value The expiration time of the directory information, in seconds (default: 5) --file_info_timeout value File information expiration time, in seconds (default: 5) --volume_info_timeout value Volume information expiration time, in seconds (default: 5) --case_insensitive Is case sensitive --keep_filecache keep filecacheOS --dcache_timeout value How long to cache dentry for us3fs (default: 5m0s) --retry value Number of times to retry a failed I/O (default: 5) --parallel value Number of parallel I/O thread (default: 32) --debug Set debug level for fuse/winfsp --level value Set log level: error/warn/info/debug (default: "info") --readahead value Readahead size. e.g.: 1m/1k/1 (default: "0") --etag value Check etag for part. value is percent(0~100) (default: 50) --passwd value specify access file (default: "/etc/us3fs/us3fs.conf") --enable_md5 Enalbe md5 in http header --uid value Specify default uid (default: -1) --gid value Specify default gid (default: -1) --disable_check_vdir disable detection of virtual directories --update Update us3fs to /bin/us3fs -n Doesn't check access when mount us3fs -l Enable local cache for small file -p value Specify local cache location (default: "/tmp/us3fs/") --prefix value Specify bucket prefix path --gfl Enable get_file_list --direct_read Enable cache bypass read --perf_dump value How long to output the performance dump (default: 1h0m0s) --skip_ne_dir_lookup Skip non-essential directory checking, such as files ending in ".log",".png",".jpg", etc. --storage_class value Storage type, including "STANDARD", "IA" (default: "STANDARD") MISC --help, -h show help -f foregroundCopyErrorSuccess

Linux和Windows的參數區(qū)別主要體現在FUSE和WinFsp

配置文件對應終端參數

部分終端掛載參數支持配置在配置文件,配置文件的參數和終端參數的對應關系如下:

終端掛載參數名稱配置文件參數名稱配置文件樣例
gflget_file_listget_file_list: true
keep_pagecachekeep_pagecachekeep_pagecache: true
nno_checkno_check: true
disable_check_vdirdisable_check_vdirdisable_check_vdir: true
async_dioasync_dioasync_dio: true
skip_ne_dir_lookupskip_ne_dir_lookskip_ne_dir_look: true
lenable_localenable_local: true
wbwritebackwriteback: true
direct_readdirect_readdirect_read: true
enable_md5enable_md5enable_md5: true
debugdebugdebug: true
-o allow_otherallow_otherallow_other: true
enable_load_dentriesenable_load_dentriesenable_load_dentries:true
disable_async_readdisable_async_readdisable_async_read:true
retryretryretry: 66
parallelparallelparallel: 77
disable_removedisable_removedisable_remove: true
congestion_thresholdcongestion_thresholdcongestion_threshold: 88
max_backgroundmax_backgroundmax_background: 99
uiduiduid=100
gidgidgid :100
etagetagetag :100
dcache_timeoutdcache_timeoutdcache_timeout: 2h
entry_timeoutentry_timeoutentry_timeout: 3h
attr_timeoutattr_timeoutattr_timeout: 4h
perf_dumpperf_dumpattr_timeout: 5h
log_max_agelog_max_agelog_max_age: 6h
log_dirlog_dirlog_dir:/a/b/c
prefixprefixprefix: /a/b/c
levellevellevel: debug
storage_classstorage_classstorage_class: STANDARD
plocal_pathlocal_path:/a/b/c
readaheadreadaheadreadahead: 8m
max_cache_per_filemax_cache_per_filemax_cache_per_file: 1024m
cache_dbcache_dbcache_db: leveldb:/data/us3fs_cachedb
local_writelocal_writelocal_write: true
max_local_file_sizemax_local_file_sizemax_local_file_size: 32M
finish_write_when_releasefinish_write_when_releasefinish_write_when_release: true
read_after_write_finishread_after_write_finishread_after_write_finish: true
enable_remote_cacheenable_remote_cacheenable_remote_cache: true
cache_dirscache_dirscache_dirs: /mnt/nvme01,/mnt/nvme02
cache_size_limitcache_size_limitcache_size_limit: 100
master_addrmaster_addrmaster_addr: :
data_portdata_portdata_port: 3333
page_sizepage_sizepage_size: 8388608
fuse_session_cntfuse_session_cntfuse_session_cnt: 4


掛載參數配置在配置文件樣例 編輯/etc/us3fs/us3fs.yaml(如果沒有該目錄需要自行創(chuàng)建)依據具體需求將掛載參數寫在配置文件,簡化掛載命令


access_key: ************************************secret_key: ************************************endpoint: ufile.cn-north-02.ucloud.cnhosts: []CopyErrorSuccess

選項列表

WinFsp

選項名稱描述
oWinFsp支持的option參數
dir_info_timeout目錄緩存的超時時間,默認5s
file_info_timeout文件緩存的超時時間,默認5s
volume_info_timeout卷信息的超時時間,默認5s
keep_filecache是否把文件放入緩存

FUSE

選項名稱描述
oFUSE支持的option參數
entry_timeout指定fuse緩存被查找的文件名的時間
默認為5min
attr_timeout指定fuse緩存文件/目錄屬性的時間
默認為5min
disable_async_read關閉fuse kernel預讀使用異步模式。默認開啟
wb指定寫入使用writeback方式。不支持覆蓋寫/追加寫
max_background指定fuse kernel的max_background參數(fuse kernel版本>=7.13),
目前fuse usespace最多支持1024(默認:64),該參數能提升direct io的并行度
congestion_threshold指定fuse kernel(fuse kernel版本>=7.13)的congestion_threshold參
數,目前fuse usespace最多支持768(默認:48),該參數會觸發(fā)并行IO的擁塞控制
async_dio開啟fuse內核的async_dio參數,默認關閉async_dio。該參數開啟后,
fuse kernel對direct io進行異步處理
keep_pagecache開啟pagecache,文件打開時會根據inode的修改時間以及大小變化決
定是否更新,所以請注意entry_timeout和dcache_timeout參數對此會
有一定影響,使得未能及時感知到文件修改時間、大小變化


fuse常用選項列表(與-o一起使用)


選項名稱描述
allow_other指定文件系統(tǒng)可以所有用戶訪問
默認關閉
ro指定當前文件系統(tǒng)為只讀

使用方式

-o option=valueCopyErrorSuccess

OS(Object Storage)

選項名稱描述
dcache_timeoutdentry cache在us3fs中的緩存時長
默認為5min
retry請求失敗后重試次數,默認5次
parallelI/O并發(fā)線程數
默認20個
debug指定用戶態(tài)fuse日志級別為debuy
默認關閉
level指定us3fs日志級別
默認為Info級別
readahead預讀大小。 例如:1m/1k/1(默認:“0”)
etag檢查上傳數據的 etag所占百分比。 值是百分比(0~100)(默認值:50)
passwd指定賬戶文件,默認路徑/etc/us3fs/us3fs.yaml // windows 平臺自定義
enable_md5在http請求頭中增加md5校驗,默認關閉
uid指定文件所屬的默認用戶,默認當前用戶
gid指定文件所屬的默認用戶組,默認當前用戶組
disable_check_vdir禁用虛擬目錄檢測
update更新us3fs版本,新版本路徑為/bin/us3fs
n掛載時不檢查bucket權限,如果沒有所在地域沒有列表服務可開啟
l開啟后對小文件使用本地目錄做緩存,異步上傳。具體使用示例見小文件場景
p指定小文件異步上傳的本地緩存目錄
prefix指定掛載的bucket前綴目錄,默認為空
gfl對于沒有ListObjects API支持的Endpoint, 該參數可以繞過,通過PrefixFileList API模擬
direct_read開啟后,繞過us3fs內部緩存組織模塊,直接讀取us3數據,
對于被頻繁訪問的文件會有一定性能降低,反之有利于降低時延
perf_dump指定時間周期輸出時延統(tǒng)計信息,默認周期是1hour
skip_ne_dir_lookup跳過非必要的目錄檢查,目前過濾支持".jpe"、".jpeg"、".png"、
".gz"、".tgz"、".gz"、".tgz"、".log"、".plot"、".js"、".html"、
".css"、".apk"為后綴的文件,需要確保bucket下沒有用以上后綴
作為目錄后綴的情況
storage_class指定寫入US3中文件的存儲類型,支持STANDARD(標準), IA(低頻)兩種。 (default: STANDARD)
cache_db指定本地存儲us3fs元數據cache的方式及路徑,格式為:leveldb:/data/us3fs_cachedb
finish_write_when_release開啟后,支持文件異步結束上傳,用于支持一個fd有多次flush的場景
read_after_write_finish開啟后,讀取文件時,如果文件正在寫入,會等待文件寫入完成后才返回讀的內容
local_write開啟后,寫入的數據會暫存到本地文件系統(tǒng)后再異步上傳到服務端
max_local_file_size和 local_write搭配使用,指定能寫入到本地文件系統(tǒng)的最大文件大?。J值:32M)

MISC

選項名稱描述
help, h查看幫助
f掛載時啟用前臺模式,相關輸出會打印到標準輸出

windows下-f參數無效

使用示例

  • entry_timeout, attr_timeout, dcache_timeout:

設置dcache_timeout可增加文件/目錄屬性在內存中的有效時間,增強使用體驗。建議entry_timeout , attr_timeout設置時間小于dcache_timeout

注:開啟緩存后,可能造成用戶讀取目錄的內容和實際bucket中的內容不一致。默認為開啟,需要關閉請設置為0s

示例:ls包含10000個文件的目錄耗時

[root@10-9-120-211 ~]# us3fs --dcache_timeout=60s --entry_timeout=60s --attr_timeout=60s <your_bucket> <mountpoint> [root@10-9-120-211 ~]# time ls -la <your_dir> | wc -l10003real 0m5.964suser 0m0.033ssys 0m0.232s[root@10-9-120-211 ~]#[root@10-9-120-211 ~]#[root@10-9-120-211 ~]# time ls -la <your_dir> | wc -l10003real 0m0.872suser 0m0.029ssys 0m0.133sCopyErrorSuccess

disable_async_read

默認讀取模式為異步,同步讀取性能較差。

示例如下:

[root@10-9-120-211 ~]# us3fs --disable_async_read <your_bucket> <mountpoint> [root@10-9-120-211 ~]# dd if=<your_file> of=/dev/null bs=4M count=1010+0 records in10+0 records out41943040 bytes (42 MB, 40 MiB) copied, 10.2345 s, 4.1 MB/s[root@10-9-120-211 ~]# us3fs <your_bucket> <mountpoint> [root@10-9-120-211 ~]# dd if=<your_file> of=/dev/null bs=4M count=1010+0 records in10+0 records out41943040 bytes (42 MB, 40 MiB) copied, 0.685801 s, 61.2 MB/sCopyErrorSuccess

parallel

增大并發(fā)數可提升讀寫性能,相應的也行增加系統(tǒng)資源占用。

示例如下:

// 默認并發(fā)數20[root@10-9-120-211 ~]# us3fs <your_bucket> <mountpoint> [root@10-9-120-211 ~]# dd if=/dev/zero of=<your_file> bs=4M count=10241024+0 records in1024+0 records out4294967296 bytes (4.3 GB, 4.0 GiB) copied, 25.5351 s, 168 MB/s// 調整并發(fā)數為32[root@10-9-120-211 ~]# us3fs --parallel=32 <your_bucket> <mountpoint> [root@10-9-120-211 ~]# dd if=/dev/zero of=<your_file> bs=4M count=10241024+0 records in1024+0 records out4294967296 bytes (4.3 GB, 4.0 GiB) copied, 18.3614 s, 234 MB/sCopyErrorSuccess

readahead

調整預讀窗口大小對大文件的順序讀有較大影響,建議在16m~32m,但會增加內存消耗,可以適當縮小預讀窗口。

示例如下:

// 默認預讀大小16MB [root@10-9-120-211 ~]# dd if=<your_file> of=/dev/null bs=4M count=1024 1024+0 records in 1024+0 records out 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 60.0498 s, 71.5 MB/s// 調整預讀大小為32MB [root@10-9-120-211 ~]# us3fs --readahead=32m <your_bucket> <mountpoint> [root@10-9-120-211 ~]# dd if=<your_file> of=/dev/null bs=4M count=1024 1024+0 records in 1024+0 records out 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 37.6013 s, 114 MB/sCopyErrorSuccess

場景化參數設置

性能相關參數

parallel:設置并發(fā)線程,對cpu負載有一定影響。建議設置在20~40較為合理
critical:寫入文件時啟用本地etag校驗,相比未開啟會提高約50%的cpu占用。

readahead:預讀窗口大小,由于fuse自身有讀寫窗口的限制,一定的預讀大小對讀取性能有顯著提升。建議設置在16m~32m,但會增加內存消耗,可以適當縮小預讀窗口。

keep_pagecache: 盡可能緩存數據內容在vfs pagecache中,直到文件的修改時間和大小發(fā)生變化,才無效掉pagecache中的歷史數據。

wb: 該參數會使得寫入的IO會盡量在pagecache中合并,然后以大IO(默認128K)發(fā)送到us3fs。

fuse_session_cnt: 設置與內核fuse模塊通信的連接數,對cpu和內存負載有一定影響,建議在資源空閑的機器上可開啟,并將數量設置在CPU核數以內,開啟后讀寫性能都有一定程度的提升

小文件場景

對于大量小文件場景,如果對性能有要求,可指定-l開啟本地本地緩存。當啟用本地緩存后,us3fs掛載后首先會將指定緩存目錄下已存在的所有小于等于4MB的文件按照其路徑上傳到bucket中。當寫入文件大小不大于4MB,文件會嘗試寫入本地緩存目錄,寫入成功后即返回,后端異步上傳到us3。寫入失?。ㄈ鐧嘞薏蛔悖臻g不足等)則仍然使用同步方式寫入us3對象存儲

注:異步上傳可能出現寫入后端失敗,us3fs會一直重試直到寫入成功。

高讀吞吐場景

cache_dirs: 設置本地讀緩存磁盤,推薦使用本地nvme盤來存放讀緩存內容,可設置多個盤,使用 , 號分割,注意緩存盤盡量不要使用系統(tǒng)盤,避免由于瞬間的IO上漲導致系統(tǒng)hang住,推薦使用獨立的本地nvme盤(盤的讀寫吞吐能在2GB+)。

cache_size_limit: 設置緩存盤存儲量使用上限,當緩存的內容達到該上限時,會進行LRU淘汰

page_size: 在開啟本地讀緩存功能時,需要將page_size從默認的1048576調整到8388608

共享讀緩存

當多個掛載點之間需要共享讀緩存內容時,可以通過執(zhí)行

us3fs run-master --listen_addr 192.168.0.10:6667CopyErrorSuccess

命令來啟動一個master節(jié)點運行,同時將其余的掛載點的 master_addr 參數設置為 192.168.0.10:6667, 這樣各個掛載點會同該master定期保持心跳,這一組掛載點將會成為一個小型的讀緩存集群

     enable_remote_cache: 當一個掛載點開啟該參數后,其余的掛載點就可能會連接上它檢查是否有緩存數據可讀,當發(fā)現目標數據存在時,會嘗試從該掛載點讀取數據內容

     data_port: 當一個掛載點開啟enable_remote_cache后,暴露在哪個端口對外進行訪問

自動掛載

推薦的最佳實踐方案是采用systemctl來保證服務異常退出,或者機器重啟后能重新掛載us3fs,但需要注意Linux(Windows平臺暫未提供方案)的發(fā)行版本是否支持systemctl:

Ubuntu >= 15.04

Centos、RHEL >= 7

滿足系統(tǒng)要求后,經過如下幾個簡單步驟即可:


1.設置配置

在/etc/systemd/system/目錄下創(chuàng)建名為us3fs.service的文件,并增加如下內容

[Unit]Description=US3FS (User Space FileSystem for US3)Requires=network-online.targetAfter=network-online.target[Service]Type=forkingUser=<user> Group=<group> Restart=alwaysRestartSec=10ExecStart=/bin/us3fs --passwd=/etc/us3fs/us3fs.conf --keep_pagecache <your_bucket> <mountpoint> ExecStop=/bin/umount <monutpoint> [Install]WantedBy=multi-user.targetCopyErrorSuccess

User為需要訪問掛載點的用戶。如root。

Group為需要訪問掛載點的用戶組。如root。

ExecStart為掛載命令,按照需要自行填寫

執(zhí)行systemctl daemon-reload配置則會生效。


服務啟用或停止

執(zhí)行systemctl start us3fs.service啟動服務;

執(zhí)行systemctl stop us3fs.service停止服務;

執(zhí)行systemctl restart us3fs.service重啟服務;

執(zhí)行systemctl status us3fs.service查看服務狀態(tài);


設置為開機自啟動

執(zhí)行systemctl enable us3fs.service;




對象存儲 S3

免費咨詢獲取折扣

Loading