Try 5.05 fastdfs

1 版本信息

服务器使用的系统为centos7.1, fastdfs版本为5.05稳定版

服务器ip分别是:

172.27.12.65,作为tracker机器

172.27.12.61,作为group1的storage

172.27.12.67,作为group2的storage

2 FastDFS安装配置

2.1 FastDFS安装

2.1.1 下载FastDFS及相关

下载fastdfs-5.05:

wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz

下载libfastcommon-master:

wget https://github.com/happyfish100/libfastcommon/archive/master.zip

下载fastdfs module:

wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip

下载nginx lua:

wget http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz

2.1.2 安装FastDFS依赖

安装编译环境,执行命令:

sudo yum -y groupinstall ‘Development Tools‘

安装libfastcommon,执行命令:

cd libfastcommon-master

./make.sh

sudo ./make.sh install

2.1.3 安装FastDFS

cd fastdfs-5.05/

./make.sh

sudo ./make.sh install

2.2 FastDFS配置

添加用户

sudo useradd fastdfs -M -s /sbin/nologin

创建文件夹

sudo mkdir -p /data/fdfs/

sudo chown -R fastdfs:fastdfs /data/fdfs

2.2.1 配置tracker服务器

在65服务器上配置tracker服务器,只列出修改的内容,未列出内容无需修改。添加配置文件:

sudo cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf

修改tracker配置文件:

base_path=/data/fdfs

run_by_group=fastdfs

run_by_user=fastdfs

2.2.2 启动tracker

执行启动命令:

sudo /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start

2.2.3 配置storage服务器

分别在61和67服务器,修改storage.conf文件,只列出修改的内容,未列出内容无需修改。添加storage配置文件:

cd /etc/fdfs

sudo cp storage.conf.sample storage.conf

修改group1的storage配置文件

group_name=group1

run_by_group=fastdfs

run_by_user=fastdfs

base_path=/data/fdfs

tracker_server=192.168.1.50:22122

store_path0=/data/fdfs

修改group2的storage的配置文件

run_by_group=fastdfs

run_by_user=fastdfs

group_name=group2

base_path=/data/fdfs

tracker_server=192.168.1.51:22122

store_path0=/data/fdfs

2.2.4 启动storage

分别在61和67服务器执行启动storage命令:

sudo /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

storage正确启动后,需要创建连接。分别在61和67服务器,执行命令:

sudo ln -s /data/fdfs/data /data/fdfs/data/M00

2.2.5 配置storage的测试客户端

为storage服务器添加配置客户端文件

cd /etc/fdfs

sudo cp client.conf.sample client.conf

修改client.conf文件,未列出内容无需修改,修改项如下:

base_path=/data/fdfs

tracker_server=192.168.1.50:22122

3 Openresty Nginx Lua安装和配置

3.1 Openresty Nginx Lua安装

在/usr/yKF6600/fdfs目录,下载并解压fastdfs-nginx-module,执行命令:

wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip

unzip fastdfs-nginx-module-master.zip

在/usr/yKF6600/fdfs目录,下载并解压openresty nginx lua,执行命令:

wget http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz

tar -zxvf ngx_openresty-1.7.10.1.tar.gz

3.1.1 安装ngx_openresty

安装编译环境

sudo yum install pcre-devel openssl openssl-devel

安装ngx_openresty,在ngx_openresty目录,执行

sudo ./configure --with-luajit --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --add-module=/usr/yKF6600/fastdfs/fastdfs-nginx-module-master/src

sudo gmake

sudo gmake install

创建nginx使用的目录

sudo mkdir /data/ngx

sudo chown -R fastdfs:fastdfs /data

创建mod_fastdfs.conf文件

sudo cp /usr/yKF6600/fdfs/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/

3.2 配置ngx_openresty

3.2.1 修改mod_fastdfs.conf文件

分别咋61和67机器执行

sudo touch /data/ngx/mod_nginx.log

sudo chown –R fastdfs:fastdfs /data

61机器为group1的storage服务器,修改/etc/fdfs/mod_fastdfs.conf文件(未列出内容无需修改),修改的内容如下:

base_path=/data/ngx

tracker_server=192.168.1.36:22122

group_name=group1

store_path0=/data/fdfs

url_have_group_name = true

log_filename=/data/ngx/mod_nginx.log

group_count = 2

[group1]

group_name=group1

storage_server_port=23000

store_path_count=1

store_path0=/data/fdfs

[group2]

group_name=group2
storage_server_port=23000

store_path_count=1

store_path0=/data/fdfs

67服务器为group2的storage服务器,修改/etc/fdfs/mod_fastdfs.conf(未列出内容无需修改),修改的内容如下:

base_path=/data/ngx

tracker_server=192.168.1.36:22122

group_name=group2

store_path0=/data/fdfs

url_have_group_name = true

log_filename=/data/ngx/mod_nginx.log

group_count = 2

[group1]

group_name=group1

storage_server_port=23000

store_path_count=1

store_path0=/data/fdfs

[group2]

group_name=group2

storage_server_port=23000

store_path_count=1

store_path0=/data/fdfs

3.2.2 添加http.conf和mine.types文件

分别在61和67服务器复制http.conf和mime.types到/etc/fdfs目录

cd /usr/yKF6600/fdfs/fastdfs-5.05/conf

sudo cp http.conf mime.types /etc/fdfs/

3.2.3 配置nginx.conf文件

在61服务器上,修改group1的nginx的/usr/local/openresty/nginx/conf/nginx.conf

#user nobody;

user fastdfs;

worker_processes 1;

error_log /data/ngx/error.log;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘

‘$status $body_bytes_sent "$http_referer" ‘

‘"$http_user_agent" "$http_x_forwarded_for"‘;

access_log /data/ngx/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

server {

listen 80;

server_name localhost;

charset utf8;

location /group1/M00 {

alias /data/fdfs/data;

ngx_fastdfs_module;

}

}

}

在67服务器上,修改nginx.conf,因为group2的nginx.conf文件内容只有如下内容和group1的nginx.conf内容不一致,其他按照group1的nginx.conf配置修改:

location /group2/M00 {

alias /data/fdfs/data;

ngx_fastdfs_module;

}

3.2.4 启动或者重载入nginx配置文件

启动nginx命令:

sudo /usr/local/openresty/nginx/sbin/nginx

重新载入nginx配置:

sudo /usr/local/openresty/nginx/sbin/nginx -s reload

4 上传测试

创建test.html页面,输入如下内容

test fastdfs

上传测试文件,命令为:

/usr/bin/fdfs_test /etc/fdfs/client.conf upload test.html

返回结果类似为为:

[2016-05-04 02:06:56] DEBUG - base_path=/data/fdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group:

server 1. group_name=, ip_addr=172.27.12.61, port=23000

group_name=group1, ip_addr=172.27.12.61, port=23000

storage_upload_by_filename

group_name=group1, remote_filename=M00/00/00/rBAEYVcpWTqAWVsvAAAADcvBslg32.html

source ip address: 172.27.12.61

file timestamp=2016-05-04 02:06:50

file size=13

file crc32=3418468952

example file url: http://172.27.12.61/group1/M00/00/00/rBAEYVcpWTqAWVsvAAAADcvBslg32.html

storage_upload_slave_by_filename

group_name=group1, remote_filename=M00/00/00/rBAEYVcpWTqAWVsvAAAADcvBslg32_big.html

source ip address: 172.27.12.61

file timestamp=2016-05-04 02:06:50

file size=13

file crc32=3418468952

example file url: http://172.27.12.61/group1/M00/00/00/rBAEYVcpWTqAWVsvAAAADcvBslg32_big.html

访问上传的页面,执行命令:

curl http://172.27.12.61/group1/M00/00/00/rBAEYVcpWTqAWVsvAAAADcvBslg32_big.html

得到结果为:

test fdfs

如果无法成功上传误,可以在storage服务器上使用fdfs_monitor检测是否有错误。命令为fdfs_monitor /etc/fdfs/storage.conf

以下是使用fdfs_monitor检测为运行正常的结果:

[2016-05-04 17:36:37] DEBUG - base_path=/data/fdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

server_count=1, server_index=0

tracker server is 172.27.12.65:22122

group count: 2

Group 1:

group name = group1

disk total space = 36426 MB

disk free space = 31228 MB

trunk free space = 0 MB

storage server count = 1

active server count = 1

storage server port = 23000

storage HTTP port = 8888

store path count = 1

subdir count per path = 256

current write server index = 0

current trunk file id = 0

Storage 1:

id = 172.27.12.61

ip_addr = 172.27.12.61 ACTIVE

http domain =

version = 5.05

join time = 2016-05-04 17:05:01

up time = 2016-05-04 17:05:01

total storage = 36426 MB

free storage = 31228 MB

upload priority = 10

store_path_count = 1

subdir_count_per_path = 256

storage_port = 23000

storage_http_port = 8888

current_write_path = 0

source storage id =

if_trunk_server = 0

connection.alloc_count = 256

connection.current_count = 0

connection.max_count = 0

total_upload_count = 0

success_upload_count = 0

total_append_count = 0

success_append_count = 0

total_modify_count = 0

success_modify_count = 0

total_truncate_count = 0

success_truncate_count = 0

total_set_meta_count = 0

success_set_meta_count = 0

total_delete_count = 0

success_delete_count = 0

total_download_count = 0

success_download_count = 0

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 = 0

success_upload_bytes = 0

total_append_bytes = 0

success_append_bytes = 0

total_modify_bytes = 0

success_modify_bytes = 0

stotal_download_bytes = 0

success_download_bytes = 0

total_sync_in_bytes = 0

success_sync_in_bytes = 0

total_sync_out_bytes = 0

success_sync_out_bytes = 0

total_file_open_count = 0

success_file_open_count = 0

total_file_read_count = 0

success_file_read_count = 0

total_file_write_count = 0

success_file_write_count = 0

last_heart_beat_time = 2016-05-04 17:31:37

last_source_update = 1970-01-01 08:00:00

last_sync_update = 1970-01-01 08:00:00

last_synced_timestamp = 1970-01-01 08:00:00

Group 2:

group name = group2

disk total space = 36426 MB

disk free space = 32921 MB

trunk free space = 0 MB

storage server count = 1

active server count = 1

storage server port = 23000

storage HTTP port = 8888

store path count = 1

subdir count per path = 256

current write server index = 0

current trunk file id = 0

Storage 1:

id = 172.27.12.67

ip_addr = 172.27.12.67 (ci-dmz-c03) ACTIVE

http domain =

version = 5.05

join time = 2016-05-04 17:33:01

up time = 2016-05-04 17:33:01

total storage = 36426 MB

free storage = 32921 MB

upload priority = 10

store_path_count = 1

subdir_count_per_path = 256

storage_port = 23000

storage_http_port = 8888

current_write_path = 0

source storage id =

if_trunk_server = 0

connection.alloc_count = 256

connection.current_count = 0

connection.max_count = 0

total_upload_count = 0

success_upload_count = 0

total_append_count = 0

success_append_count = 0

total_modify_count = 0

success_modify_count = 0

total_truncate_count = 0

success_truncate_count = 0

total_set_meta_count = 0

success_set_meta_count = 0

total_delete_count = 0

success_delete_count = 0

total_download_count = 0

success_download_count = 0

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 = 0

success_upload_bytes = 0

total_append_bytes = 0

success_append_bytes = 0

total_modify_bytes = 0

success_modify_bytes = 0

stotal_download_bytes = 0

success_download_bytes = 0

total_sync_in_bytes = 0

success_sync_in_bytes = 0

total_sync_out_bytes = 0

success_sync_out_bytes = 0

total_file_open_count = 0

success_file_open_count = 0

total_file_read_count = 0

success_file_read_count = 0

total_file_write_count = 0

success_file_write_count = 0

last_heart_beat_time = 2016-05-04 17:31:45

last_source_update = 1970-01-01 08:00:00

last_sync_update = 1970-01-01 08:00:00

last_synced_timestamp = 1970-01-01 08:00:00

时间: 2024-10-12 06:47:33

Try 5.05 fastdfs的相关文章

05: 分布式文件系统 、 FastDFS原理 、 FastDFS配置及应用

部署分布式存储服务一.分布式文件系统介绍 二.配置分布式存储服务2.1 配置主控节点(111) 装包 修改配置文件 启动服务 查看端口]# yum -y install gcc gcc-c++ libevent]# cd fastdfs]# yum -y install libevent-*.rpm]#tar -zxf FastDFS_v4.06.tar.gz ]#cd FastDFS]#./make.sh ]#./make.sh install]# ls /etc/fdfs/ #配置文件存放目

FastDFS的php和nginx模块配置

一.FastDFS和php整合 1.安装php # 安装依赖包 yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel cu

[项目构建 五]babasport ajax图片上传及FastDFS入门案例.

今天来开始写图片上传的功能, 现在的图片上传都讲求 上传完成后立刻回显且页面不刷新, 这里到底是怎么做的呢? 当然是借助于ajax了, 但是ajax又不能提交表单, 这里我们还要借助一个插件: jquery.form.js剩下的一个是FastDFS, 那么什么是FastDFS呢? FastDFS是一个开源的轻量级分布式文件系统,由跟踪服务器(tracker server).存储服务器(storage server)和客户端(client)三个部分组成,主要解决了海量数据存储问题,特别适合以中小文

fastdfs集群

基础环境说明 6台服务器 两台tracker  4台storages 192.168.56.131 tracker 服务器 edu-dfs-tracker-1 192.168.56.132 tracker 服务器 edu-dfs-tracker-2 192.168.56.135 storage服务器 edu-dfs-storage-group1-1 192.168.56.136 storage服务器 edu-dfs-storage-group1-2 192.168.56.137 storage服

windows 下文件上传到fastdfs

php.ini 配置 [fastdfs]; the base pathfastdfs_client.base_path = D:/tmp; connect timeout in seconds; default value is 30sfastdfs_client.connect_timeout = 2; network timeout in seconds; default value is 30sfastdfs_client.network_timeout = 60 ; standard l

一、CentOS7下搭建FastDFS+Nginx实现静态图片服务器

在集群环境下,图片存放在本地存在诸多限制,一般采用单独的图片服务器进行管理.FastDFS就是这样一个图片管理服务器. 环境需求,CentOS7下 一.先下载三件套,并上传到服务器中(Nginx自行下载),地址如下 1:libfastcommon https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz 2:fastdfs https://github.com/happyfish100/fastdfs/archive/

FastDFS 集群的安装、配置、使用

FastDFS 集群的安装.配置.使用 FastDFS 介绍(参考:http://www.oschina.net/p/fastdfs) FastDFS 是一个开源的分布式文件系统,它对文件进行管理,功能包括:文件存储.文件同步.文件 访问(文件上传.文件下载)等,解决了大容量存储和负载均衡的问题.特别适合以文件为载体的在线服务,如相册网站.视频网站等等. FastDFS 服务端有两个角色:跟踪器(tracker)和存储节点(storage).跟踪器主要做调度工作,在访问上起负载均衡的作用.存储节

Linux 下 FastDFS v5.08 分布式文件系统的安装

一.系统安装目录 源代码包目录 /data/wwwroot libevent安装目录 /usr/local/libevent FastDFS安装目录 /data/fastdfs nginx安装目录 /data/nmp/nginx 二.下载FastDFS安装包 https://sourceforge.net/projects/fastdfs/files/ 如:FastDFS_v5.08.tar.gz https://sourceforge.net/projects/fastdfs/files/Fa

Centos6.5 -- fastdfs安装(虚拟机搭建集群)

一.操作系统概述 电脑型号     X64 兼容 台式电脑  (扫描时间:2016年11月14日) 操作系统     Windows 7 旗舰版 64位 SP1 ( DirectX 11 ) 处理器  英特尔 Core i7-6700K @ 4.00GHz 四核 主板      华硕 B150M-A/M.2 ( 英特尔 Skylake-S - 100 Series/C230 Series 芯片组 Family - A148 ) 内存      16 GB ( Avexir DDR4 2400MH