fast-dfs分布式文件存储

fastDFS 下载地址
https://github.com/happyfish100/fastdfs.git
https://sourceforge.net/projects/fastdfs/files
https://github.com/happyfish100/libfastcommon
fast库依赖

yum install -y unzip gcc gcc-c++ openssl openssl-devel zlib-devel pcre-devel perl
unzip libfastcommon-master.zip
cd libfastcommon-master
./make.sh
./make.sh install
tar fx FastDFS_v5.07.tar.gz
./make.sh
./make.sh install
(如果编译错误 先执行./make.sh clean 清理下)
/etc/init.d/fdfs_storaged 默认启动文件位置
/etc/init.d/fdfs_tracker
配置文件在(样例配置文件)

/etc/fdfs/client.conf.sample
/etc/fdfs/storage.conf.sample
/etc/fdfs/tracker.conf.sample

默认命令工具在/usr/bin 下
因为 FastDFS 服务脚本设置的 bin 目录是/usr/local/bin, 但实际命令安装在/usr/bin, 可以进入/user/bin 目录使用以下命令查看 fdfs 的相关命令:

因此需要修改 FastDFS 服务脚本中相应的命令路径,也就是把/etc/init.d/fdfs_storaged和/etc/init.d/fdfs_tracker 两个脚本中的/usr/local/bin 修改成/usr/bin:
编辑跟踪器配置文件
disabled=false #启用配置文件
port=22122 #tracker 的端口号,一般采用 22122 这个默认端口
base_path=/fastdfs/tracker #tracker 的数据文件和日志目录

创建基础数据目录(参考基础目录 base_path 配置)

mkdir -p /fastdfs/tracker

启动tracker

/etc/init.d/fdfs_trackerd start

开机自启动

vi /etc/rc.d/rc.local

FastDFS Tracker

/etc/init.d/fdfs_trackerd start
配置 FastDFS 存储

cd /etc/fdfs/

cp storage.conf.sample storage.conf

Vim storage.conf

disabled=false #启用配置文件
group_name=group1 #组名(第一组为 group1, 第二组为 group2)
port=23000 #storage 的端口号,同一个组的 storage 端口号必须相同
base_path=/fastdfs/storage #设置 storage 的日志目录
store_path0=/fastdfs/storage #存储路径
store_path_count=1 #存储路径个数,需要和 store_path 个数匹配
tracker_server=192.168.50.135:22122 #tracker 服务器的 IP 地址和端口
tracker_server=192.168.50.136:22122 #多个 tracker 直接添加多条配置
http.server_port=8888 #设置 http 端口号

mkdir -p /fastdfs/storage

/etc/init.d/fdfs_storaged start

vi /etc/rc.d/rc.local 开机自启动

FastDFS Storage

/etc/init.d/fdfs_storaged start

/usr/bin/fdfs_monitor /etc/fdfs/storage.conf

所有 Storage 节点都启动之后,可以在任一 Storage 节点上使用如下命令查看集群信息:

文件上传测试
修改 Tracker 服务器中的客户端配置文件

cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf

vi /etc/fdfs/client.conf

base_path=/fastdfs/tracker
tracker_server=192.168.50.135:22122
tracker_server=192.168.50.136:22122
执行如下文件上传命令

/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/src/FastDFS_v5.05.tar.gz

返回I D
[root@localhost logs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /opt/FastDFS_v5.07.tar.gz
group1/M00/00/00/wKgKkVvbOweAV3whAAVFdPbmJX8.tar.gz
[root@localhost logs]#

yum -y install gcc
yum -y install gcc-c++
yum -y install openssl openssl-devel
yum -y install zlib-devel
yum -y install pcre-devel
下载nginx
http://nginx.org/download/nginx-1.13.12.tar.gz
下载最新版 fastdfs-nginx-module
https://github.com/happyfish100/fastdfs-nginx-module/
根据需要的/fastdfs-nginx-module INSTALLL 文件 选择需要的
Nginx版本和fastDFS文件服务器

执行完上述命令,有可能会报错
/usr/local/src/fastdfs-nginx-module/src/ngx_http_fastdfs_module.c:812: 错误:‘fdfs_send_reply_chunk’ 未声明 (在此函数内第一次使用)
/usr/local/src/fastdfs-nginx-module/src/ngx_http_fastdfs_module.c:813: 错误:‘struct fdfs_http_context’ 没有名为 ‘proxy_handler’ 的成员
/usr/local/src/fastdfs-nginx-module/src/ngx_http_fastdfs_module.c:819: 错误:‘struct fdfs_http_context’ 没有名为 ‘if_modified_since’ 的成员
/usr/local/src/fastdfs-nginx-module/src/ngx_http_fastdfs_module.c:822: 错误:‘struct fdfs_http_context’ 没有名为 ‘if_modified_since’ 的成员
/usr/local/src/fastdfs-nginx-module/src/ngx_http_fastdfs_module.c:852: 错误:‘struct fdfs_http_context’ 没有名为 ‘range’ 的成员
/usr/local/src/fastdfs-nginx-module/src/ngx_http_fastdfs_module.c:858: 错误:‘struct fdfs_http_context’ 没有名为 ‘if_range’ 的成员
/usr/local/src/fastdfs-nginx-module/src/ngx_http_fastdfs_module.c:858: 错误:‘true’ 未声明 (在此函数内第一次使用)
make[1]: *** [objs/addon/src/ngx_http_fastdfs_module.o] 错误 1
make[1]: Leaving directory `/usr/local/src/nginx-1.4.7’
make: *** [build] 错误 2

cd fastdfs-nginx-module/src
vi config
去掉/local
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

https://github.com/FRiCKLE/ngx_cache_purge/

Nginx:Purge,ngx_cache_purge模块
下载
压缩包解压后安装脚本
[root@minion_1 fdfs]# ls
client.conf ***fdfs_storage.sh l***ibfastcommon-master.zip nginx-1.14.1.tar.gz storage.conf
fastdfs-nginx-module_v1.16.tar.gz fdfs_tracker.sh mime.types nginx.conf storage_nginx.conf
FastDFS_v5.07.tar.gz http.conf mod_fastdfs.conf ngx_cache_purge-2.3.tar.gz tracker.conf
[root@minion_1 fdfs]#

[root@minion_1 fdfs]# cat fdfs_storage.sh
#!/bin/bash
yum install -y lrzsz unzip gcc gcc-c++ perl vim bind-utils pcre-devel zlib-devel ntp ntpdate
ntpdate cn.pool.ntp.org && hwclock --systohc && hwclock -w && mkdir -p /fastdfs/storage
tar fx FastDFS_v5.07.tar.gz
tar fx nginx-1.14.1.tar.gz
tar fx fastdfs-nginx-module_v1.16.tar.gz
unzip libfastcommon-master.zip
cd libfastcommon-master
./make.sh && ./make.sh install >> /libfastcommon.txt
if [ $? -ne 0 ];then
echo “缺少依赖关系,请查看build.txt”
else
cd …/FastDFS
./make.sh && ./make.sh install
[ -d /etc/fdfs ] && cp …/storage.conf /etc/fdfs && cp …/mod_fastdfs.conf /etc/fdfs
cp …/mime.types /etc/fdfs && cp …/http.conf /etc/fdfs/
sed -i “s/usr/local/usr/g” …/fastdfs-nginx-module/src/config
cd …/nginx-1.14.1
./configure --prefix=/usr/local/nginx --add-module=…/fastdfs-nginx-module/src && make && make install >> /nginx.txt
if [ $? -ne 0 ];then
echo “nginx安装未成功”
else
rm -f /usr/local/nginx/conf/nginx.conf && cp …/storage_nginx.conf /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx
netstat -ntlp | grep nginx
fi
/etc/init.d/fdfs_storaged start
netstat -ntlp | grep fdfs
fi

[root@minion_1 fdfs]# cat fdfs_tracker.sh
#!/bin/bash
yum install -y lrzsz unzip gcc gcc-c++ perl vim bind-utils pcre-devel zlib-devel ntp ntpdate
ntpdate cn.pool.ntp.org && hwclock --systohc && hwclock -w
tar fx FastDFS_v5.07.tar.gz
mkdir -p /fastdfs/tracker
tar fx nginx-1.14.1.tar.gz
tar fx ngx_cache_purge-2.3.tar.gz
unzip libfastcommon-master.zip
cd libfastcommon-master
./make.sh && ./make.sh install >> /lib.txt
if [ $? -ne 0 ];then
echo “缺少依赖关系,请查看build.txt”
else
cd …/FastDFS
./make.sh && ./make.sh install
[ -d /etc/fdfs ] && cp …/tracker.conf /etc/fdfs && cp …/client.conf /etc/fdfs/
cd …/nginx-1.14.1
mkdir -p /var/cache/nginx/proxy_cache/tmp
find . -type f -exec touch {} ;
./configure --prefix=/usr/local/nginx --add-module=…/ngx_cache_purge-2.3 && make && make install >> /nginx.txt

if [ $? -ne 0  ];then
echo "nginx安装未成功"
  else
    rm -f /usr/local/nginx/conf/nginx.conf && cp ../nginx.conf /usr/local/nginx/conf
/usr/local/nginx/sbin/nginx
netstat -ntlp | grep nginx
fi

/etc/init.d/fdfs_trackerd start
netstat -ntlp | grep fdfs
fi

猜你喜欢

转载自blog.csdn.net/weixin_43231324/article/details/85995752