FastDFS分布式文件系统环境搭建心得

FastDFS环境搭建

环境准备

系统环境说明

名称说明
CentOS7.X(安装系统)
libfastcommonFastDFS分离出的一些公用函数包
FastDFSFastDFS本体
fastdfs-nginx-moduleFastDFS和nginx的关联模块,解决组内同步延迟问题
nginxnginx 1.15.4

服务器环境资源及用途

名称IP地址应用
tracker,storage01192.168.40.210FastDFS,libfastcommon,nginx,fastdfs-nginx-module
storage02192.168.40.220FastDFS,libfastcommon,nginx,fastdfs-nginx-module

安装目录

说明路径
tracker/storage日志路径/data/local/fastdfs/
文件存储路径/data/local/fastdfs
安装路径/usr/local/

开始安装

1.安装包以及依赖文件下载

# 下载环境依赖包
yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y
# 下载fdfs安装包文件
cd /usr/local/
# 下载libfastcommon
git clone https://github.com/happyfish100/libfastcommon.git --depth 1
# 下载fastdfs
git clone https://github.com/happyfish100/fastdfs.git --depth 1
# 下载fastdfs-nginx-module
git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
# 下载nginx
wget http://nginx.org/download/nginx-1.15.4.tar.gz
tar -zxvf nginx-1.15.4.tar.gz

2.安装fastdfs

# 安装libfastcommon
cd libfastcommon/
./make.sh && ./make.sh install
# 安装fastdfs
cd ../fastdfs/
./make.sh && ./make.sh install
# 安装nginx
cd ../nginx-1.15.4/
./configure --add-module=/usr/local/fastdfs-nginx-module/src
make && make install

3.修改配置文件

192.168.40.210
cd /etc/fdfs
cp tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
cp client.conf.sample client.conf
cp /usr/local/fastdfs/conf/http.conf /etc/fdfs/ # 供nginx使用
cp /usr/local/fastdfs/conf/mime.types /etc/fdfs/ # 供nginx使用
cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
# 修改tracker.conf文件
vim tracker.conf
base_path=/data/local/fastdfs # 存储日志和数据的根目录

# 启动tracker
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
# 修改storage.conf文件
vim storage.conf
group_name=ciec0 # 修改组名
port=23000 # storage端口 一般默认不修改
base_path=/data/local/fastdfs  # 日志文件保存路径
store_path0=/data/local/fastdfs # 文件存储路径
tracker_server=192.168.40.210:22122 # tracker
http.server_port=81 # HTTP访问端口(与nginx配置一致)
# 启动storage
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

192.168.40.220 # 与210机器一致,不过只启动storage服务,不启动tracker服务
# 修改storage.conf文件
vim storage.conf
group_name=ciec0 # 修改组名
port=23000 # storage端口 一般默认不修改
base_path=/data/local/fastdfs  # 日志文件保存路径
store_path0=/data/local/fastdfs # 文件存储路径
tracker_server=192.168.40.210:22122 # tracker
http.server_port=81 # HTTP访问端口(与nginx配置一致)
# 启动storage
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

4.测试上传

# 修改client.conf文件
# 需要修改的内容如下
base_path=/data/local/fastdfs
tracker_server=192.168.40.210:22122 # tracker服务器IP和端口
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /etc/fdfs/client.conf
# 返回ID表示成功
ciec0/M00/00/00/wKgo0l3kfiuAf5FiAAAGr5EsoIc78.conf

5.配置nginx访问

# 192.168.40.210
vim /etc/fdfs/mod_fastdfs.conf
# 修改以下配置
tracker_server=192.168.40.210:22122 # tracker服务器IP和端口
group_name=ciec0 # 组名
url_have_group_name=true # url是否含有组名
base_path=/data/local/fastdfs # 日志文件路径
store_path0=/data/local/fastdfs # 文件存储路径
# 修改nginx配置
cd /usr/local/nginx/conf
mkdir fdfs/
vim  fdfs_ciec.conf
# 添加fdfs_nginx配置
server {
        listen 81;
        server_name localhost;
        location ~/ciec0/M00 {
            ngx_fastdfs_module;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }
    }
vim nginx.conf
# 修改如下主nginx配置
upstream fdfs_group01 {
    server 192.168.40.210:81 weight=1 max_fails=2 fail_timeout=30s;
    server 192.168.40.220:81 weight=1 max_fails=2 fail_timeout=30s;
        }
    server {
    listen 80;
    server_name 0.0.0.0;
    location /ciec0{
        proxy_next_upstream http_502 http_504 error timeout invalid_header;
        proxy_pass http://fdfs_group01;
        expires 30d;
                }
        }
    include /usr/local/nginx/conf/test/fdfs.conf;
# 启动nginx
/usr/local/nginx/sbin/nginx
# 192.168.40.220
cd /usr/local/nginx/conf
mkdir fdfs/
vim  fdfs_ciec.conf
# 添加fdfs_nginx配置
server {
        listen 81;
        server_name localhost;
        location ~/ciec0/M00 {
            ngx_fastdfs_module;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }
    }
# 启动nginx
/usr/local/nginx/sbin/nginx

6.测试文件下载

# 浏览器访问
http://192.168.40.210/ciec0/M00/00/00/wKgo0l3kfiuAf5FiAAAGr5EsoIc78.conf
# 成功下载及配置完成
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值