FastDFS_v5.08.tar.gz:FastDFS源碼
libfastcommon-master.zip:(從 FastDFS 和 FastDHT 中提取出來的公共 C 函數(shù)庫)
fastdfs-nginx-module-master.zip:storage節(jié)點(diǎn)http服務(wù)nginx模塊
nginx-1.10.0.tar.gz:Nginx安裝包
ngx_cache_purge-2.3.tar.gz:圖片緩存清除Nginx模塊(集群環(huán)境會用到)
一、所有tracker和storage節(jié)點(diǎn)都執(zhí)行如下操作
1、安裝所需的依賴包
yum install make cmake gcc gcc-c++
2、安裝libfatscommon
cd /usr/local/src
安裝unzip 命令:
yum install -y unzip zip unzip libfastcommon-master.zip
編譯、安裝
cd libfastcommon-master
./make.sh
./make.sh install
3、安裝FastDFS
cd /usr/local/src tar -xzvf FastDFS_v5.08.tar.gz
cd FastDFS
./make.sh
./make.sh install
采用默認(rèn)安裝方式,相應(yīng)的文件與目錄如下:
1> 服務(wù)腳本:
/etc/init.d/fdfs_storaged /etc/init.d/fdfs_trackerd
2> 配置文件(示例配置文件):
ll /etc/fdfs/
-rw-r--r-- 1 root root 1461 1月 4 14:34 client.conf.sample
-rw-r--r-- 1 root root 7927 1月 4 14:34 storage.conf.sample
-rw-r--r-- 1 root root 7200 1月 4 14:34 tracker.conf.sample
3> 命令行工具(/usr/bin目錄下)
-rwxr-xr-x 1 root root 260584 1月 4 14:34 fdfs_appender_test
-rwxr-xr-x 1 root root 260281 1月 4 14:34 fdfs_appender_test1
-rwxr-xr-x 1 root root 250625 1月 4 14:34 fdfs_append_file
-rwxr-xr-x 1 root root 250045 1月 4 14:34 fdfs_crc32
-rwxr-xr-x 1 root root 250708 1月 4 14:34 fdfs_delete_file
-rwxr-xr-x 1 root root 251515 1月 4 14:34 fdfs_download_file
-rwxr-xr-x 1 root root 251273 1月 4 14:34 fdfs_file_info
-rwxr-xr-x 1 root root 266401 1月 4 14:34 fdfs_monitor
-rwxr-xr-x 1 root root 873233 1月 4 14:34 fdfs_storaged
-rwxr-xr-x 1 root root 266952 1月 4 14:34 fdfs_test
-rwxr-xr-x 1 root root 266153 1月 4 14:34 fdfs_test1
-rwxr-xr-x 1 root root 371336 1月 4 14:34 fdfs_trackerd
-rwxr-xr-x 1 root root 251651 1月 4 14:34 fdfs_upload_appender
-rwxr-xr-x 1 root root 252781 1月 4 14:34 fdfs_upload_file
二、配置tracker服務(wù)器
1> 復(fù)制tracker樣例配置文件,并重命名
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
2> 修改tracker配置文件
vim /etc/fdfs/tracker.conf
# 修改的內(nèi)容如下:
disabled=false # 啟用配置文件
port=22122 # tracker服務(wù)器端口(默認(rèn)22122)
base_path=/fastdfs/tracker # 存儲日志和數(shù)據(jù)的根目錄
其它參數(shù)保留默認(rèn)配置, 具體配置解釋可參考官方文檔說明:
http://bbs.chinaunix.net/thread-1941456-1-1.html
3> 創(chuàng)建base_path指定的目錄
mkdir -p /fastdfs/tracker
4> 防火墻中打開tracker服務(wù)器端口( 默認(rèn)為 22122)
vi /etc/sysconfig/iptables
附加:若/etc/sysconfig 目錄下沒有iptables文件可隨便寫一條iptables命令配置個(gè)防火墻規(guī)則:如:
iptables -P OUTPUT ACCEPT
然后用命令:service iptables save 進(jìn)行保存,默認(rèn)就保存到 /etc/sysconfig/iptables 文件里。這時(shí)既有了這個(gè)文件。防火墻也可以啟動了。接下來要寫策略,也可以直接寫在/etc/sysconfig/iptables 里了。
添加如下端口行:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT
重啟防火墻
service iptables restart
5> 啟動tracker服務(wù)器
/etc/init.d/fdfs_trackerd start
初次啟動,會在/fastdfs/tracker目錄下生成logs、data兩個(gè)目錄。
drwxr-xr-x 2 root root 4096 1月 4 15:00 data drwxr-xr-x 2 root root 4096 1月 4 14:38 logs
檢查FastDFS Tracker Server是否啟動成功:
ps -ef | grep fdfs_trackerd

三、配置storage服務(wù)器
1> 復(fù)制storage樣例配置文件,并重命名
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
2> 編輯配置文件
vi /etc/fdfs/storage.conf
# 修改的內(nèi)容如下:
disabled=false # 啟用配置文件
port=23000 # storage服務(wù)端口
base_path=/fastdfs/storage # 數(shù)據(jù)和日志文件存儲根目錄
store_path0=/fastdfs/storage # 第一個(gè)存儲目錄
tracker_server=ip01:22122 # tracker服務(wù)器IP和端口
http.server_port=8888# http訪問文件的端口 現(xiàn)可不配
其它參數(shù)保留默認(rèn)配置, 具體配置解釋可參考官方文檔說明:
http://bbs.chinaunix.net/thread-1941456-1-1.html
3> 創(chuàng)建基礎(chǔ)數(shù)據(jù)目錄
mkdir -p /fastdfs/storage
4> 防火墻中打開storage服務(wù)器端口( 默認(rèn)為 23000)
vi /etc/sysconfig/iptables
添加如下端口行:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 23000 -j ACCEPT
重啟防火墻
service iptables restart
重點(diǎn):啟動
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
/usr/local/bin/fdfs_storage /etc/fdfs/storage.conf restart