博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx-fastdfs搭建分布式云存储系统
阅读量:7028 次
发布时间:2019-06-28

本文共 3339 字,大约阅读时间需要 11 分钟。

nginx-fastdfs搭建

00-预备工具包:

(1)安装fastdfs所需的软件包:

  • libfastcommon-1.0.38.tar.gz
  • fastdfs-5.11.tar.gz
  • fastdfs-nginx-module-1.20.tar.gz
  • libevent-2.1.8-stable.tar.gz

    (2)安装Nginx所需的软件包:
    • nginx-1.13.7.tar.gz
    • openssl-1.1.0g.tar.gz
    • pcre-8.41.tar.gz
    • zlib-1.2.11.tar.gz

(3)最少准备6台虚拟机:

1251785-20180731172302274-1823711058.png

01-安装fastdfs:

(1) libfastcommon-1.0.38.tar.gz安装

$ tar xzvf libfastcommon-1.0.38.tar.gz$ cd libfastcommon-1.0.38$ sudo ./make.sh

(2) fastdfs-5.11.tar.gz 安装

$ tar xzvf fastdfs-5.11.tar.gz$ cd fastdfs-5.11$ ./make.sh$ sudo ./make.sh install

(3) 配置tracker

192.168.189.128, 192.168.189.130

$ cd /etc/fdfs client.conf.sample  storage.conf.sample  storage_ids.conf.sample  tracker.conf.sample$ sudo su# cp tracker.conf.sample tracker.conf# vim tracker.conf

修改tracker.conf:base_path=/home/sunpan/fastdfs/tracker 修改到前建立好的文件路径。

1251785-20180731172446147-1911400410.png

启动 fastdfs

# /etc/init.d/fdfs_trackerd start

(4) 配置tracker

$ cd /etc/fdfs client.conf.sample  storage.conf.sample  storage_ids.conf.sample  tracker.conf.sample$ sudo su# cp storage.conf.sample storage.conf# vim storage.conf

修改storage.conf:group_name(本文设置两组,group1或者group2) tacker_server (前面配置的tracker的IP和端口号) base_path store_path0 ( 这两个路径设置为早已经建立的路径)

1251785-20180731172510156-732604213.png

1251785-20180731172948288-91565377.png

启动storage的fdfs:

# /etc/init.d/fdfs_storaged start

1251785-20180731172540701-882125592.png

02-安装Nginx和fastdfs-nginx-module

** 一定要记得安装 gcc编译依赖环境 **

(1)openssl安装

[root@localhost src]# tar zxvf openssl-1.1.0g.tar.gz省略安装内容...[root@localhost src]# cd openssl-1.1.0g[root@localhost openssl-1.1.0g]# ./config && make && make install省略安装内容...

(2)pcre安装

[root@localhost src]# tar zxvf pcre-8.41.tar.gz省略安装内容...[root@localhost src]# cd pcre-8.41[root@localhost pcre-8.41]# ./configure && make && make install省略安装内容...

(3)zlib安装

[root@localhost src]# tar zxvf zlib-1.2.11.tar.gz省略安装内容...[root@localhost src]# cd zlib-1.2.11[root@localhost zlib-1.2.11]# ./configure && make && make install省略安装内容...

(4)nginx安装

[root@localhost src]# tar zxvf nginx-1.13.7.tar.gz省略安装内容...[root@localhost src]# cd nginx-1.13.7[root@localhost nginx-1.13.7]# ./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_addition_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_stub_status_module --with-stream --with-pcre=/home/sunpan/works/fastdfs/packet/nginx/pcre-8.41/build --with-zlib=/home/sunpan/works/fastdfs/packet/nginx/zlib-1.2.11/build --with-openssl=/home/sunpan/works/fastdfs/packet/nginx/openssl-1.1.0g/build --add-module=/home/sunpan/works/fastdfs/packet/fastdfs-nginx-module-1.20/src/

zlib openssl pcre等编译的文件路径,如果已经make install ,则可以不with上该路径。

直接configure,会出现错误:

1251785-20180731172613314-251330623.png

此时,需要修改 /home/sunpan/works/fastdfs/packet/fastdfs-nginx-module-1.20/src/里的config文件里:

ngx_module_incs

1251785-20180731172631594-1574595072.png

configure之后就是编译和安装:

make && make install (其实直接make install就行了)

(5)配置Nginx和fastdfs模块

复制fastdfs-nginx-module里的mod_fastdfs.conf(/home/sunpan/works/fastdfs/packet/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf)文件到/etc/fdfs/并配置修改对应路径名。

1251785-20180731172641480-150990117.png

1251785-20180731172701181-1013299164.png

复制fastdfs的http.conf mime.types到/etc/fdfs/

cd /home/sunpan/works/fastdfs/fastdfs-5.11/confcp http.conf /etc/fdfscp mime.types /etc/fdfs

修改http.conf

1251785-20180731172722989-1472198081.png

修改Nginx配置文件:/usr/local/nginx/conf/nginx

1251785-20180731172735849-2009246071.png

修改端口号为前面storage服务器的对应的端口号。

添加location映射。

(5)启动Nginx

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

03-测试上传文件

使用fastdfs自带的客户端或者自己编写客户端都可以。

这里使用fastdfs自带的客户端,配置好client.conf就就可以直接上传文件了。

fdfs_upload_file /etc/fdfs/client.conf image.jpg

1251785-20180731172752357-535975851.png

上传成功!

可以取访问了,使用storage服务器的ip地址就可以直接在浏览器访问该图片了。

1251785-20180731172823047-1387012342.png

转载于:https://www.cnblogs.com/sunpan822/p/9397076.html

你可能感兴趣的文章
一起学shell之(九-2)拼写检查、进程
查看>>
nginx配置支持http2
查看>>
vmware收集日志相关
查看>>
2014.7.30-8.3日广大网友的提问解答(答问题的第2个工作周)
查看>>
何玺评腾讯一起来捉妖,值得期待的区块链游戏
查看>>
LightBus新浪微博客户端开源下载
查看>>
Hyper-V 3.0网络虚拟化PART 2:外部交换机
查看>>
【翻译】培训提示:解决常见编码问题的简单技巧
查看>>
[全球最详细] 《统一沟通-微软-实战》VS《统一沟通-微软-技巧》-51CTO
查看>>
iptables官方手册整理
查看>>
Win8 官方培训课程
查看>>
用MacBook对交换机进行初始化配置
查看>>
Linux 的五个重启命令及具体说明
查看>>
Hadoop虚拟化扩展(HVE)之资源扩展技术
查看>>
Exchange日常管理之十九:配置邮件提示功能
查看>>
论脚本时代:盘点那些节省时间的自动化软件
查看>>
虚拟资源引流变现
查看>>
Powershell管理系列(三)2012 AD域用户UPN名称还原
查看>>
C#设计模式(13)——代理模式(Proxy Pattern)
查看>>
K8S集群基于metrics server的HPA测试
查看>>