首页
首页
文章目录
  1. 简介
  2. 机器清单
  3. 系统基础信息处理
  4. 安装操作部署
    1. 1、安装相关工具
    2. 2、安装相关依赖
    3. 3、下载安装libfastcommon和fastDFS源码并编译安装
    4. 4、配置相关配置文件
    5. 5、启动tracker与storage
    6. 6、配置安装nginx,并测试访问
  5. 集群部署

Centos7.7安装fastDFS集群记录

简介

fastDFS 有以下三个组件 其中tracker和storage为server端部署 client为客户端连接配置

tracker:跟踪者,负责调度存储服务。
storage:用于文件存储。
client:调用tracker

机器清单

服务器ip 部署内容 系统配置信息
20.21.8.88 storage、tracker 4核心,16G内存,80G系统盘,1000G数据盘 group1
20.21.8.89 storage、nginx 4核心,16G内存,80G系统盘,1000G数据盘 group1
20.21.8.90 storage、tracker、nginx 4核心,16G内存,80G系统盘,1000G数据盘 group1

系统基础信息处理

1、安装时间同步服务

1
2
3
yum install chrony -y
vim /etc/chrony.conf
# 配置server 即可

2、修改systcl.conf

1
2
3
4
5
6
7
8
9
10
vim /etc/sysctl.conf
# 添加以下内容
vm.dirty_writeback_centisecs=100
vm.dirty_expire_centisecs=100
vm.swappiness=1
net.ipv4.ip_local_port_range=10000 65001
net.ipv4.tcp_max_orphans=4000000
net.ipv4.tcp_timestamps=0
net.core.somaxconn=1024
net.netfilter.nf_conntrack_max=121005752

3、修改limit.conf

1
2
3
4
5
6
7
8
# 修改最大进程和最大文件打开数限制
vim /etc/security/limits.conf
* soft nofile 655350
* hard nofile 655350
* soft nproc unlimited
* hard nproc unlimited
* soft core unlimited
* hard core unlimited

安装操作部署

1、安装相关工具

1
yum -y install  vim wget unzip

2、安装相关依赖

1
yum install -y gcc-c++ perl

3、下载安装libfastcommon和fastDFS源码并编译安装

libfastcommon下载地址: https://github.com/happyfish100/libfastcommon/releases

1
2
3
4
unzip libfastcommon-1.0.43.zip
cd libfastcommon
./make.sh
./make.sh install

fastDFS下载地址:https://github.com/happyfish100/fastdfs/releases

1
2
3
4
unzip fastdfs-6.06.zip
cd fastdfs-6.06
./make.sh
./make.sh install

4、配置相关配置文件

1
2
3
4
5
6
7
8
9
cd /etc/fdfs
mv client.conf.sample client.conf
mv storage.conf.sample storage.conf
mv storage_ids.conf.sample storage_ids.conf
mv tracker.conf.sample tracker.conf
# 创建相关目录
mkdir -p /data/fastfdfs/fdfa/client
mkdir -p /data/fastfdfs/fdfa/storage
mkdir -p /data/fastfdfs/fdfa/tracker

修改client.conf

1
2
base_path=/data/fastfdfs/fdfa/client
tracker_server=真实的地址:端口

修改storage.conf

1
2
3
base_path=/data/fastfdfs/fdfa/storage
store_path0=/data/fastfdfs/fdfa/storage
tracker_server=真实的地址:端口

修改tracker.conf

1
2
3
base_path=/data/fastfdfs/fdfa/tracker
# 归属组设置
store_group=group1

5、启动tracker与storage

启动tracker

1
fdfs_trackerd /etc/fdfs/tracker.conf start

启动storage

1
fdfs_storaged /etc/fdfs/storage.conf start

测试上传

1
fdfs_test /etc/fdfs/client.conf upload /root/1.jpg

6、配置安装nginx,并测试访问

1
2
3
4
5
6
7
8
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar zxvf nginx-1.14.0.tar.gz
# 下载nginx的fastdfs模块 地址:https://github.com/happyfish100/fastdfs-nginx-module/releases
unzip fastdfs-nginx-module-master.zip
mkdir -p /usr/share/nginx
cd nginx-1.14.0
./configure --prefix=/usr/share/nginx --add-module=/root/fastdfs-nginx-module-master/src
make && make install

从fastdfs的压缩包中复制配置文件至/etc/fdfs里面去

1
2
cp /root/fastdfs-6.06/conf/http.conf /etc/fdfs/
cp /root/fastdfs-6.06/conf/mime.types /etc/fdfs/

从fastdfs-nginx-module压缩包中复制配置文件到/etc/fdfs/里面去

1
2
cp /root/fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/
cp /root/fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/

修改mod_fastdfs.conf
修改 40行,更改tracker的ip地址与端口

1
tracker_server=真实的地址:端口

修改53行 url地址中是否包含组名

1
url_have_group_name = true

修改62行 storage所在目录

1
store_path0=/data/fastfdfs/fdfa/storage

保存退出
修改nginx配置文件
添加

1
ngx_fastdfs_module;

配置nginx 配置nginx

启动nginx

上传测试文件

1
fdfs_test /etc/fdfs/client.conf upload /root/Xnip2020-08-13_12-26-30.jpg

fdfs上传测试 fdfs上传测试

浏览器打开图中地址正常能查看图片就表示服务正常。

集群部署

参考单点部署只需要修改tracker 和storage接口,和nginx做成keepalived即可

支持一下
扫一扫,我会更有动力更新
  • 微信扫一扫
  • 支付宝扫一扫