新聞中心
1.安裝FastDFS
(一) 安裝tracker
(二) 安裝storage
(三) 測試上傳

一、安裝FastDFS
下載FastDFS,官方下載地址: https://code.google.com/archive/p/fastdfs/downloads 需要翻墻訪問
(一)安裝tracker
-
首先需要安裝libevent
下載libevent 官方下載地址 http://libevent.org/
tar -zxvf libevent-2.0.22-stable.tar.gz //解壓
./configure // 配置
make && make install //編譯安裝
-
安裝tracker
tar -zxvf FastDFS_v4.06.tar.gz //解壓 cd FastDFS/ ./make.sh //編譯 ./make.sh install //安裝安裝完成后 所有的可執(zhí)行文件在/usr/local/bin下,以fdfs開頭,所有配置文件在/etc/fdfs下
vim /etc/fdfs/tracker.conf
只需改動以下幾個參數(shù)即可:
disabled=false #啟用配置文件
bind_addr=192.168.100.110 #綁定tracker 服務(wù)器的IP
port=22122 #設(shè)置tracker的端口號
base_path=base_path=/home/tracker/fastdfs #設(shè)置tracker的數(shù)據(jù)文件和日志目錄(需預(yù)先創(chuàng)建)
http.server_port=8080 #設(shè)置http端口號
#最后一行加上
#include http.conf
修改完成之后保存退出
(注:如需要進(jìn)行性能調(diào)優(yōu),可以參照附錄的配置文件的詳細(xì)說明。)
創(chuàng)建對應(yīng)文件
mkdir /home/tracker
mkdir /home/tracker/fastdfs
把防火墻對應(yīng)的端口打開 這里是22122
因為這里使用的是CentOS 7,防火墻和其他的是不一樣的,這里我們禁用CentOS自帶的Firewalls,下載一個iptables,使用這個
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機(jī)啟動
yum -y install iptables-services
vim /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22122 -j ACCEPT #保存退出 重啟防火墻
systemctl restart iptables.service
4.運行
tracker:/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
確認(rèn)是否啟動成功(查看22122端口是否監(jiān)聽)
netstat -unltp | grep fdfs
5 設(shè)置開機(jī)啟動
vim /etc/rc.d/rc.local
添加運行命令進(jìn)文件
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
到這里tracker就安裝完成了
(二)安裝storage
1、使用剛剛的FastDFS_v4.06.tar.gz 安裝
2、首先需要安裝libevent
下載libevent 官方下載地址 http://libevent.org/
tar -zxvf libevent-2.0.22-stable.tar.gz #解壓
./configure #配置
make && make install #編譯安裝
3、安裝
tar -zxvf FastDFS_v4.06.tar.gz //解壓
cd FastDFS/
./make.sh //編譯
./make.sh install //安裝
4、安裝完成 下面是配置的過程
vim /etc/fdfs/storage.conf
一般需要配置以下項
disabled=false #啟用配置文件
group_name=group1#組名,根據(jù)實際情況修改
bind_addr=192.168.100.111 #ip 配置storage服務(wù)器的ip
port=23000 #設(shè)置storage的端口號
base_path=/home/storage/fastdfs #設(shè)置storage的日志目錄(需預(yù)先創(chuàng)建)
store_path_count=1 #存儲路徑個數(shù),需要和store_path個數(shù)匹配
store_path0=/home/storage/fastdfs #存儲路徑
tracker_server=192.168.100.110:22122 #tracker服務(wù)器的IP地址和端口號
http.server_port=8080 #設(shè)置http端口號
#最后一行加上
#include http.conf
保存退出 (注:如需要進(jìn)行性能調(diào)優(yōu),可以參照附錄的配置文件的詳細(xì)說明。)
創(chuàng)建對應(yīng)目錄
mkdir /home/storage
mkdir /home/storage/fastdfs
5、運行
運行storage之前,先要把防火墻中對應(yīng)的端口打開(本例中為23000)。
yum -y install iptables-services
vim /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 23000 -j ACCEPT
保存退出 重啟防火墻
systemctl restart iptables.service
啟動storage 查看對應(yīng)端口是否開始監(jiān)聽
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf start
看到下面這情況就是啟動成功
確認(rèn)啟動成功后,可以運行fdfs_monitor查看storage服務(wù)器是否已經(jīng)登記到tracker服務(wù)器。
/usr/local/bin/fdfs_monitor /etc/fdfs/storage.conf
12、設(shè)置開機(jī)自動啟動
vim /etc/rc.d/rc.local
將運行命令行添加進(jìn)文件:
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf restart
到這里 storage 安裝完成
(三)測試上傳
1、我們可以先測試一下上傳的功能,到tracker服務(wù)器
2、修改 client.conf 文件
vim client.conf
修改內(nèi)容:
base_path=/home/client/fastdfs #日志和文件存放路徑
tracker_server=192.168.100.110:22122 #tracker 服務(wù)器ip
http.tracker_server_port=8080 #tracker 端口
#include http.conf #最后一行寫成這樣
修改之后保存退出
4、測試上傳
/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /home/admin/Desktop/test.avi
上傳成功。但是現(xiàn)在使用這個URL 還不能訪問到資源。需要配個nginx 才行。我們可以去storage服務(wù)器查看之前對應(yīng)創(chuàng)建的storage數(shù)據(jù)文件夾下面查看
文件已經(jīng)上傳到storage服務(wù)器
由于現(xiàn)在還不能訪問,所以我們需要配 nginx。
網(wǎng)站題目:FastDFS分布式存儲服務(wù)器安裝過程詳解
轉(zhuǎn)載來源:http://www.dlmjj.cn/article/coisihd.html


咨詢
建站咨詢
