1、安装gcc(编译时需要)

FastDFS是C语言开发,安装FastDFS需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc

yum install -y gcc gcc-c++

2、安装libevent(运行时需求)

若安装了桌面图形界面,就不需要安装;FastDFS依赖libevent库;

yum -y install libevent

3、 安装libfastcommon

 libfastcommon是FastDFS官方提供的,libfastcommon包含了FastDFS运行所需要的一些基础库。

(1)上传 libfastcommonV1.0.7.tar.gz到Centos机器上;

(2)将 libfastcommonV1.0.7.tar.gz解压至/usr/local/下:

tar -zxvf libfastcommonV1.0.7.tar.gz -C /usr/local/

(3)切换目录到:/usr/local/libfastcommon-1.0.7/ 下,接着进行编译和安装;

cd /usr/local/libfastcommon-1.0./
./make.sh #编译
./make.sh install #安装

安装后的截图:

(4)libfastcommon安装好后会在/usr/lib64 目录下生成  libfastcommon.so 库文件;

  

  注意:由于FastDFS程序引用usr/lib目录所以需要将/usr/lib64下的库文件拷贝至/usr/lib下。

cp libfastcommon.so /usr/lib

4、安装tracker

(1)上传 FastDFS_v5.05.tar.gz 到 centos 上;

(2)将FastDFS_v5.05.tar.gz 解压至/usr/local/下

tar -zxvf FastDFS_v5..tar.gz -C /usr/local

(3)切换目录到: /usr/local/FastDFS/ 下,编译和安装;

cd /usr/local/FastDFS/
./make.sh && ./make.sh install #编译之后接着进行安装

安装后的截图:

(4)安装成功将安装目录下的conf下的文件拷贝到/etc/fdfs/下;

cp /usr/local/FastDFS/conf/* /etc/fdfs/

5、配置和启动tracker

(1)切换目录到: /etc/fdfs/ 目录下;

(2)拷贝一份新的tracker配置文件

cp tracker.conf.sample tracker.conf

(3)修改tracker.conf ;   vim tracker.conf

base_path=/home/yuqing/fastdfs  改为:  base_path=/home/fastdfs
http.server_port 改为: 80
base_path=/home/fastdfs
http.server_port=80 #配置http端口

(4)创建 /home/fastdfs 目录

mkdir /home/fastdfs

(5)启动tracker,运行如下命令:

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

注意:在/home/fastdfs/ 目录下生成两个目录, 一个是数据,一个是日志;

6、配置和启动storage

由于上面已经安装过FastDFS,这里只需要配置storage就好了;

(1)切换目录到: /etc/fdfs/ 目录下;

(2)拷贝一份新的storage配置文件

cp storage.conf.sample storage.conf

(3)修改storage.conf ;   vim storage.conf

group_name=group1 #配置组名
base_path=/home/yuqing/fastdfs 改为: base_path=/home/fastdfs

#store存放文件的位置(store_path)
store_path0=/home/yuqing/fastdfs 改为: store_path0=/home/fdfs_storage
#如果有多个挂载磁盘则定义多个store_path,如下
#store_path1=.....
#store_path2=...... #配置tracker服务器:IP
tracker_server=192.168.172.20:22122
#如果有多个则配置多个tracker
#tracker_server=192.168.101.4:22122 #配置http端口
http.server_port=88

(4)创建 /home/fdfs_storage 目录

mkdir /home/fdfs_storage

(5)启动storage, 运行命令如下:

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

启动完成后进入 /home/fdfs_storage/data 目录下,显示目录如下:

7、使用FastDFS自带工具测试

(1)切换目录到 /etc/fdfs/ 目录下;

(2)拷贝一份新的client配置文件

cp client.conf.sample client.conf

(3)修改client.conf ;   vim client.conf,修改基本路径和tracker_server如下:

注意:若tracker有多个,可以配置多个,如下:

  #tracker_server=......

  #tracker_server=......

(4)拷贝一张图片luzhouYue.jpg 到Centos服务器上的 /usr1 目录下;

  

(5)进行测试,运行如下:(运行测试程序,读取/etc/fdfs/client.conf 文件,上传/usr1目录下的luzhouYue.jpg文件)

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /usr1/luzhouYue.jpg

结果如下,表示搭建成功;

以上图中的文件地址:http://192.168.172.20/group1/M00/00/00/wKisFFpBG9eAHaQvAAAWKd1hQR4158_big.jpg  对应storage服务器上的/home/fdfs_storage/data/00/00/wKisFFpBG9eAHaQvAAAWKd1hQR4158_big.jpg文件;

由于现在还没有和nginx整合无法使用http下载。

8、FastDFS 和nginx整合

8.1 在tracker上安装 nginx

在每个tracker上安装nginx,的主要目的是做负载均衡及实现高可用。如果只有一台tracker可以不配置nginx。

一个tracker对应多个storage,通过nginx对storage负载均衡;

8.2 在storage 上安装nginx

(1)上传 fastdfs-nginx-module_v1.16.tar.gz 到Centos服务器上;

(2)解压 fastdfs-nginx-module_v1.16.tar.gz 到 /usr/local目录下;

tar -zxvf fastdfs-nginx-module_v1..tar.gz -C /usr/local

(3)切换目录到: /usr/local/fastdfs-nginx-module/src/ 目录下

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

(4)修改config文件,将文件中的所有 /usr/local/ 路径改为 /usr/

修改完成后:

(5)将fastdfs-nginx-module/src下的mod_fastdfs.conf拷贝至/etc/fdfs/下

cp mod_fastdfs.conf /etc/fdfs/

(6)并修改 /etc/fdfs/mod_fastdfs.conf 的内容;vi /etc/fdfs/mod_fastdfs.conf

base_path=/tmp 修改为 base_path=/home/fastdfs

base_path=/home/fastdfs
tracker_server=192.168.172.20:22122
#tracker_server=192.168.172.20:22122 #(多个tracker配置多行)
url_have_group_name=true #url中包含group名称
store_path0=/home/fdfs_storage #指定文件存储路径(上面配置的store路径)

(7)将libfdfsclient.so拷贝至/usr/lib下

cp /usr/lib64/libfdfsclient.so /usr/lib/

(8)创建nginx/client目录

mkdir -p /var/temp/nginx/client

8.3 Nginx的安装

(1)上传 nginx-1.8.0.tar.gz 到Centos服务器上;

(2)解压 nginx-1.8.0.tar.gz 到 /usr/local目录下;

tar -zxvf nginx-1.8..tar.gz -C /usr/local/

(3)安装nginx的依赖库

yum install pcre
yum install pcre-devel
yum install zlib
yum install zlib-devel
yum install openssl
yum install openssl-devel

(4)进入nginx解压的目录下:cd /usr/local/nginx-1.8.0/

(5)加入模块命令配置

./configure \
--prefix=/usr/local/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/fastdfs-nginx-module/src

  

注意:上边将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录;

(6)编译并安装

make && make install

安装成功后查看生成的目录,如下所示:

(7)拷贝配置文件到 /etc/fdfs 下;

cd /usr/local/FastDFS/conf
cp http.conf mime.types /etc/fdfs/

(8)修改nginx配置文件

mkdir /usr/local/nginx/logs # 创建logs目录
cd /usr/local/nginx/conf/
vim nginx.conf

做如下的修改:

  

  

说明

  (a.) server_name指定本机ip;

  (b.) location /group1/M00/:group1为nginx 服务FastDFS的分组名称,M00是FastDFS自动生成编号,对应store_path0=/home/fdfs_storage,如果FastDFS定义store_path1,这里就是M01

(9)nginx的启动

cd /usr/local/nginx/sbin/
./nginx

查询nginx进程

  

(10) fastdfs 和 nginx 服务的开机自启动: http://www.cnblogs.com/yufeng218/p/8215381.html

9、在浏览器中访问上传到fastDFS的图片

因为Centos系统有防火墙,需要先关闭掉,才可以在浏览器中访问;

(1)CentOS 7.0默认使用的是firewall作为防火墙;若没有启用iptables 作为防火墙,则使用以下方式关闭防火墙:

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

  

(2)若已经启用iptables作为防火墙,则使用以下方式关闭:

service iptables stop  #临时关闭防火墙
chkconfig iptables off #永久关闭防火墙

防火墙的相关链接:http://www.jb51.net/article/101576.htm

           http://www.linuxidc.com/Linux/2015-05/117473.htm

(3)在谷歌浏览器中访问刚才上传的图片:

刚才上传的图片地址为:http://192.168.172.20/group1/M00/00/00/wKisFFpBG9eAHaQvAAAWKd1hQR4158_big.jpg

/usr/local/nginx/

Centos7 上安装 FastDFS的更多相关文章

  1. Centos7 上安装FastDFS

    Centos7 上安装 FastDFS 本文章摘抄于 风止鱼歇  博客地址:https://www.cnblogs.com/yufeng218/p/8111961.html 1.安装gcc(编译时需要 ...

  2. LiunxCentos7 上安装 FastDFS

    Centos7 上安装 FastDFS 1.安装gcc(编译时需要) FastDFS是C语言开发,安装FastDFS需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gc ...

  3. 在centos7上安装Jenkins

    在centos7上安装Jenkins 安装 添加yum repos,然后安装 sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins ...

  4. 在 CentOS7 上安装 zookeeper-3.4.9 服务

    在 CentOS7 上安装 zookeeper-3.4.9 服务 1.创建 /usr/local/services/zookeeper 文件夹: mkdir -p /usr/local/service ...

  5. 在 CentOS7 上安装 MongoDB

    在 CentOS7 上安装 MongoDB 1 通过 SecureCRT 连接至 CentOS7 服务器: 2 进入到 /usr/local/ 目录: cd /usr/local 3 在当前目录下创建 ...

  6. 在 CentOS7 上安装 MySQL5.7

    在 CentOS7 上安装 MySQL5.7 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中: cd /usr/local/ 3 创建 ...

  7. 在 CentOS7 上安装 Tomcat9

    在 CentOS7 上安装 Tomcat9 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中: cd /usr/local/ 3 创建目 ...

  8. 在CentOS7上安装JDK1.8

    在CentOS7上安装JDK1.8 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中: cd /usr/local/ 3 创建目录 to ...

  9. 在Centos7上安装漏洞扫描软件Nessus

    本文摘要:简单叙述了在Centos7上安装Nessus扫描器的过程   Nessus 是目前全世界最多人使用的系统漏洞扫描与分析软件,Nessus的用户界面是基于Web界面来访问Nessus漏洞扫描器 ...

随机推荐

  1. 编程四剑客sed-2019.2.20

    sed    [-Options]     [‘Commands’]    filename; sed工具默认处理文本,文本内容输出屏幕已经修改,但是文件内容其实没有修改,需要加-i参数即对文件彻底修 ...

  2. hdu1799-循环多少次?-(组合恒等式)

    循环多少次? Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  3. EVIL TWIN AP

    git clone https://github.com/P0cL4bs/3vilTwinAttacker.git cd 3vilTwinAttacker/ ./installer.sh --inst ...

  4. python 函数的定义及传参

    函数是一个通用的程序结构部件,是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 定义一个简单的函数: >>> def test(a): #创建一个函数,函数名是test ...

  5. 设置input标签的placeholder的样式

    设置input样式代码: input::-webkit-input-placeholder{ /*WebKit browsers*/ color: red; } input::-moz-input-p ...

  6. Testng 常用总结

    自动化测试过程中使用testng管理测试用例是常规的做法,我们需要对它的特性有一个深入的了解和认识: testng的原理: 参考:https://blog.csdn.net/dm_vincent/ar ...

  7. Android 性能测试之CPU

    接上一篇 CPU跟内存一样,存在一些测试子项,如下清单所示 1.空闲状态下的应用CPU消耗情况 2.中等规格状态下的应用CPU消耗情况 3.满规格状态下的应用CPU消耗情况 4.应用CPU峰值情况 C ...

  8. TOJ4757: 12345(数学)

    传送门 时间限制(普通/Java):1000MS/3000MS     内存限制:65536KByte 描述 为了说明水题也不是那么好AC的,FD出了一个由数字1~5组成的题目,题意如下: 给定一个正 ...

  9. 【zookeeper】使用场景

    以下场景是我认为的zookeeper可能会大显身手的场景. 场景1:配置新增和更新 我们可以将zookeeper部署成一个配置服务,实现配置的存储和发布等功能. 具体的原理是:zookeeper可以按 ...

  10. TZOJ 2560 Geometric Shapes(判断多边形是否相交)

    描述 While creating a customer logo, ACM uses graphical utilities to draw a picture that can later be ...