更新yum源

cd /etc/yum.repos.d
wget http://mirrors.aliyun.com/repo/Centos-7.repo
yum update

安装gcc(编译时需要)

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

yum install -y gcc gcc-c++

安装libevent(运行时需求)

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

yum -y install libevent

安装libfastcommon

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

(1)上传libfastcommon-master.zip到Centos机器上;

(2)将libfastcommon-master.zip移至/usr/local/下并解压:

unzip libfastcommon-master.zip

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

cd libfastcommon-masteryum install binutils #重要!否则下面编译出错!
./make.sh
./make.sh install

安装后的返回信息:

[root@node3 libfastcommon-master]# ./make.sh install
mkdir -p /usr/lib64
mkdir -p /usr/lib
 libfastcommon.so /usr/lib64
 libfastcommon.so /usr/lib
mkdir -p /usr/include/fastcommon
 common_define.h hash.h chain.h logger.h base64.h shared_func.h pthread_func.h ini_file_reader.h _os_define.h sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h fast_timer.h process_ctrl.h fast_mblock.h connection_pool.h fast_mpool.h fast_allocator.h fast_buffer.h skiplist.h multi_skiplist.h flat_skiplist.h skiplist_common.h system_info.h fast_blocked_queue.h php7_ext_wrapper.h id_generator.h char_converter.h char_convert_loader.h /usr/include/fastcommon

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

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

cp libfastcommon.so /usr/lib

安装tracker

(1)上传 fastdfs-master.zip 到 centos 上;

(2)将 fastdfs-master.zip解压至/usr/local/下

unzip fastdfs-master.zip

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

cd fastdfs-master
./make.sh && ./make.sh install

安装后的返回信息:

mkdir -p /usr/include/fastdfs
cp -f ../common/fdfs_define.h ../common/fdfs_global.h ../common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h ../tracker/fdfs_shared_func.h ../storage/trunk_mgr/trunk_shared.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/include/fastdfs
if [ ! -f /etc/fdfs/client.conf.sample ]; then cp -f ../conf/client.conf /etc/fdfs/client.conf.sample; fi

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

cp /usr/local/fastdfs-master/conf/* /etc/fdfs/

配置和启动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/fastdfshttp.server_port  改为: 80
base_path=/home/fastdfs
http.server_port=  #配置http端口

(4)创建 /home/fastdfs 目录:

mkdir /home/fastdfs

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

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

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

配置和启动storage

由于上面已经安装过FastDFS(由于失误,秘node3上的FastDFS安装文件夹为/root/cf/fastdfs-master/,因此拷贝命令为: cp /root/cf/fastdfs-master/conf/* /etc/fdfs/ ),这里只需要配置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服务器:IPtracker_server=10.200.101.133: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 目录下,显示目录如下:

使用FastDFS自带工具测试

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

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

cp client.conf.sample client.conf

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

base_path=/home/fdfs_client

tracker_server=10.200.101.133:22122

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

  #tracker_server=......

  #tracker_server=......

(4)拷贝一张图片Koala.jpg到Centos服务器上的/home/cf/img目录下;

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

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/cf/img/Koala.jpg

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

[root@node5 fdfs]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/cf/img/Koala.jpg
This is FastDFS client test program v5.

Copyright (C) , Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/
for more detail.

[-- ::] DEBUG - base_path=/home/fdfs_client, connect_timeout=, network_timeout=, tracker_server_count=, anti_steal_token=, anti_steal_secret_key length=, use_connection_pool=, g_connection_pool_max_idle_time=3600s, use_storage_id=, storage server 

tracker_query_storage_store_list_without_group:
        server . group_name=, ip_addr=
        server . group_name=, ip_addr=

group_name=group1, ip_addr=
storage_upload_by_filename
group_name=group1, remote_filename=M00///CshlhlzmGV6APvHtAAvqH_kipG8314.jpg
source ip address: 10.200.101.134
-- ::

example file url: http://10.200.101.134/group1/M00/00/00/CshlhlzmGV6APvHtAAvqH_kipG8314.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00///CshlhlzmGV6APvHtAAvqH_kipG8314_big.jpg
source ip address: 10.200.101.134
-- ::

example file url: http://10.200.101.134/group1/M00/00/00/CshlhlzmGV6APvHtAAvqH_kipG8314_big.jpg

以上返回信息中的文件地址:http://10.200.101.134/group1/M00/00/00/CshlhlzmGV6APvHtAAvqH_kipG8314_big.jpg 对应storage服务器上的/home/fdfs_storage/data/00/00/CshlhlzmGV6APvHtAAvqH_kipG8314_big.jpg 文件;

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

附内网中安装时测试的信息:

[root@node2 cf]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/cf/img/Koala.jpg
This is FastDFS client test program v5.

Copyright (C) , Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/
for more detail.

[-- ::] DEBUG - base_path=/home/fdfs_client, connect_timeout=, network_timeout=, tracker_server_count=, anti_steal_token=, anti_steal_secret_key length=, use_connection_pool=, g_connection_pool_max_idle_time=3600s, use_storage_id=, storage server 

tracker_query_storage_store_list_without_group:
    server . group_name=, ip_addr=
    server . group_name=, ip_addr=

group_name=group1, ip_addr=
storage_upload_by_filename
group_name=group1, remote_filename=M00///CmQEDF2A52qARueZAAvqH_kipG8075.jpg
source ip address: 10.100.4.12
-- ::

example file url: http://10.100.4.12/group1/M00/00/00/CmQEDF2A52qARueZAAvqH_kipG8075.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00///CmQEDF2A52qARueZAAvqH_kipG8075_big.jpg
source ip address: 10.100.4.12
-- ::

example file url: http://10.100.4.12/group1/M00/00/00/CmQEDF2A52qARueZAAvqH_kipG8075_big.jpg

FastDFS 和nginx整合

在tracker上安装 nginx

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

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

在storage 上安装nginx

(1)上传 fastdfs-nginx-module-master.zip 到Centos服务器上;

(2)解压 fastdfs-nginx-module-master.zip 到 /usr/local目录下;

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

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

cp mod_fastdfs.conf /etc/fdfs/

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

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

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

(6)创建nginx/client目录

mkdir -p /var/temp/nginx/client

Nginx的安装

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

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

tar -zxvf nginx-1.12.2.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.12.2/

(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-master/src

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

(6)编译并安装

make && make install

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

(7)修改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 

(10)如果端口被占用

查询进程:

lsof -i :

杀掉进程:

 PID

查询nginx进程:

ps -ef|grep nginx

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

在浏览器中访问上传到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 #永久关闭防火墙

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

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

参考:

https://www.cnblogs.com/yufeng218/p/8111961.html

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

  1. CentOS上安装FastDFS分布式文件系统

    鱼大自己写的项目简介:http://bbs.chinaunix.net/thread-1920470-1-1.html 架构简介:http://www.programmer.com.cn/4380/ ...

  2. LiunxCentos7 上安装 FastDFS

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

  3. Centos7 上安装FastDFS

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

  4. NoSql1 在Linux(CentOS)上安装memcached及使用

    前言:       今天是初五,生活基本要从过年的节奏中回归到正常的生活了,所以想想也该想想与工作有关的事情了.我之前在工作中会经常使用memcached和redis,但是自己一直没有时间系统的好好看 ...

  5. 在Ubuntu|CentOS上安装Shutter截图工具及快捷键设置

    简介 Shutter前身叫GScrot,它是一款相当棒的截图软件. 通过Shutter,你可以截取包括选定区域.全屏幕.窗口.窗口内的控件甚至网页的图像.通过内置的强大插件机制,你可以在截图后,对图像 ...

  6. 在CentOS上安装rabbitmq-server

    ***在 CentOS 6.4上安装python*** 注意啊,自己手动安装python2.7.5,不要动系统上面其他的版本 1,先安装GCC,用如下命令yum install gcc gcc-c++ ...

  7. CentOS上安装软件错误提示:configure: error: no acceptable C compiler found in $PATH

    CentOS上安装软件错误提示:configure: error: no acceptable C compiler found in $PATH 因为是centos linux,默认可以采用yum方 ...

  8. 如何在centos上安装epel源

    一.EPEL是什么? EPEL (Extra Packages for Enterprise Linux,企业版Linux的额外软件包) 是Fedora小组维护的一个软件仓库项目,为RHEL/Cent ...

  9. 在Centos上安装RabbitMQ流程(转)

    在Centos上安装RabbitMQ流程------------------------ 1. 需求 由于项目中要用到消息队列,经过ActiveMQ与RabbitMQ的比较,最终选择了RabbbitM ...

随机推荐

  1. java之中文乱码处理

    有些时候,比如文件操作的时候,特别是文件中有中文,会规定用GBK格式,这时读写文件,可能会出现中文乱码 资源文件乱码 文件内容乱码 资源文件乱码: 解决: PropertiesUtil proper ...

  2. redhat 7.6 iptables 配置

    1.查看iptables默认表(filter) iptables -L -n 2.iptables 默认内链(filter)表三种: INPUT:处理进入防火墙的数据包 FORWARD:源自其他计算机 ...

  3. 珠心算测验(0)<P2014_1>

    珠心算测验 (count.cpp/c/pas) 问题描述]  珠心算是一种通过在脑中模拟算盘变化来完成快速运算的一种计算技术.珠心算训练,既能够开发智力,又能够为日常生活带来很多便利,因而在很多学校得 ...

  4. 动态代理Cglib

    jar包 <!-- https://mvnrepository.com/artifact/cglib/cglib --><dependency> <groupId> ...

  5. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 表格:为所有表格的单元格添加边框

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  6. 企业面试问题收集-ssh框架

    SSH框架阶段 SSH的优缺点,使用场景? Hibernate优缺点 Hibernate优点:(1) 对象/关系数据库映射(ORM)它使用时只需要操纵对象,使开发更对象化,抛弃了数据库中心的思想,完全 ...

  7. MyuCMS_V2.1漏洞分析

    前言 在CNVD看到一个MyuCMS的一个任意文件删除漏洞.然后去搜了下这个CMS,发现官网公告显示在V2.2.3版本修复了CNVD提供的多处漏洞. 怀着好奇的心里,去CNVD搜了下这个CMS,结果发 ...

  8. 使用gitthub 创建项目搭建博客

    最近在学Andrew Ng 的机器学习,做了上买那个的练习题和变成作业,想着把自己做的编程作业放到GitHub,方便讨论,虽然之前注册了GitHub,但这两年整天在毕设方向的事,做的身心俱疲,再加上自 ...

  9. maven缺失ojdbc6解决方案 :Missing artifact com.oracle:ojdbc6:jar:11.2.0.1.0问题解决 ojdbc包pom.xml出错

    问题已解决,感谢博主,给您磕头了. | | 解决方法就是把缺少的 jar 手动添加到本地仓库中,再重新引入依赖即可.详情请参考以下链接. | | 转发自: https://blog.csdn.net/ ...

  10. 移动端禁止缩放<meta>

    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale= ...