设为首页 收藏本站
查看: 1647|回复: 0

[经验分享] FastDFS+Nginx安装配置笔记

[复制链接]

尚未签到

发表于 2018-11-12 12:49:03 | 显示全部楼层 |阅读模式
  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>  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>  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
  如果看到文件内容,说明配置成功!



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-634168-1-1.html 上篇帖子: nginx中的CA证书的实现详解 下篇帖子: Nginx安装加载ssl错误
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表