更新時間:2021-06-10 16:26:36 來源:動力節點 瀏覽2200次
FastDFS是一個開源的輕量級分布式文件系統,它對文件進行管理,功能包括:文件存儲、文件同步、文件訪問(文件上傳、文件下載)等,解決了大容量存儲和負載均衡的問題。特別適合以文件為載體的在線服務,如相冊網站、視頻網站等等。
FastDFS的安裝和使用
(1)安裝準備軟件
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)創建和tracker和storage目錄
mkdir /usr/local/nginx/tracker
mkdir /usr/local/nginx/storage
(5)解壓libfastcommon安裝包
tar -zxvf libfastcommon-1.0.38.tar.gz
(6)編譯并安裝libfastcommon
# 進入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
# 進入nginx-1.7.4目錄
cd fastdfs-5.11
./make.sh
./make.sh install
(9)驗證是否安裝成功
ll /etc/init.d/ | grep fdfs
# 出現以下內容說明安裝成功
-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)復制配置文件模板
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)啟動fdfs_trackerd
service fdfs_trackerd start
ps -ef | grep fdfs_trackerd
(13)設置開機自啟動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)啟動fdfs_storaged
service fdfs_storaged start
ps -ef | grep fdfs_storaged
(16)設置開機自啟動fdfs_storaged
chkconfig fdfs_storaged on
(17)開放防火墻相關端口
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關聯
cp mod_fastdfs.conf /etc/fdfs/
vi /etc/fdfs/mod_fastdfs.conf
# 修改以下內容
connect_timeout=20
tracker_server=192.168.0.208:22122
url_have_group_name=true
store_path0=/usr/local/nginx/storage
(21)拷貝相關配置文件
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
# 添加下面的內容
location ~/group([0-9])/ {
ngx_fastdfs_module;
}
(24)重啟nginx
./nginx -s stop
./nginx
(25)nginx自啟動
chmod 777 /etc/init.d/nginx
chkconfig --add /etc/init.d/nginx
chkconfig nginx on
以上就是動力節點小編介紹的"FastDFS安裝和使用",希望對大家有幫助,如有疑問,請在線咨詢,有專業老師隨時為您服務。
0基礎 0學費 15天面授
有基礎 直達就業
業余時間 高薪轉行
工作1~3年,加薪神器
工作3~5年,晉升架構
提交申請后,顧問老師會電話與您溝通安排學習