美文网首页
Fastdfs安装

Fastdfs安装

作者: QZH_2019 | 来源:发表于2020-03-27 00:28 被阅读0次

1. 安装必备环境

环境准备
libfatscommon:FastDFS分离出的一些公用函数包
FastDFS:FastDFS本体
fastdfs-nginx-module:FastDFS和nginx的关联模块
nginx:发布访问服务

yum install -y gcc gcc-c++
yum install -y libevent

2. 解压

tar -zxvf libfastcommon-1.0.42.tar.gz
cd  libfastcommon-1.0.42
./make.sh
./make.sh install

tar -zxvf fastdfs-6.04.tar.gz
cd fastdfs-6.04
./make.sh
./make.sh install

cp 安装路径/conf/* /etc/fdfs

3. 修改配置文件(服务器1的tracker.conf)

vim tracker.conf

base_path=/usr/local/fastdfs/tracker

mkdir /usr/local/fastdfs/tracker -p

3.1 修改配置文件(服务器2的storage.conf)

vim storage.conf

base_path=/usr/local/fastdfs/storage
store_path0=/usr/local/fastdfs/storage
tracker_server=172.17.0.3:22122

mkdir /usr/local/fastdfs/storage -p

3.2修改配置文件(服务器2的client.conf)

vim client.conf

base_path=/usr/local/fastdfs/client
tracker_server=172.17.0.3:22122
group_name=test_group

mkdir /usr/local/fastdfs/client -p

4. 启动

第一台
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
第二台
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf

5. 检查进程

查看pid

ps -ef | grep tracker

停止

/usr/bin/stop.sh /etc/fdfs/tracker.conf

6. 测试连通性

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/image.jpg

/home/image.jpg为测试文件

7. 配置nginx(与storage配置在一个节点上)

tar -zxvf fastdfs-nginx-module-1.22.tar.gz
cd fastdfs-nginx-module-1.22
cd src
vim config
ngx_addon_name=ngx_http_fastdfs_module

if test -n "${ngx_module_link}"; then
    ngx_module_type=HTTP
    ngx_module_name=$ngx_addon_name
    ngx_module_incs="/usr/include"
    ngx_module_libs="-lfastcommon -lfdfsclient"
    ngx_module_srcs="$ngx_addon_dir/ngx_http_fastdfs_module.c"
    ngx_module_deps=
    CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
    . auto/module
else
    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/include"
    CORE_LIBS="$CORE_LIBS -lfastcommon -lfdfsclient"
    CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
fi
cp mod_fastdfs.conf /etc/fdfs/

nginx环境安装

yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
tar -zxvf nginx-1.16.1.tar.gz
mkdir /var/temp/nginx -p

进入nginx目录:cd nginx-1.16.1

./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--add-module=/root/fastdfs-nginx-module-1.22/src

/root/fastdfs-nginx-module-1.22/src路径一定要写对

make 
make install
cd /etc/fdfs/
vi mod_fastdfs.conf

修改mod_fastdfs.conf

base_path=/usr/local/fastdfs/tmp
tracker_server=172.17.0.3:22122
group_name=test_group
url_have_group_name = true
store0_path=/usr/local/fastdfs/storage

创建文件:

mkdir /usr/local/fastdfs/tmp
cd /usr/local/nginx/conf
vim nginx.conf

修改nginx.conf

server {
    listen       8888;
    server_name  localhost;

    location /test_group/M00 {
            ngx_fastdfs_module;
    }

}

测试:

../sbin/nginx -t
../sbin/nginx

访问图片:
http://127.0.0.1:8888/test_group/M00/00/00/rBEABF58ztqANzPtAAA_9VXxm3k099.jpg

相关文章

网友评论

      本文标题:Fastdfs安装

      本文链接:https://www.haomeiwen.com/subject/vxahuhtx.html