热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

fastdfs+nginx安装配置过程

1.系统环境最小化安装的CentOS6.2tracker1:192.168.68.113tracker1:192.168.68.116storage1:192.168.68.114storage1:192.168.68.1152.环境准备[所有服务器都需要]安装EPEL源rpm-ivhepel-release-6-6.
1.系统环境
最小化安装的 CentOS 6.2
tracker1:   192.168.68.113
tracker1:   192.168.68.116
storage1:   192.168.68.114
storage1:   192.168.68.115
2.环境准备[所有服务器都需要]
安装EPEL源
rpm -ivh epel-release-6-6.noarch.rpm
安装开发工具和编译nginx所需的开发包
yum groupinstall -y "Development Tools"
yum install -y libevent-devel pcre-devel zlib-devel
3.在tracker上的安装配置
[root@tracker1]# wget http://fastdfs.googlecode.com/files/FastDFS_v3.06.tar.gz
[root@tracker1]# tar xvzf FastDFS_v3.06.tar.gz
[root@tracker1]# cd FastDFS
[root@tracker1]# vi make.sh
#将找到下面两行,将前边的"#"去掉,目的是安装httpd和fdfs_trackerd/fdfs_storaged服务
    WITH_HTTPD=1
    WITH_LINUX_SERVICE=1
[root@tracker1]# ./make.sh
[root@tracker1]# ./make.sh install
[root@tracker1]# vi /etc/fdfs/tracker.conf
修改/etc/fdfs/tracker.conf,主要修改以下两处,如有其他调整,可参考文档自行调整,默认的配置也可以工作。
    # 配置data和log的存放路径,该路径如果不存在,需要自己创建
    base_path=/home/tracker1/fastdfs
    # 找到下面这行包含两个"##"号
    ##include http.conf
    # 去掉一个"#"
    #include http.conf
[root@tracker1]# mkdir -p /home/tracker1/fastdfs
启动tracker服务
[root@tracker1]# service fdfs_trackerd start
确认8080,22122端口已经监听
[root@tracker1]# netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:111                 0.0.0.0:* LISTEN
tcp        0      0 0.0.0.0:8080                0.0.0.0:* LISTEN
tcp        0      0 0.0.0.0:22  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:45372               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:22122               0.0.0.0:*                   LISTEN
tcp        0      0 :::111    :::*                        LISTEN
tcp        0      0 :::22     :::*                        LISTEN
tcp        0      0 :::45032  :::*                        LISTEN
4.在storage上的安装配置
下载FastDFS,Nginx和fastdfs-nginx-module
[root@storage1]# wget http://fastdfs.googlecode.com/files/FastDFS_v3.06.tar.gz
[root@storage1]# wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.10.tar.gz
[root@storage1]# wget http://nginx.org/download/nginx-1.0.11.tar.gz
安装FastDFS =>安装方法与tracker1上相同。
安装nginx和fastdfs-nginx-module
[root@storage1]# tar xvzf nginx-1.0.11.tar.gz
[root@storage1]# tar xvzf fastdfs-nginx-module_v1.10.tar.gz
[root@storage1]# cd nginx-1.0.11
[root@storage1]# ./configure --prefix=/usr/local/nginx --add-module=/home/fastdfs-nginx-module/src
[root@storage1]# make
[root@storage1]# make install
[root@storage1]# vi /etc/fdfs/storage.conf
修改/etc/fdfs/storage.conf,主要修改以下几处,如有其他调整,可参考文档自行调整,默认的配置也可以工作。
    
    # HTTP settings
    # 关闭内置的web server
    http.disabled=true
    # the port of the web server on this storage server
    # web server的端口改成80
    http.server_port=80
    # the name of the group this storage server belongs to
    # 此台storage1所属的服务器组名,同组内storage数据完全相同
    group_name=group1
    # the base path to store data and log files
    # 放置data和log的目录
    base_path=/home/storage1/fastdfs
    # store_path#, based 0, if store_path0 not exists, it's value is base_path
    # the paths must be exist
    # 放置文件的目录
    store_path0=/home/storage1/fastdfs
    # tracker_server can ocur more than once, and tracker_server format is
    # "host:port", host can be hostname or ip address
    # tracker server的ip和端口,此处可以写多个tracker server,每行一个
    tracker_server=192.168.68.113:22122
    tracker_server=192.168.68.116:22122
[root@storage1]# cp /home/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
[root@storage1]# vi /etc/fdfs/mod_fastdfs.conf
    # the base path to store log files
    # 放置log的目录
    base_path=/home/storage1/fastdfs
    # FastDFS tracker_server can ocur more than once, and tracker_server format is
    # "host:port", host can be hostname or ip address
    # tracker1的ip和端口,此处可以写多个tracker server,每行一个
    tracker_server=192.168.68.113:22122
    tracker_server=192.168.68.116:22122
    # the group name of storage server
    # 此台storage server所属的服务器组名
    group_name=group1
    # if uri including group name
    # default value is false
    # 在URL中包含group名称
    url_have_group_name = true
    # store_path#, based 0, if store_path0 not exists, it's value is base_path
    # the paths must be exist
    # 放置文件的目录
    store_path0=/home/storage1/fastdfs
[root@storage1]# mkdir -p /home/storage1/fastdfs
在nginx的server配置段中增加M00的location声明
[root@storage1]# vi /usr/local/nginx/conf/nginx.conf
    location /group1/M00 {
            root /home/storage1/fastdfs/data;
            ngx_fastdfs_module;
    }
创建M00目录的软连接
[root@storage1]# ln -s /home/storage1/fastdfs/data  /home/storage1/fastdfs/data/M00
启动storage服务
[root@storage1]# service fdfs_storaged start
启动nginx,启动之前,要确定fdfs_trackerd服务已启动且相关防火墙端口已开放
[root@storage1]# /usr/local/nginx/sbin/nginx
确认80,23000端口已经监听
[root@storage1]# netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:111                 0.0.0.0:* LISTEN
tcp        0      0 0.0.0.0:80  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:22  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:23000               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:34169               0.0.0.0:*                   LISTEN
tcp        0      0 :::111    :::*                        LISTEN
tcp        0      0 :::22     :::*                        LISTEN
tcp        0      0 :::60001  :::*                        LISTEN
5.在tracker上的操作[作为client测试]
[root@tracker1]# /etc/fdfs/client.conf
    # the base path to store log files
    base_path=/tmp
    # tracker_server can ocur more than once, and tracker_server format is
    #  "host:port", host can be hostname or ip address
    tracker_server=192.168.68.113:22122
    tracker_server=192.168.68.116:22122
创建一个用于测试的文件test.txt
[root@tracker1]# vi test.txt
输入内容: hello,this is my first fastdfs test
保存。使用自带的fdfs_test上传文件测试
[root@tracker1]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload test.txt
This is FastDFS client test program v3.06
Copyright (C) 2008, 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.
[2012-06-13 17:58:25] INFO - base_path=/tmp, connect_timeout=30, network_timeout=60, tracker_server_count=2, anti_steal_token=0, anti_steal_secret_key 
length=0
tracker_query_storage_store_list_without_group:
        server 1. group_name=group1, ip_addr=192.168.68.114, port=23000
group_name=group1, ip_addr=192.168.68.114, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607.txt
source ip address: 192.168.68.114
file timestamp=2012-06-13 17:58:25
file size=37
file crc32=3584975788
file url: http://192.168.68.113:8080/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607.txt
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txt
source ip address: 192.168.68.114
file timestamp=2012-06-13 17:58:25
file size=37
file crc32=3584975788
file url: http://192.168.68.113:8080/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txt
6.使用浏览器打开上传的文件
http://192.168.68.113:8080/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txt
如果看到文件内容,说明配置成功!

推荐阅读
  • Nginx使用AWStats日志分析的步骤及注意事项
    本文介绍了在Centos7操作系统上使用Nginx和AWStats进行日志分析的步骤和注意事项。通过AWStats可以统计网站的访问量、IP地址、操作系统、浏览器等信息,并提供精确到每月、每日、每小时的数据。在部署AWStats之前需要确认服务器上已经安装了Perl环境,并进行DNS解析。 ... [详细]
  • Linux服务器密码过期策略、登录次数限制、私钥登录等配置方法
    本文介绍了在Linux服务器上进行密码过期策略、登录次数限制、私钥登录等配置的方法。通过修改配置文件中的参数,可以设置密码的有效期、最小间隔时间、最小长度,并在密码过期前进行提示。同时还介绍了如何进行公钥登录和修改默认账户用户名的操作。详细步骤和注意事项可参考本文内容。 ... [详细]
  • Ubuntu 9.04中安装谷歌Chromium浏览器及使用体验[图文]
    nsitionalENhttp:www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd ... [详细]
  • Linux如何安装Mongodb的详细步骤和注意事项
    本文介绍了Linux如何安装Mongodb的详细步骤和注意事项,同时介绍了Mongodb的特点和优势。Mongodb是一个开源的数据库,适用于各种规模的企业和各类应用程序。它具有灵活的数据模式和高性能的数据读写操作,能够提高企业的敏捷性和可扩展性。文章还提供了Mongodb的下载安装包地址。 ... [详细]
  • CentOS 7部署KVM虚拟化环境之一架构介绍
    本文介绍了CentOS 7部署KVM虚拟化环境的架构,详细解释了虚拟化技术的概念和原理,包括全虚拟化和半虚拟化。同时介绍了虚拟机的概念和虚拟化软件的作用。 ... [详细]
  • svnWebUI:一款现代化的svn服务端管理软件
    svnWebUI是一款图形化管理服务端Subversion的配置工具,适用于非程序员使用。它解决了svn用户和权限配置繁琐且不便的问题,提供了现代化的web界面,让svn服务端管理变得轻松。演示地址:http://svn.nginxwebui.cn:6060。 ... [详细]
  • Centos下安装memcached+memcached教程
    本文介绍了在Centos下安装memcached和使用memcached的教程,详细解释了memcached的工作原理,包括缓存数据和对象、减少数据库读取次数、提高网站速度等。同时,还对memcached的快速和高效率进行了解释,与传统的文件型数据库相比,memcached作为一个内存型数据库,具有更高的读取速度。 ... [详细]
  • 深入解析Linux下的I/O多路转接epoll技术
    本文深入解析了Linux下的I/O多路转接epoll技术,介绍了select和poll函数的问题,以及epoll函数的设计和优点。同时讲解了epoll函数的使用方法,包括epoll_create和epoll_ctl两个系统调用。 ... [详细]
  • Linux下安装免费杀毒软件ClamAV及使用方法
    本文介绍了在Linux系统下安装免费杀毒软件ClamAV的方法,并提供了使用该软件更新病毒库和进行病毒扫描的指令参数。同时还提供了官方安装文档和下载地址。 ... [详细]
  • LVS实现负载均衡的原理LVS负载均衡负载均衡集群是LoadBalance集群。是一种将网络上的访问流量分布于各个节点,以降低服务器压力,更好的向客户端 ... [详细]
  • CentOS7.8下编译muduo库找不到Boost库报错的解决方法
    本文介绍了在CentOS7.8下编译muduo库时出现找不到Boost库报错的问题,并提供了解决方法。文章详细介绍了从Github上下载muduo和muduo-tutorial源代码的步骤,并指导如何编译muduo库。最后,作者提供了陈硕老师的Github链接和muduo库的简介。 ... [详细]
  • 本文介绍了在无法联网的情况下,通过下载rpm包离线安装zip和unzip的方法。详细介绍了如何搜索并下载合适的rpm包,以及如何使用rpm命令进行安装。 ... [详细]
  • Linux下部署Symfoy2对app/cache和app/logs目录的权限设置,symfoy2logs
    php教程|php手册xml文件php教程-php手册Linux下部署Symfoy2对appcache和applogs目录的权限设置,symfoy2logs黑色记事本源码,vsco ... [详细]
  • 现在比较流行使用静态网站生成器来搭建网站,博客产品着陆页微信转发页面等。但每次都需要对服务器进行配置,也是一个重复但繁琐的工作。使用DockerWeb,只需5分钟就能搭建一个基于D ... [详细]
  • centos6.8 下nginx1.10 安装 ... [详细]
author-avatar
金玉的海角_745
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有