FastDFS集群环境搭建

一、集群架构图

FastDFS集群架构图

二、搭建步骤

1、资源下载至 /root/software

资源地址:https://github.com/happyfish100
下载 libfastcommon、fastdfs、fastdfs-nginx-module-master

2、安装libfastcommon-master
cd /root/software
unzip libfastcommon-master.zip
cd libfastcommon-master
./make.sh && ./make.sh install
3、安装fastdfs-master
cd /root/software
unzip fastdfs-master.zip 
cd fastdfs-master
./make.sh && ./make.sh install

#复制文件到/etc/fdfs/
cp conf/http.conf /etc/fdfs/
cp conf/mime.types /etc/fdfs/
#去掉.sample文件后缀 在/etc/fdfs/目录下
cd /etc/fdfs/
rename .sample '' *
添加目录
mkdir -p /opt/fastdfs/tracker
mkdir -p /opt/fastdfs/storage/files
修改/etc/fdfs/tracker.conf
bath_path=/opt/fastdfs/tracker
修改/etc/fdfs/storage.conf
group_name=group1  #注:107是 group2
bath_path=/opt/fastdfs/storage
store_path0=/opt/fastdfs/storage/files
tracker_server=192.168.12.106:22122 
tracker_server=192.168.12.107:22122
启动 Tracker Server、Storage Server
fdfs_trackerd /etc/fdfs/tracker.conf
fdfs_storaged /etc/fdfs/storage.conf
修改/etc/fdfs/client.conf,并做相关测试
base_path=/opt/fastdfs/client
tracker_server=192.168.12.106:22122
tracker_server=192.168.12.107:22122

需要安装相关目录 mkdir -p /opt/fastdfs/client

将文件20190906022041252.jpg上传至/root/software

fdfs_test /etc/fdfs/client.conf upload /root/software/20190906022041252.jpg

如果一切正常,会有相关访问链接的提示信息,如:http://192.168.12.106/group1/M00/00/00/wKgMal1yJ0aAau9iAADLSe9ZOYY945.jpg

4、安装nginx
安装storage代理nginx
  • 解压fastdfs-nginx-module-master
cd /root/software
unzip fastdfs-nginx-module-master.zip
cp fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/
  • 修改mod_fastdfs.conf
bath_path=/opt/fastdfs/nginx_mod
tracker_server=192.168.99.1:22122 #如果集群部署,可以有多行
store_path0=/opt/fastdfs/storage/files

group_count= 2 //如果集群部署,此值需要设置
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/opt/fastdfs/storage/files

[group2]
group_name=group2
storage_server_port=23000
store_path_count=1
store_path0=/opt/fastdfs/storage/files
  • 编译安装nginx
cd /root/software/nginx-1.16.1
make clean
./configure --prefix=/usr/local/nginx-fdfs --add-module=/root/software/fastdfs-nginx-module-master/src
make && make install

注:/root/software/nginx-1.16.1 此目录是之前安装nginx时已经解压过的

  • 配制/usr/local/nginx-fdfs/conf/nginx.conf
vi /usr/local/nginx-fdfs/conf/nginx.conf
listen 8090 
location ~ /group[1-9]/M0[0-9] {   
    ngx_fastdfs_module;
}
  • 启动/usr/local/nginx-fdfs/sbin/nginx
安装入口nginx

具体安装步骤可参考:https://blog.csdn.net/lglspace/article/details/100577118

修改/usr/local/nginx-1.16.1/conf/nginx.conf

#http节点下
upstream fastdfs_storage_server {  
    server 192.168.12.106:8090;  
    server 192.168.12.107:8090;
}
#server节点下,nginx拦截请求路径:
location ~ /group[1-9]/M0[0-9] {   
    proxy_pass http://fastdfs_storage_server; 
}

启动/usr/local/nginx-1.16.1/sbin/nginx

三、访问测试之前上传的图片

http://192.168.12.106:8090/group1/M00/00/00/wKgMal1yJ0aAau9iAADLSe9ZOYY945.jpg
http://192.168.12.106/group1/M00/00/00/wKgMal1yJ0aAau9iAADLSe9ZOYY945.jpg

遇到的坑

o trunk_mgr/trunk_sync.o trunk_mgr/trunk_client.o trunk_mgr/trunk_free_block_checker.o ../client/client_global.o ../client/tracker_client.o ../client/storage_client.o ../client/client_func.o fdht_client/fdht_proto.o fdht_client/fdht_client.o fdht_client/fdht_func.o fdht_client/fdht_global.o storage_dump.o -L/usr/lib64 -lpthread -lfastcommon -I. -Itrunk_mgr -I../common -I../tracker -I../client -Ifdht_client -I/usr/include/fastcommon /tmp/ccob9lB6.o: In function `main': /opt/FastDFS/storage/fdfs_storaged.c:130: undefined reference to `g_exe_name' storage_dump.o: In function `fdfs_dump_global_vars': /opt/FastDFS/storage/storage_dump.c:36: undefined reference to `g_exe_name' collect2: error: ld returned 1 exit status make: *** [fdfs_storaged] Error 1

处理方法: ./make.sh clean

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值