FastDFS儲存伺服器部署

ymyang發表於2016-07-08

準備安裝包

/opt/libevent-2.0.22-stable.tar.gz
/opt/FastDFS_v4.06.tar.gz

安裝libevent

cd /opt
tar zxvf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --prefix=/opt/yliyun/libevent/
make && make install

新增lib:

vim /etc/ld.so.conf

新增以下內容:

/opt/yliyun/libevent/lib

執行:

ldconfig

安裝FastDFS

解壓:

cd /opt
tar zxvf FastDFS_v4.06.tar.gz
cd FastDFS

修改編譯配置:

vim make.sh

修改以下內容:

TARGET_PREFIX=/opt/yliyun/fdfs
TARGET_CONF_PATH=/opt/yliyun/fdfs/etc

執行以下命令安裝:

./make.sh  C_INCLUDE_PATH=/opt/yliyun/libevent/include  LIBRARY_PATH=/opt/yliyun/libevent/lib
./make.sh install

FastDFS就成功安裝到/opt/yliyun/fdfs了

新增lib:

vim /etc/ld.so.conf

新增以下內容:

/opt/yliyun/fdfs/lib

執行:

ldconfig

啟動指令碼,從測試伺服器拷貝:

/opt/yliyun/bin/fdfs_trackerd
/opt/yliyun/bin/fdfs_storaged

Nginx安裝

安裝包準備
準備好原始碼包:

/opt/ngx_openresty-1.9.3.2.tar.gz
/opt/fastdfs-nginx-module_v1.15.tar.gz

解壓
執行以下命令解壓安裝包:

cd /opt
tar zxvf fastdfs-nginx-module_v1.15.tar.gz
tar zxvf ngx_openresty-1.9.3.2.tar.gz

修改編譯配置:

vim fastdfs-nginx-module/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 /opt/yliyun/fdfs/include/fastdfs /opt/yliyun/fdfs/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/opt/yliyun/fdfs/lib -lfastcommon -lfdfsclient"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE=`256*1024` -DFDFS_MOD_CONF_FILENAME=`"/opt/yliyun/fdfs/etc/mod_fastdfs.conf"`"

編譯安裝
執行以下命令安裝編譯所需的依賴:

yum install -y pcre-devel openssl-devel

執行以下命令編譯安裝openresty:

mkdir yliyun
cd ngx_openresty-1.9.3.2
./configure --prefix=/opt/yliyun/openresty --add-module=/opt/fastdfs-nginx-module/src/ 
make
make install

openresty就成功安裝到/opt/yliyun/openresty了

資料目錄:

mkdir -pv /data/yliyun/data/g1_data0

日誌目錄:

mkdir -pv /data/yliyun/logs/nginx
mkdir -pv /opt/yliyun/data/tracker
mkdir -pv /opt/yliyun/data/storage

配置修改

FastDFS配置修改

Tracker配置
修改配置:
vim /opt/yliyun/fdfs/etc/tracker.conf

修改以下內容:

base_path=/opt/yliyun/data/tracker

store_group=group1

Storage配置
修改配置:

vim /opt/yliyun/fdfs/etc/storage.conf

修改以下內容:

group_name=group1

base_path=/data/yliyun/logs/fdfs/storage

store_path0=/data/yliyun/data/g1_data0

tracker_server=192.168.1.2:22122

Nginx外掛配置

修改配置:

vim /opt/yliyun/fdfs/etc/mod_fastdfs.conf

修改以下內容:

base_path=/data/yliyun/logs/nginx

tracker_server=192.168.1.2:22122

group_name=group1

store_path0=/data/yliyun/data/g1_data0

log_filename=/data/yliyun/logs/nginx /mod_fdfs.log

Nginx配置修改

修改nginx配置:

vim /opt/yliyun/openrestry/nginx/conf/nginx.conf

新增以下配置:

location ~ /group1/M0[0-9] {
ngx_fastdfs_module;
}

防火牆配置

編輯配置檔案:

vim /etc/sysconfig/iptables

新增以下配置:

-A INPUT -s 10.137.147.0/24 -p tcp --dport 80 -j ACCEPT
-A INPUT -s 10.137.147.0/24 -p tcp --dport 22122 -j ACCEPT
-A INPUT -s 10.137.147.0/24 -p tcp --dport 23000 -j ACCEPT

重啟防火牆:

service iptables restart

相關文章