• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

nginx-fastdfs分布式文件系统安装与配置【显哥出品,必为精品】

技术栈 lixian 3年前 (2022-04-26) 11396次浏览 1个评论 扫描二维码

一、环境准备

yum install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel -y

二、安装libfastcommon

1.获取libfastcommon安装包:wget https://github.com/happyfish100/libfastcommon/archive/V1.0.38.tar.gz

2.解压安装包:tar -zxvf V1.0.38.tar.gz

3.进入目录:cd libfastcommon-1.0.38

4.执行编译:./make.sh

5.安装:./make.sh install

三、安装FastDFS

1.获取fdfs安装包:wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz

2.解压安装包:tar -zxvf V5.11.tar.gz

3.进入目录:cd fastdfs-5.11

4.执行编译:./make.sh

5.安装:./make.sh install

四、配置Tracker服务

1. 进入/etc/fdfs目录
cp tracker.conf.sample tracker.conf
mkdir /data/fastdfs/tracker -p

2.编辑tracker.conf:vim tracker.conf,修改相关参数
base_path=/data/fastdfs/tracker
http.server_port=80

3.启动tracker(支持start|stop|restart):
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start

五、配置Storage服务

1.进入/etc/fdfs目录
cp storage.conf.sample storage.conf
mkdir /data/fastdfs/storage -p

2.编辑storage.conf:vim storage.conf,修改相关参数:
base_path=/data/fastdfs/storage
store_path0=/data/fastdfs/storage
tracker_server=192.168.1.103:22122

3.启动storage(支持start|stop|restart):
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

六、安装Nginx和fastdfs-nginx-module模块

1.下载Nginx安装包 wget http://nginx.org/download/nginx-1.15.2.tar.gz

2.下载fastdfs-nginx-module安装包 wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz

3.解压nginx:tar -zxvf nginx-1.15.2.tar.gz

4.解压fastdfs-nginx-module:tar -xvf V1.20.tar.gz

5.安装依赖的库 :yum install libpcre3 libpcre3-dev openssl libssl-dev libperl-dev -y

6.修改fastdfs-nginx-module-1.20/src/config文件: 
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/" 
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/" 

7.进入nginx目录:cd nginx-1.15.2,配置加载fastdfs-nginx-module模块:
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/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_stub_status_module  \
--with-http_ssl_module  \
--with-http_addition_module \
--with-http_auth_request_module \
--with-stream \
--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=/usr/local/fastdfs/fastdfs-nginx-module-1.22/src

8.编译安装:
make
make install

9.查看安装路径:whereis nginx
启动、停止:
cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop #此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程
./nginx -s reload

七、配置Nginx和fastdfs-nginx-module模块

1.配置mod-fastdfs.conf,并拷贝到/etc/fdfs文件目录下

cd fastdfs-nginx-module-1.20/src/
cp mod_fastdfs.conf /etc/fdfs


2.进入/etc/fdfs修改mod-fastdfs.conf:
base_path=/data/fastdfs/storage
tracker_server=192.168.1.103:22122 #tracker的地址
url_have_group_name=true #url是否包含group名称
store_path0=/data/fastdfs/storage #文件存储的位置

3.配置客户端(Client)
vim /etc/fdfs/client.conf
tracker_server=192.168.1.103:22122
http.tracker_server_port=80
base_path=/data/fastdfs/storage

4.配置nginx,新增server:
cd /usr/local/nginx/conf/
vim nginx.conf
server {
        listen       80;
        server_name  192.168.1.103;
        location /group1/M00/ {
            ngx_fastdfs_module;
        }}
最后需要拷贝fastdfs解压目录中的http.conf和mime.types:cd /usr/local/src/fastdfs-5.11/conf
cp mime.types http.conf /etc/fdfs/

5.测试
测试服务:/usr/bin/fdfs_test /etc/fdfs/client.conf upload (指定配置文件)

本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:nginx-fastdfs分布式文件系统安装与配置【显哥出品,必为精品】
喜欢 (2)

您必须 登录 才能发表评论!

(1)个小伙伴在吐槽
  1. I may need your help. I tried many ways but couldn't solve it, but after reading your article, I think you have a way to help me. I'm looking forward for your reply. Thanks.
    gate io2023-06-04 04:20