FastDFS+Nginx安装配置

FastDFS+Nginx安装配置

1.系统环境

最小化安装的RedHat 6.4

fastdfs版本:FastDFS_v3.06.tar.gz

nginx版本:nginx-1.0.11.tar.gz

fastdfs-nginx-module版本:fastdfs-nginx-module_v1.10.tar.gz

tracker1:192.168.199.126

tracker2:192.168.199.127

storage1:192.168.199.128

storage2: 192.168.199.129

2.安装依赖包

yumgroupinstall -y "Development Tools"

yuminstall -y libevent-devel pcre-devel zlib-devel

3.安装配置

1.)在所有机器上安装fastdfs

mkdir –p/data/fastdfs #为以后存放日志和数据做准备

tar xvzfFastDFS_v3.06.tar.gz

cd FastDFS

vimmake.sh

#将找到下面两行,将前边的"#"去掉,目的是安装httpd和fdfs_trackerd/fdfs_storaged服务

WITH_HTTPD=1

WITH_LINUX_SERVICE=1

./make.sh

./make.shinstall

#如果遇到报错

/usr/bin/ld: cannot find -levent

collect2: ld returned 1 exit status

make: *** [fdfs_monitor] Error 1

则是缺少libevent-devel造成,需要安装libevent-devel

安装方法:

rpm -ivhlibevent-doc-1.4.13-4.el6.noarch.rpm libevent-headers-1.4.13-4.el6.noarch.rpmlibevent-devel-1.4.13-4.el6.x86_64.rpm

2.)在tracker上修改tracker.conf配置文件

vim /etc/fdfs/tracker.conf

# 配置data和log的存放路径,该路径如果不存在,需要自己创建

base_path=/data/fastdfs

# 找到下面这行包含两个"##"号

##include http.conf

# 去掉一个"#"

#include http.conf

在tracker上修改client.conf配置文件

vim/etc/fdfs/client.conf

#修改base_path

base_path=/data/fastdfs

#修改tracker地址,多个tracker写成多行,IP地址后面需要加端口

tracker_server=192.168.199.126:22122

tracker_server=192.168.199.127:22122

3.)在storage上修改storage.conf配置文件

vim/etc/fdfs/storage.conf

#修改base_path

base_path=/data/fastdfs

#修改store_path0,此为存放数据路径

store_path0=/data/fastdfs

#修改tracker地址,多个tracker写成多行,IP地址后面需要加端口

tracker_server=192.168.199.126:22122

tracker_server=192.168.199.127:22122

# 关闭内置的webserver

http.disabled=true

# webserver的端口改成80

http.server_port=80

# 此台storage1所属的服务器组名,同组内storage数据完全相同

group_name=group1

4.)在storage上安装nginx和fastdfs-nginx-module

tar xvzffastdfs-nginx-module_v1.10.tar.gz

tar xvzfnginx-1.0.11.tar.gz

cdnginx-1.0.11

./configure--prefix=/usr/local/nginx --add-module=/opt/fastdfs-nginx-module/src

make&& make install

cp/opt/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

vim/etc/fdfs/mod_fastdfs.conf

# 放置log的目录

base_path=/home/storage1/fastdfs

# tracker1的ip和端口,此处可以写多个trackerserver,每行一个

tracker_server=192.168.199.126:22122

tracker_server=192.168.199.127:22122

# 此台storageserver所属的服务组名

group_name=group1

# 在URL中包含group名称,很重要

url_have_group_name = true

# 放置文件的目录

store_path0=/data/fastdfs

==============================================

在nginx配置文件中添加如下信息

vim/usr/local/nginx/conf/nginx.conf

location /group1/M00 {

root /home/storage1/fastdfs/data;

ngx_fastdfs_module;

}

创建M00目录的软连接

ln -s/data/fastdfs/data/ /data/fastdfs/data/M00

5.)启动与监控:

tracker启动:确认8080,22122端口已经监听

/etc/init.d/fdfs_trackerdstart

tracker上面监控:

fdfs_monitor/etc/fdfs/client.conf

storage启动:确认80,23000端口已经监听

/etc/init.d/fdfs_storagedstart

storage上面监控:

fdfs_monitor/etc/fdfs/storage.conf

nginx启动:

/usr/local/nginx/sbin/nginx

4.在tracker上测试

echo‘hello,this is my first fastdfs test‘ >test.txt

/usr/local/bin/fdfs_test/etc/fdfs/client.conf upload test.txt

This isFastDFS client test program v3.06

Copyright(C) 2008, Happy Fish / YuQing

FastDFSmay be copied only under the terms of the GNU General

PublicLicense V3, which may be found in the FastDFS source kit.

Pleasevisit the FastDFS Home Page http://www.csource.org/

for moredetail.

[2015-08-1212:59:22] INFO - base_path=/data/fastdfs, 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=10.10.212.135,port=23000

server 2. group_name=group1,ip_addr=192.168.199.129, port=23000

group_name=group1,ip_addr=192.168.199.129, port=23000

storage_upload_by_filename

group_name=group1,remote_filename=M00/00/00/wKjHgVXK0qqKJ6VhAAAAJP1L3N8706.txt

source ipaddress: 192.168.199.129

filetimestamp=2015-08-12 12:59:22

filesize=36

filecrc32=4249607391

file url:http://10.10.212.134:8080/group1/M00/00/00/wKjHgVXK0qqKJ6VhAAAAJP1L3N8706.txt

storage_upload_slave_by_filename

group_name=group1,remote_filename=M00/00/00/wKjHgVXK0qqKJ6VhAAAAJP1L3N8706_big.txt

source ipaddress: 192.168.199.129

filetimestamp=2015-08-12 12:59:22

filesize=36

filecrc32=4249607391

file url: http://10.10.212.134:8080/group1/M00/00/00/wKjHgVXK0qqKJ6VhAAAAJP1L3N8706_big.txt

使用浏览器打开上面任一地址地址,如果看到文件内容,说明配置成功!

5.FAQ

1.)查看当前监控信息,在tracker上执行fdfs_monitor/etc/fdfs/client.conf和在storage上执行fdfs_monitor/etc/fdfs/storage.conf得到的结果一样。

[[email protected]]# fdfs_monitor /etc/fdfs/client.conf

[2015-08-1213:08:34] INFO - base_path=/data/fastdfs, connect_timeout=30,network_timeout=60, tracker_server_count=2, anti_steal_token=0,anti_steal_secret_key length=0

server_count=2,server_index=0

trackerserver is 10.10.212.134:22122

groupcount: 1

Group 1:

group name= group1

disk freespace = 36 GB

trunk freespace = 0 GB

storageserver count = 2

activeserver count = 2

storageserver port = 23000

storageHTTP port = 80

store pathcount = 1

subdircount per path = 256

currentwrite server index = 1

currenttrunk file id = 0

Storage 1:

ip_addr = 10.10.212.135  ACTIVE

http domain =

version = 3.06

join time = 2015-05-20 13:44:32

up time = 2015-08-12 10:35:12

total storage = 45GB

free storage = 36GB

upload priority = 10

store_path_count = 1

subdir_count_per_path = 256

storage_port = 23000

storage_http_port = 80

current_write_path = 0

source ip_addr =

if_trunk_server= 0

total_upload_count = 9283

success_upload_count = 9283

total_append_count = 0

success_append_count = 0

total_set_meta_count = 1688

success_set_meta_count = 1688

total_delete_count = 132

success_delete_count = 132

total_download_count = 4539

success_download_count = 4539

total_get_meta_count = 0

success_get_meta_count = 0

total_create_link_count = 0

success_create_link_count = 0

total_delete_link_count = 0

success_delete_link_count = 0

total_upload_bytes = 2474396113

success_upload_bytes =2474396113

total_append_bytes = 0

success_append_bytes = 0

stotal_download_bytes =377438594

success_download_bytes =377438594

total_sync_in_bytes = 67059

success_sync_in_bytes = 67059

total_sync_out_bytes =2435190011

success_sync_out_bytes =2435190011

total_file_open_count = 13836

success_file_open_count = 13836

total_file_read_count = 5176

success_file_read_count = 5176

total_file_write_count = 16999

success_file_write_count =16999

last_heart_beat_time =2015-08-12 13:05:44

last_source_update = 2015-08-1211:37:09

last_sync_update = 2015-08-1213:00:26

last_synced_timestamp = 2015-08-1212:59:22 (0s delay)

Storage 2:

ip_addr = 192.168.199.129  ACTIVE

http domain =

version = 3.06

join time = 2015-08-12 10:11:25

up time = 2015-08-12 10:30:23

total storage = 44GB

free storage = 37GB

upload priority = 10

store_path_count = 1

subdir_count_per_path = 256

storage_port = 23000

storage_http_port = 80

current_write_path = 0

source ip_addr = 10.10.212.135

if_trunk_server= 0

total_upload_count = 4

success_upload_count = 4

total_append_count = 0

success_append_count = 0

total_set_meta_count = 3

success_set_meta_count = 3

total_delete_count = 0

success_delete_count = 0

total_download_count = 3

success_download_count = 3

total_get_meta_count = 0

success_get_meta_count = 0

total_create_link_count = 0

success_create_link_count = 0

total_delete_link_count = 0

success_delete_link_count = 0

total_upload_bytes = 66850

success_upload_bytes = 66850

total_append_bytes = 0

success_append_bytes = 0

stotal_download_bytes = 319240

success_download_bytes = 319240

total_sync_in_bytes =2435190011

success_sync_in_bytes =2435190011

total_sync_out_bytes = 67059

success_sync_out_bytes = 67059

total_file_open_count = 10721

success_file_open_count = 10721

total_file_read_count = 3

success_file_read_count = 3

total_file_write_count = 18311

success_file_write_count =18311

last_heart_beat_time =2015-08-12 13:05:56

last_source_update = 2015-08-1212:59:22

last_sync_update = 2015-08-1211:36:11

last_synced_timestamp =2015-08-12 11:37:09 (0s delay)

#多个节点查看当前是否为激活状态和同步延时时间,

2.)增加storage节点,配置与其它节点相同,安装fastdfs、nginx后 ,把配置文件storage.confmod_fastdfs.conf copy到/etc/fdfs/即可,添加完成后重启tracker和storage,再用monitor查看同步信息及节点当前状态。

时间: 2024-10-18 13:52:57

FastDFS+Nginx安装配置的相关文章

Nginx安装配置(转)

Nginx 安装配置 Nginx("engine x")是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器. 在高连接并发的情况下,Nginx是Apache服务器不错的替代品. Nginx 安装 系统平台:CentOS release 6.6 (Final) 64位. 一.安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtoo

VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三)

首先启动Nginx 1. 转到 nginx 目录: /usr/local/nginx; 启动 nginx: /usr/local/nginx/nginx ubuntu 前要加 sudo; 关健配置 http 配置块下,一般设置在 zgip on 下: upstream localhost { #绿色对应 #ip_hash; server localhost:8090; server localhost:8080; } server / { location / { proxy_connect_t

Redhat下Nginx安装配置

1.下载Nginx curl -O http://nginx.org/download/nginx-1.7.3.tar.gz -o /home/tango 2.安装Nginx 解压 tar -zxvf /home/tango/nginx-1.7.3.tar.gz /home/tango/nginx-1.7.3-setup 准备依赖 yum install pcre-devel yum install openssl-devel 编译,进入/home/tango/nginx-1.7.3-setup

FastDFS的安装配置(2)

FastDFS的安装配置 环境介绍:centos6.8 1.下载源码包(github站点) fastdfs-master.zip  # 依赖 libfastcommon-master libfastcommon-master.zip 2.编译安装 (a)首先安装 libfastcommon-master # unzip libfastcommon-master.zip # cd libfastcommon-master/ # cat INSTALL # ./make.sh       --> 确

saltstack之多节点nginx安装配置

多节点nginx安装配置 定义多节点 cd /srv/salt vim top.sls base:  'server4.lalala.com':    - nginx.install  'server1.lalala.com':    - nginx.install 把要共享的文件放在指定目录 [[email protected] files]# pwd /srv/salt/nginx/files [[email protected] files]# ls n ginx-1.10.1.tar.g

1.Nginx安装配置

1.Nginx安装配置 Nginx("engine x")是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器. 在高连接并发的情况下,Nginx是Apache服务器不错的替代品 Nginx 安装 系统平台:CentOS release 6.6 (Final) 64位. 一.安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtoo

Nginx安装配置及调优

Nginx安装配置及调优 ? 一.安装Nginx ? 1.安装环境 [[email protected] ~]# yum –y install gcc pcre-devel openssl-devel 2.创建一个用户启动nginx [[email protected] ~]# useradd –s /sbin/nologin nginx 3.安装(不用的装模块不装) [[email protected] nginx-1.12.2]# ./configure \--prefix=/usr/loc

Nginx安装配置|Nginx反向代理|Nginx支持HTTPS|Nginx重定向

Nginx安装配置 可以直接看到最下面的HTTPS. Nginx安装 我的系统如下: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.3 LTS Release: 16.04 Codename: xenial 安装(如果有apache服务器, 建议卸载了, 或者改Nginx的默认端口): sudo apt-get install nginx 此时已经开启了80端口, 并且配置处在etc/

FastDFS+nginx安装与配置

FastDFS 是一个由 C 语言实现的开源轻量级分布式文件系统 环境 centos7安装gcc yum install gcc-c++ -y 2.libeventyum -y install libevent如果没有perl库,需要使用yum install perl* 命令安装一下yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel pe