更新時(shí)間:2021-06-10 16:26:36 來源:動(dòng)力節(jié)點(diǎn) 瀏覽2371次
FastDFS是一個(gè)開源的輕量級(jí)分布式文件系統(tǒng),它對(duì)文件進(jìn)行管理,功能包括:文件存儲(chǔ)、文件同步、文件訪問(文件上傳、文件下載)等,解決了大容量存儲(chǔ)和負(fù)載均衡的問題。特別適合以文件為載體的在線服務(wù),如相冊(cè)網(wǎng)站、視頻網(wǎng)站等等。
FastDFS的安裝和使用
(1)安裝準(zhǔn)備軟件
yum install gcc-c++ perl
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl--devel
yum install libevent
(2)下載安裝包
Nginx-1.5.1
libfastcommon-1.0.38.tar.gz
fastdfs-5.11.tar.gz
fastdfs-nginx-module-1.20.tar.gz
(3)解壓nginx安裝包
tar -zxvf nginx-1.5.1.tar.gz
(4)創(chuàng)建和tracker和storage目錄
mkdir /usr/local/nginx/tracker
mkdir /usr/local/nginx/storage
(5)解壓libfastcommon安裝包
tar -zxvf libfastcommon-1.0.38.tar.gz
(6)編譯并安裝libfastcommon
# 進(jìn)入nginx-1.7.4目錄
cd libfastcommon-1.0.38
./make.sh
./make.sh install
(7)解壓fastdfs安裝包
tar -zxvf fastdfs-5.11.tar.gz
(8)編譯并安裝fastdfs
# 進(jìn)入nginx-1.7.4目錄
cd fastdfs-5.11
./make.sh
./make.sh install
(9)驗(yàn)證是否安裝成功
ll /etc/init.d/ | grep fdfs
# 出現(xiàn)以下內(nèi)容說明安裝成功
-rwxr-xr-x. 1 root root 961 Apr 28 09:59 fdfs_storaged
-rwxr-xr-x. 1 root root 963 Apr 28 09:59 fdfs_trackerd
[root@localhost fastdfs-5.11]# cd /etc/fdfs/
[root@localhost fdfs]# cp tracker.conf.sample tracker.conf
[root@localhost fdfs]# cp storage.conf.sample storage.conf
(10)復(fù)制配置文件模板
cd /etc/fdfs/
cp tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
(11)配置fdfs_trackerd
vi /etc/fdfs/tracker.conf
# the base path to store data and log files
base_path=/usr/local/nginx/tracker
(12)啟動(dòng)fdfs_trackerd
service fdfs_trackerd start
ps -ef | grep fdfs_trackerd
(13)設(shè)置開機(jī)自啟動(dòng)fdfs_trackerd
chkconfig fdfs_trackerd on
(14)配置fdfs_storaged
vi /etc/fdfs/storage.conf
# the base path to store data and log files
base_path=/usr/local/nginx/storage
store_path0=/usr/local/nginx/storage
tracker_server=192.168.0.208:22122
(15)啟動(dòng)fdfs_storaged
service fdfs_storaged start
ps -ef | grep fdfs_storaged
(16)設(shè)置開機(jī)自啟動(dòng)fdfs_storaged
chkconfig fdfs_storaged on
(17)開放防火墻相關(guān)端口
firewall-cmd --add-port=22122/tcp --permanent
firewall-cmd --add-port=23000/tcp --permanent
firewall-cmd --reload
(18)解壓fastdfs-nginx-module安裝包
tar -xzvf fastdfs-nginx-module-1.20.tar.gz
cd fastdfs-nginx-module-1.20/src
(19)配置fastdfs-nginx-module
vi config
#
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
(20)配置nginx與FastDFS關(guān)聯(lián)
cp mod_fastdfs.conf /etc/fdfs/
vi /etc/fdfs/mod_fastdfs.conf
# 修改以下內(nèi)容
connect_timeout=20
tracker_server=192.168.0.208:22122
url_have_group_name=true
store_path0=/usr/local/nginx/storage
(21)拷貝相關(guān)配置文件
cd /root/FastDFS/fastdfs-5.11/conf
cp http.conf mime.types /etc/fdfs/
(22)編譯nginx
cd /root/nginx-1.16.1
./configure --add-module=/root/FastDFS/fastdfs-nginx-module-1.20/src/
make
make install
(23)配置nginx
vi nginx.conf
# 添加下面的內(nèi)容
location ~/group([0-9])/ {
ngx_fastdfs_module;
}
(24)重啟nginx
./nginx -s stop
./nginx
(25)nginx自啟動(dòng)
chmod 777 /etc/init.d/nginx
chkconfig --add /etc/init.d/nginx
chkconfig nginx on
以上就是動(dòng)力節(jié)點(diǎn)小編介紹的"FastDFS安裝和使用",希望對(duì)大家有幫助,如有疑問,請(qǐng)?jiān)诰€咨詢,有專業(yè)老師隨時(shí)為您服務(wù)。
0基礎(chǔ) 0學(xué)費(fèi) 15天面授
有基礎(chǔ) 直達(dá)就業(yè)
業(yè)余時(shí)間 高薪轉(zhuǎn)行
工作1~3年,加薪神器
工作3~5年,晉升架構(gòu)
提交申請(qǐng)后,顧問老師會(huì)電話與您溝通安排學(xué)習(xí)