FastDFS安裝配置
第一步:安裝FastDFS
1.解壓 FastDFS_v4.07.tar.gz ==>FastDFS
2. cd FastDFS ==>vim make.sh
修改以下內容
TARGET_PREFIX=/usr/local/fdfs
TARGET_CONF_PATH=/usr/local/fdfs/conf
mkdir -p /usr/local/fdfs
mkdir -p /usr/local/fdfs/conf
修改
if [ "$uname" = "Linux" ]; then
if [ "$WITH_LINUX_SERVICE" = "1" ]; then
if [ ! -d $TARGET_CONF_PATH ]; then
mkdir -p $TARGET_CONF_PATH
cp -f conf/tracker.conf $TARGET_CONF_PATH
cp -f conf/storage.conf $TARGET_CONF_PATH
cp -f conf/client.conf $TARGET_CONF_PATH
cp -f conf/http.conf $TARGET_CONF_PATH
cp -f conf/mime.types $TARGET_CONF_PATH
fi
cp -f init.d/fdfs_trackerd /etc/rc.d/init.d/
cp -f init.d/fdfs_storaged /etc/rc.d/init.d/
/sbin/chkconfig --add fdfs_trackerd
/sbin/chkconfig --add fdfs_storaged
fi
fi
第二步:安裝libevent-2.0.19-stable.tar.gz
1.解壓 libevent-2.0.19-stable.tar.gz==>libevent-2.0.19-stable
2.進入libevent-2.0.19-stable 安裝
./configure --prefix=/usr/local/libevent
make
make install
3. 添加軟連接
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /lib64/libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /lib/libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/local/lib64/libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/local/lib/libevent-2.0.so.5
第三步:安裝FastDFS
./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib
./make.sh install
第四步:如果/usr/local/fastdfs/conf沒有fdfs_trackerd和fdfs_storaged這兩個文件,就從 /FastDFS/tracker 和FastDFS/storage/目錄下復制過去
第五步:修改配置
mkdir -p /home/softinstall/data/tracker
1. 修改 tracker.conf
base_path=/home/softinstall/data/tracker
bind_addr=192.168.9.169
1.1 修改storage_ids.conf
100001 group1 192.168.9.169
2. 啟動tracker
./fdfs_trackerd ../conf/tracker.conf
查看22122端口是否啟動起來
第六步:配置storage
mkdir -p /home/softinstall/data/store
mkdir -p /home/softinstall/data/store/store0
mkdir -p /home/softinstall/data/store/store1
mkdir -p /home/softinstall/data/store/store2
1.修改storage.conf
base_path=/home/softinstall/data/store
store_path_count=3
store_path0=/home/softinstall/data/store/store0
store_path1=/home/softinstall/data/store/store1
store_path2=/home/softinstall/data/store/store2
tracker_server=192.168.9.169:22122
#限6*6=36個目錄 默認256*256
subdir_count_per_path=6
2. 啟動storage
./fdfs_storaged ../conf/storage.conf
查看23000端口是否啟動
第七步:安裝nginx+fastdfs模塊
1. 安裝pcre-8.32
進入pcre-8.32
./configure
make
make install
安裝如果有問題缺省某些包,可以執行:
yum groupinstall "Development Tools"
第八步:解壓fastdfs-nginx-module_v1.15.tar.gz和 nginx-1.4.2.tar.gz
1.進入 fastdfs-nginx-module_v1.15/src
vim fastdfs-nginx-module_v1.15/src/config
修改成以下內容
ngx_addon_name=ngx_http_fastdfs_module
HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
CORE_INCS="$CORE_INCS /usr/local/fdfs/include/fastdfs /usr/local/fdfs/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/local/fdfs/lib -lfastcommon -lfdfsclient"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/usr/local/fdfs/conf/mod_fastdfs.conf\"'"
2. 安裝
進入nginx-1.4.2目錄
./configure --prefix=/home/softinstall/nginx/nginx-fastdfs-install --with-pcre=/home/softinstall/nginx/pcre-8.32 --add-module=/home/softinstall/nginx/fastdfs-nginx-module/src
安裝中如果有問題
可以執行安裝以下包:yum -y install gcc gcc-c++ zlib-devel openssl-devel
3.配置nginx.conf
進入nginx-fastdfs-install/conf
vim nginx.conf 配置以下內容
location /M00 {
root /home/softinstall/data/store/store0/data;
ngx_fastdfs_module;
}
location /M01 {
root /home/softinstall/data/store/store1/data;
ngx_fastdfs_module;
}
location /M02 {
root /home/softinstall/data/store/store2/data;
ngx_fastdfs_module;
}
4.配置mod_fastdfs.conf
mkdir -p /home/softinstall/data/nginx_mod
進入 /usr/local/fdfs/conf目錄
vim mod_fastdfs.conf
base_path=/home/softinstall/data/nginx_mod
tracker_server=192.168.9.169:22122
store_path_count=3
store_path0=/home/softinstall/data/store/store0
store_path1=/home/softinstall/data/store/store1
store_path2=/home/softinstall/data/store/store2
5. 啟動nginx
進入 /home/softinstall/nginx/nginx-fastdfs-install/sbin
./nginx
如果啟動找不到
error while loading shared libraries: libfdfsclient.so: cannot open shared object file: No such file or directory
error while loading shared libraries: libfastcommon.so: cannot open shared object file: No such file or directory
請使用以下軟連接
ln -s /usr/local/fdfs/lib/libfastcommon.so /usr/lib/libfastcommon.so
ln -s /usr/local/fdfs/lib/libfastcommon.so /usr/lib64/libfastcommon.so
ln -s /usr/local/fdfs/lib/libfdfsclient.so /usr/lib64/libfdfsclient.so
ln -s /usr/local/fdfs/lib/libfdfsclient.so /usr/lib/libfdfsclient.so
==========================fastDHT================================
【第一步:】安裝 Berkley DB
【1.】 tar -zxvf db-4.7.25.tar.gz
進入 db-4.7.25/build_unix
../dist/configure --prefix=/usr
【第二步:】安裝FastDHT
mkdir -p /usr/local/fdht
mkdir -p /usr/local/fdht/conf
1. tar -zxvf FastDHT_v1.23.tar.gz
進入 FastDHT_v1.23
vim make.sh
修改
TARGET_PREFIX=/usr/local/fdht
TARGET_CONF_PATH=/usr/local/fdht/conf
if [ "$1" = "install" ]; then
cd ..
cp -f restart.sh $TARGET_PREFIX/bin
cp -f stop.sh $TARGET_PREFIX/bin
if [ "$uname" = "Linux" ]; then
if [ "$WITH_LINUX_SERVICE" = "1" ]; then
if [ ! -d $TARGET_CONF_PATH ]; then
mkdir -p $TARGET_CONF_PATH
cp -f conf/fdhtd.conf $TARGET_CONF_PATH
cp -f conf/fdht_servers.conf $TARGET_CONF_PATH
cp -f conf/fdht_client.conf $TARGET_CONF_PATH
fi
cp -f init.d/fdhtd /etc/rc.d/init.d/
/sbin/chkconfig --add fdhtd
fi
fi
fi
【2.】 安裝
./make.sh
------------------------------------------------------------------------------
如果出現 global.h:18:19: error: event.h: No such file or directory
進入/home/softinstall/fastdfs/libevent-2.0.19-stable然後執行
./configure --prefix=/usr
make
make install
---------------------------------------------------------------------------------
./make.sh install
【3.】 配置fdht
【3.1】 vim /usr/local/fdht/conf/fdhtd.conf
port=11411
bash_path=/home/softinstall/data/fastdht
cache_size = 32MB
store_sub_keys=true
use_storage_id=true
#include /usr/local/fdht/conf/fdht_servers.conf (本行前有#表示打開,如果想關閉此選項,則應該為##開頭)
【3.2】 vim /usr/local/fdht/conf/fdht_server.conf
group_count = 1
group0 = 192.168.9.165:11411
【3.3】 vim /usr/local/fdht/conf/fdht_client.conf
keep_alive=1 (本選項關聯 storaged.conf文件)
base_path=/home/softinstall/data/fastdht
#include /usr/local/fdht/conf/fdht_servers.conf
【3.4】 配置FastDFS 的 storaged.conf文件
vi storaged.conf (默認位置: /usr/local/fdfs/conf/storaged.conf)
check_file_duplicate=1
本配置項解釋: 是否檢測上傳文件已經存在。如果已經存在,則不存在文件內容,建立一個索引鏈接以節省磁盤空間
key_namespace=FastDFS
本配置項解釋: 當上個參數設定為1時 , 在FastDHT中的命名空間
keep_alive=1
本配置項解釋: 長連接配置選項,如果為0則為短連接 1為長連接
#include /usr/local/fdht/conf/fdht_servers.conf
本配置項解釋: 可以通過 #include filename 方式來加載 FastDHT servers 的配置
【3.5】
===========================總體啟動流程======================================
啟動tracker /usr/local/fdfs/bin/fdfs_trackerd /usr/local/fdfs/conf/tracker.conf
停止tracker /usr/local/fdfs/bin/stop.sh /usr/local/fdfs/conf/tracker.conf
啟動storage /usr/local/fdfs/bin/fdfs_storaged /usr/local/fdfs/conf/storage.conf
停止storage /usr/local/fdfs/bin/stop.sh /usr/local/fdfs/conf/storage.conf
啟動nginx /home/softinstall/nginx/nginx-fastdfs-install/sbin/nginx
啟動
/usr/local/fdht/bin/fdhtd /usr/local/fdht/conf/fdhtd.conf
停止
/usr/local/fdht/bin/stop.sh /usr/local/fdht/conf/fdhtd.conf
測試 是否有錯誤:
/usr/local/fdht/bin/fdht_test /usr/local/fdht/conf/fdht_client.conf
=================================================================