FastCFS基于塊存儲的通用分布式文件系統(tǒng)
FastCFS 是一款基于塊存儲的通用分布式文件系統(tǒng),可以作為MySQL、PostgresSQL、Oracle等數(shù)據(jù)庫和云平臺的后端存儲。
支持的操作系統(tǒng)
- Linux: Kernel version >= 3.10 (完全支持)
- MacOS or FreeBSD (僅支持服務端,不支持FUSE)
依賴
- libfuse (版本 3.9.4 或更高版本)
- libfastcommon (tag: V1.0.45)
- libserverframe (tag: V1.1.1)
- fastDIR (tag: V1.1.0)
- faststore (tag: V1.1.0)
- FastCFS (tag: V1.1.0)
安裝
libfuse可以采用腳本libfuse_setup.sh一鍵編譯和安裝。
libfastcommon、libserverframe、fastDIR、faststore和FastCFS 五個安裝包可采用 fastcfs.sh 腳本統(tǒng)一安裝配置,也可以按照5.1 - 5.6部分獨立安裝配置。
統(tǒng)一安裝方式
git clone https://github.com/happyfish100/FastCFS.git; cd FastCFS/
通過執(zhí)行fastcfs.sh腳本,可自動從github倉庫拉取或更新五個倉庫代碼,按照依賴順序進行編譯、安裝,并能根據(jù)配置文件模版自動生成集群相關配置文件。
fastcfs.sh 命令參數(shù)說明:
- pull -- 從github拉取或更新代碼庫(拉取到本地build目錄)
- makeinstall -- 順序編譯、安裝代碼庫(make && make install)
- init -- 初始化集群目錄、配置文件(已存在不會重新生成)
- clean -- 清除已編譯程序文件(相當于make clean)
一鍵搭建(包括部署和運行)demo環(huán)境(需要root身份執(zhí)行):
./helloWorld.sh --prefix=/usr/local/fastcfs-test
或執(zhí)行如下命令(需要root身份執(zhí)行):
./libfuse_setup.sh
./fastcfs.sh pull
./fastcfs.sh makeinstall
IP=$(ifconfig -a | grep -w inet | grep -v 127.0.0.1 | awk '{print $2}' | tr -d 'addr:' | head -n 1)
./fastcfs.sh init \
--dir-path=/usr/local/fastcfs-test/fastdir \
--dir-server-count=1 \
--dir-host=$IP \
--dir-cluster-port=11011 \
--dir-service-port=21011 \
--dir-bind-addr= \
--store-path=/usr/local/fastcfs-test/faststore \
--store-server-count=1 \
--store-host=$IP \
--store-cluster-port=31011 \
--store-service-port=41011 \
--store-replica-port=51011 \
--store-bind-addr= \
--fuse-path=/usr/local/fastcfs-test/fuse \
--fuse-mount-point=/usr/local/fastcfs-test/fuse/fuse1
注:--fuse-mount-point為mount到本地的路徑,通過這個mount point對FastCFS進行文件存取訪問。
FCFS_SHELL_PATH=$(pwd)/build/shell
$FCFS_SHELL_PATH/fastdir-cluster.sh restart
$FCFS_SHELL_PATH/faststore-cluster.sh restart
$FCFS_SHELL_PATH/fuse.sh restart
上述操作完成后,通過命令 df -h 可以看到FastCFS掛載的文件目錄。
libfastcommon
git clone https://github.com/happyfish100/libfastcommon.git; cd libfastcommon/ git checkout master ./make.sh clean && ./make.sh && ./make.sh install
默認安裝目錄:
/usr/lib64 /usr/lib /usr/include/fastcommon
libserverframe
git clone https://github.com/happyfish100/libserverframe.git; cd libserverframe/ ./make.sh clean && ./make.sh && ./make.sh install
fastDIR
git clone https://github.com/happyfish100/fastDIR.git; cd fastDIR/ ./make.sh clean && ./make.sh && ./make.sh install
faststore
git clone https://github.com/happyfish100/faststore.git; cd faststore/ ./make.sh clean && ./make.sh && ./make.sh install mkdir /etc/fstore/ cp conf/server.conf conf/client.conf conf/servers.conf conf/cluster.conf conf/storage.conf /etc/fstore/
libfuse
構(gòu)建libfuse需要先安裝meson和ninja。安裝meson和ninja需要python3.5及以上版本。
python安裝
包名:python3 python3-pip
Ubuntu下安裝命令:
apt install python3 python3-pip -y
CentOS下安裝命令:
yum install python3 python3-pip -y
meson 和 ninja 安裝
pip3 install meson pip3 install ninja
gcc安裝
Ubuntu下安裝命令:
apt install gcc g++ -y
CentOS下安裝命令:
yum install gcc gcc-c++ -y
libfuse安裝
git clone https://github.com/libfuse/libfuse.git cd libfuse/ git checkout fuse-3.10.1 mkdir build/; cd build/ meson .. meson configure -D prefix=/usr meson configure -D examples=false ninja && ninja install sed -i 's/#user_allow_other/user_allow_other/g' /etc/fuse.conf
FastCFS
git clone https://github.com/happyfish100/FastCFS.git; cd FastCFS/ ./make.sh clean && ./make.sh && ./make.sh install mkdir /etc/fcfs/ cp conf/fuse.conf /etc/fcfs/
配置
為了更好地控制FastCFS的性能,我們通過各種設置參數(shù)為FastCFS提供了高度可配置和可調(diào)節(jié)的行為。
FastCFS的配置由多個子文件組成,其中一個是入口文件,其他文件用于引用。目錄/etc/fstore 是FastCFS配置文件的默認存放位置,但是在單個服務器上安裝多個FastCFS實例時,必須為每個實例指定不同的位置。
FastCFS有以下幾個配置文件:
- server.conf - 服務器全局參數(shù)配置
- cluster.conf - 集群參數(shù)配置
- servers.conf - 服務器組參數(shù)配置
- storage.conf - 存儲參數(shù)配置
- client.conf - 客戶端使用的配置文件,需引用cluster.conf
