centos7.9 安装 FastDFS

参考文档:https://github.com/happyfish100/fastdfs/wiki

1. 查询服务器操作系统版本

[root@VM-20-4-centos fdfs]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

2. yum安装

rpm -ivh http://www.fastken.com/yumrepo/el7/noarch/FastOSrepo-1.0.0-1.el7.centos.noarch.rpm

安装 FastDFS软件包:

yum install fastdfs-server fastdfs-tool fastdfs-config -y

3. 编译环境

yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y

3. 磁盘目录

说明位置
所有安装包/usr/local/src
数据存储位置/home/dfs/
#这里我为了方便把日志什么的都放到了dfs
mkdir /home/dfs #创建数据存储目录
cd /usr/local/src #切换到安装目录准备下载安装包

4.安装libfastcommon

git clone https://github.com/happyfish100/libfastcommon.git --depth 1
cd libfastcommon/
./make.sh && ./make.sh install #编译安装
cd ../ #返回上一级目录

5. 安装libserverframe

git clone https://github.com/happyfish100/libserverframe.git --depth 1
cd libserverframe/
./make.sh && ./make.sh install #编译安装
cd ../ #返回上一级目录

6. 安装FastDFS

git clone https://github.com/happyfish100/fastdfs.git --depth 1
cd fastdfs/
./make.sh && ./make.sh install #编译安装
#配置文件准备
cp /usr/local/src/fastdfs/conf/http.conf /etc/fdfs/ #供nginx访问使用
cp /usr/local/src/fastdfs/conf/mime.types /etc/fdfs/ #供nginx访问使用
cd ../ #返回上一级目录

7. 安装fastdfs-nginx-module

git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs

8. 安装nginx

wget http://nginx.org/download/nginx-1.15.4.tar.gz #下载nginx压缩包
tar -zxvf nginx-1.15.4.tar.gz #解压
cd nginx-1.15.4/
#添加fastdfs-nginx-module模块
./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/ 
make && make install #编译安装

9. 单机部署

tracker配置

#服务器ip为 192.168.52.1
#我建议用ftp下载下来这些文件 本地修改
vim /etc/fdfs/tracker.conf
#需要修改的内容如下
port=22122  # tracker服务器端口(默认22122,一般不修改)
base_path=/home/dfs  # 存储日志和数据的根目录

storage配置

vim /etc/fdfs/storage.conf
#需要修改的内容如下
port=23000  # storage服务端口(默认23000,一般不修改)
base_path=/home/dfs  # 数据和日志文件存储根目录
store_path0=/home/dfs  # 第一个存储目录
tracker_server=192.168.52.1:22122  # tracker服务器IP和端口
http.server_port=8888  # http访问文件的端口(默认8888,看情况修改,和nginx中保持一致)

启动服务

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

client测试

vim /etc/fdfs/client.conf
#需要修改的内容如下
base_path=/home/dfs
tracker_server=192.168.52.1:22122    #tracker服务器IP和端口
#保存后测试,返回ID表示成功 如:group1/M00/00/00/xx.tar.gz
fdfs_upload_file /etc/fdfs/client.conf /home/fuxiong/images/千岛湖.jpg

注意:此时会遇到两个异常

异常一:

执行 fdfs_upload_file 上次操作时会提示连接超时信息

[root@VM-20-4-centos fdfs]# fdfs_upload_file /etc/fdfs/client.conf /home/fuxiong/images/千岛湖.jpg
[2023-12-11 09:19:36] ERROR - file: connection_pool.c, line: 226, connect to server 175.178.119.191:23000 fail, errno: 110, error info: Connection timed out
upload file fail, error no: 110, error info: Connection timed out

解决办法:关闭防火墙

[root@VM-20-4-centos fdfs]# service firewalld stop
Redirecting to /bin/systemctl stop firewalld.service

 异常二:tracker_query_storage fail, error no: 2, error info: No such file or directory

提示返回空间不足

[2023-12-11 09:11:44] ERROR - file: ../client/tracker_client.c, line: 899, fdfs_recv_response fail, result: 2
tracker_query_storage fail, error no: 2, error info: No such file or directory

解决版本:在tracker.conf中,将reserved_storage_space的值修改为5%,预留5%的磁盘空间

vi /etc/fdfs/tracker.conf

​​​​​​​​​​​​​​​​​​​​​

 配置nginx访问

vim /etc/fdfs/mod_fastdfs.conf
#需要修改的内容如下
tracker_server=192.168.52.1:22122  #tracker服务器IP和端口
url_have_group_name=true
store_path0=/home/dfs
#配置nginx.config
vim /usr/local/nginx/conf/nginx.conf
#添加如下配置
server {
    listen       8888;    ## 该端口为storage.conf中的http.server_port相同
    server_name  localhost;
    location ~/group[0-9]/ {
        ngx_fastdfs_module;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    root   html;
    }
}
#测试下载,用外部浏览器访问刚才已传过的nginx安装包,引用返回的ID
http://192.168.52.1:8888/group1/M00/00/00/wKgAQ1pysxmAaqhAAA76tz-dVgg.tar.gz
#弹出下载单机部署全部跑通

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值