FastDFS存储服务器部署

准备安装包

/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
    原文作者:ymyang
    原文地址: https://segmentfault.com/a/1190000005911392
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞