FastDFS集群部署

一. 准备服务器

 

ip地址tracker / storage
192.168.233.135tracker
192.168.233.136tracker
192.168.233.137storage
192.168.233.138storage
192.168.233.139storage
192.168.233.140storage

二. 提前准备

  • 安装 c++环境

yum install gcc-c++

  • 安装 libfastcommon

wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz

./make.sh

./make.sh install

#将安装目录下的conf下的文件拷贝到/etc/fdfs/下

cp ./conf/* /etc/fdfs/

#/home/FastDFS 这个目录是需要先创建好的,该目录是tracker的数据文件目录,用来存储storage的信息。

mkdir /home/FastDFS

# 创建目录/home/FastDFS/fdfs_storage

mkdir /home/FastDFS/fdfs_storage

三. 配置 track, storage

  • track (192.168.233.135, 192.168.233.136)

# 修改tracker.conf 配置

# Tracker默认的服务端口是22122,这个不用修改。

base_path=/home/FastDFS

#/home/FastDFS 这个目录是需要先创建好的,该目录是tracker的数据文件目录,用来存储storage的信息。

http.server_port=8088

#Http服务端口修改成8088,这个可以任意修改。

####################################################

#启动 tracker

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

或者 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

 

  •  storage(192.168.233.137, 192.168.233.138, 192.168.233.139, 192.168.233.140)

# 修改storage.conf

group_name=group1

base_path=/home/yuqing/FastDFS改为:base_path=/home/FastDFS

store_path0=/home/yuqing/FastDFS改为:store_path0=/home/FastDFS/fdfs_storage

#如果有多个挂载磁盘则定义多个store_path,如下

#store_path1=.....

#store_path2=......
tracker_server=192.168.233.135:22122   #配置192.168.233.135 tracker服务器:IP

#如果有多个则配置多个tracker

#配置http端口

http.server_port=8088

 

创建目录/home/FastDFS/fdfs_storage

Storage中配置tracker的地址,storage是主动连接tracker的。

################################################################

# 启动 storage

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

四. 测试上传

安装成功后可以通过/usr/bin/fdfs_test测试上传
在tracker机器上或者是storage机器上修改/etc/fdfs/client.conf配置文件 

base_path=/home/FastDFS/client

tracker_server=192.168.233.135:22122

在home下创建fastdfs目录

使用格式:

/usr/bin/fdfs_test  /etc/fdfs/client.conf  upload  /home/FastDFS/client/11.png

出现下图则上传成功了:

 

目前还不能下载,因为fastDFS没有提供下载接口,需要使用nginx提供下载接口。Tracker和Storage都需要安装nginx。 

五. storage安装nginx 

  • 安装依赖包 gcc, PCRE, zlib, openssl

yum install gcc-c++

yum install -y pcre pcre-devel

yum install -y zlib zlib-devel

yum install -y openssl openssl-devel

  • 安装FastDFS-nginx-module

 FastDFS-nginx-module是FastDFS和Nginx整合的插件,因为nginx需要给Storage提供下载接口,所以在Storage上需要安装,Tracker上不需要安装,因为Tracker不需要提供下载接口。

cd /opt/module/software

wget https://gitee.com/crazyjim/FastDFS_dependency_software/raw/master/fastdfs-nginx-module_v1.16.tar.gz

tar -zxvf fastdfs-nginx-module -C /usr/local/src

cd /usr/local/src/fastdfs-nginx-module/src

# 将FastDFS-nginx-module/src下的mod_FastDFS.conf拷贝至/etc/fdfs/下

cp mod_FastDFS.conf /etc/fdfs

vi /etc/fdfs/mod_FastDFS.conf

#并修改mod_FastDFS.conf的内容

  •  安装nginx

cd /opt/module/software

 wget http://nginx.org/download/nginx-1.8.1.tar.gz

tar -zxvf nginx-1.8.1.tar.gz -C /usr/local/src

 cd /usr/local/src
# 参数设置如下:设置安装前的设置如安装的位置,添加依赖包

./configure \

--prefix=/usr/local/src/nginx \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/temp/nginx/client \

--http-proxy-temp-path=/var/temp/nginx/proxy \

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \

--http-scgi-temp-path=/var/temp/nginx/scgi \

--add-module=/usr/local/src/fastdfs-nginx-module/src

mkdir -p /var/temp/nginx

make

make install

  • 修改nginx的配置文件

修改/usr/local/nginx安装目录下的conf下的nginx.conf配置文件

在server模块儿中修改:

listen       80;

server_name  localhost;

添加

#nginx提供下载接口用户请求nginx的服务nginx通过配置的location

#找到对应的文件目录

location /group1/M00/{

                root /home/FastDFS/fdfs_storage/data;

                ngx_fastdfs_module;

        }

 

  •  启动nginx

cd /usr/local/nginx/sbin/

./nginx -c /usr/local/nginx/conf/nginx.conf

 

六 tracker安装nginx 

  • 安装依赖包 gcc, PCRE, zlib, openssl

yum install gcc-c++

yum install -y pcre pcre-devel

yum install -y zlib zlib-devel

yum install -y openssl openssl-devel

  • 安装nginx

cd /opt/module/software

 wget http://nginx.org/download/nginx-1.8.1.tar.gz

tar -zxvf nginx-1.8.1.tar.gz -C /usr/local/src

 cd /usr/local/src
# 参数设置如下:设置安装前的设置如安装的位置,添加依赖包. 如果不指定安装目录, 默认nginx会安装到/usr/local下

./configure \

--prefix=/usr/local/src/nginx \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/temp/nginx/client \

--http-proxy-temp-path=/var/temp/nginx/proxy \

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \

--http-scgi-temp-path=/var/temp/nginx/scgi \

--add-module=/usr/local/src/fastdfs-nginx-module/src

mkdir -p /var/temp/nginx

make

make install

  • 修改nginx的配置文件

  • 启动

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

 

访问地址:

http://192.168.233.135/group1/M00/00/00/wKjpil8ZQtKAYdmuAAASFgZKxes289.png

http://192.168.233.137/group1/M00/00/00/wKjpil8ZQtKAYdmuAAASFgZKxes289.png

 

错误

  • make: *** No rule to make target `build', needed by `default'.  Stop.
yum -y install make zlib-devel gcc-c++ libtool openssl openssl-devel

./configure 

make && make install

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值