Fdfs 配置分布式文件系统
FastDFS的简介
FastDFS是一款开源的轻量级分布式文件系统纯C实现,支持Linux、FreeBSD等UNIX系统类google FS,不是通用的文件系统,只能通过专有API访问,目前提供了C、Java和PHP API为互联网应用量身定做,解决大容量文件存储问题,追求高性能和高扩展性FastDFS可以看做是基于文件的key value pair存储系统,称作分布式文件存储服务更为合适。
FastDFS服务端有两个角色:跟踪器(tracker)和存储节点(storage)。跟踪器主要做调度工作,在访问上起负载均衡的作用。
存储节点存储文件,完成文件管理的所有功能,就是这样的存储、同步和提供存取接口,FastDFS同时对文件的metadata进行管理。所谓文件的meta data就是文件的相关属性,以键值对(key valuepair)方式表示,如:width=1024,其中的key为width,value为1024。文件metadata是文件属性列表,可以包含多个键值对。
FastDFS的特性
- 分组存储,灵活简洁、对等结构,不存在单点
- 文件ID由FastDFS生成,作为文件访问凭证,FastDFS不需要传统的name server
- 和流行的web server无缝衔接,FastDFS已提供apache和nginx扩展模块
- 大、中、小文件均可以很好支持,支持海量小文件存储
- 支持多块磁盘,支持单盘数据恢复
- 支持相同文件内容只保存一份,节省存储空间
- 存储服务器上可以保存文件附加属性
- 下载文件支持多线程方式,支持断点续传
CentOS 7.0
配置虚拟机上网
yum -y install wget
yum -y install gcc
yum -y install perl
查看IP地址
ip addr
启动关闭服务
systemctl start/stop/restart <服务名>
配置网卡
TYPE=Ethernet
BOOTPROTO=no
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=04d204f1-8831-42b4-8d64-c4fc7af133d9
DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.2.138
GATEWAY=192.168.2.2
DNS1=114.114.114.114
下载libfastcommon
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.35.tar.gz
tar -zxvf V1.0.35.tar.gz
cd libfastcommon-1.0.35
./make.sh
./make.sh install
安装FastDFS
wget https://github.com/happyfish100/fastdfs/archive/V5.10.tar.gztar xvf V5.10.tar.gzcd fastdfs-5.10./make.sh./make.sh install
如果出现编译错误
fastdfs-5.10/storage/fdfs_storaged.c:130: undefined reference to `g_exe_name
请重新./make.sh clean后再次编译
配置跟踪服务器(tracker server)
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.confcp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
编辑tracker server配置文件tracker.conf
disabled=false
port=22122
base_path=/u01/data/fastdfs/tracker编辑client端的配置文件client.conf
base_path=/u01/data/fastdfs/tracker
tracker_server=192.168.2.138:22122创建tracker server数据目录
mkdir -p /u01/data/fastdfs/tracker启动tracker server
/etc/init.d/fdfs_trackerd start
tracker server自动在/u01/data/fastdfs/tracker目录新建data和logs目录
配置存储服务器(storage server)
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
编辑storage server配置文件storage.conf
disabled=false
port=23000
base_path=/u01/data/fastdfs/storage
tracker_server=192.168.25.100:22122
store_path0=/u01/data/fastdfs/storage
http.server_port=81创建storage server数据目录
mkdir -p /u01/data/fastdfs/storage启动storage server
/etc/init.d/fdfs_storaged start文件上传测试
[root@localhost conf.d]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf ./default.conf
group1/M00/00/00/wKgZZFxD2EqABE-RAAAFc0mlLyw60.conf
[root@localhost conf.d]#文件下载测试
[root@localhost conf.d]# /usr/bin/fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/wKgZZFxD2EqABE-RAAAFc0mlLyw60.conf
安装nginx
更新nginx安装库
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release- centos-7-0.el7.ngx.noarch.rpmwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum update
安装nginx
yum info nginx
yum install nginx
存储服务器(storage server)安装并配置nginx
1、安装fastdfs-nginx-module
fastdfs-nginx-module解决同组存储服务器之间文件复制不一致情况下,为客户端正确访问到文件提供支持。
wget http://nchc.dl.sourceforge.net/project/fastdfs/FastDFS Nginx Module Source Code/fastdfs-nginx-module_v1.16.tar.gz
注意:可能会下载不下来,建议直接复制链接下载后,再传到Linux上
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
cd fastdfs-nginx-module/src/
vi config
编辑config文件,执行如下命令进行批量替换并保存退出,修改/user/local为/user
:%s+/usr/local/+/usr/+g
2、拷贝fastdfs-nginx-module模块中配置文件到/etc/fdfs目录中并编辑
cp /u01/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
修改文件mod_fastdfs.conf
vi /etc/fdfs/mod_fastdfs.conf
connect_timeout=10
base_path=/tmp
tracker_server=192.168.2.138:22122
storage_server_port=23000
url_have_group_name = true
store_path0=/u01/data/fastdfs/storage
group_name=group1
#[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/u01/data/fastdfs/storage
3、nginx添加fastdfs-nginx-module模块
查看nginx版本
nginx -V
wget http://nginx.org/download/nginx-1.14.2.tar.gztar -zvxf nginx-1.12.1.tar.gzyum -y install pcreyum -y install openssl-devel
执行configure脚本
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-
path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx
/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp --http
-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-
temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=
/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/ngin
x/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio
--with-threads --with-http_addition_module --with-http_auth_request_
module --with-http_dav_module --with-http_flv_module --with-http_
gunzip_module --with-http_gzip_static_module --with-http_mp4_
module --with-http_random_index_module --with-http_realip_module--with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --add-module=/u01/fastdfs-nginx-module/src
最后一行:–add-module=/u01/fastdfs-nginx-module/src
make
make install
4、拷贝FastDFS中的部分配置文件到/etc/fdfs目录中
cp /u01/fastdfs/fastdfs-5.10/conf/http.conf /etc/fdfs/
cp /u01/fastdfs/fastdfs-5.10/conf/mime.types /etc/fdfs/
5、修改Nginx配置文件
vi /etc/nginx/conf.d/default.conf,
如果你安装的Nginx不存在conf.d目录,直接在nginx.conf中修改如下内容
添加如下内容:
server {listen 81;server_name localhost;location ~ /group1/M00 {root /u01/data/fastdfs/storage;ngx_fastdfs_module;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}
关闭防火墙并启动Nginx
systemctl stop firewalld.service
systemctl start firewalld.service通过Nginx代理下载文件
http://192.168.25.100:81/group1/M00/00/00/wKgZZFxD3VKABeg-AAAFc0mlLyw93.conf
Fdfs 配置分布式文件系统相关推荐
- 部署分布式文件系统(DFS)
部署分布式文件系统(DFS) 使用 DFS 命名空间,可以将位于不同服务器上的共享文件夹组合到一个或多个逻辑结构的命名空间.每个命名空间作为具有一系列子文件夹的单个共享文件夹显示给用户.但是,命名空间 ...
- dfs根目录_分布式文件系统DFS详细解读
使用分布式文件系统DFS可以轻松定位和管理网络中的共享资源.使用统一的命名路径完成对所需资源院的访问.提供可靠的负载平衡.与FRS(文件复制服务)联合在多台服务器之间提供冗余.与windows权限集成 ...
- 分布式文件系统及其部署
原文地址为: 分布式文件系统及其部署 DFS介绍 使用分布式文件系统可以轻松定位和管理网络中的共享资源.使用统一的命名路径完成对所需资源院的访问.提供可靠的负载平衡.与FRS(文件复制服务)联合在多台 ...
- 分布式文件系统(FastDFS)安装 配置
[TOC] 百度百科: FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储.文件同步.文件访问(文件上传.文件下载)等,解决了大容量存储和负载均衡的问题.特别适合以文 ...
- FastDFS分布式文件系统的安装及配置
由于网站使用nfs共享方式保存用户上传的图片,附件等资料,然后通过apache下载的方式供用户访问,在网站架构初期,使用这种简单的方式实现了静态资源的读写分离,但随着网站数据量的增加,图片服务器渐渐成 ...
- CentOS7下分布式文件系统FastDFS的安装 配置 (单节点)
背景 FastDFS是一个开源的轻量级分布式文件系统,为互联网量身定制,充分考虑了冗余备份.负载均衡.线性扩容等机制,并注重高可用.高性能等指标,解决了大容量存储和负载均衡的问题,特别适合以文件为载体 ...
- Win2003利用dfs(分布式文件系统)在负载均衡下的文件同步配置方案
2019独角兽企业重金招聘Python工程师标准>>> 因网站流量增加为了给网站减轻负担特需要文件同步与负载均衡,通过增加一台服务器,通过dfs配置实现文件的同步 1. 建议要同步的 ...
- 2003dfs分布式文件服务器,win2003分布式文件系统(dfs)配置方法[图文详解]
在网络中,共享文件的物理位置是分散分布的,用户要询问对方的共享路径才能清楚地获得共享资源.如果想看到某局域网全部的共享文件,则需要询问每一个人,这样的操作太不方便了. 根据管理员的需求,可以使用win ...
- dfs根目录_win2003分布式文件系统(dfs)配置方法[图文详解]
在网络中,共享文件的物理位置是分散分布的,用户要询问对方的共享路径才能清楚地获得共享资源.如果想看到某局域网全部的共享文件,则需要询问每一个人,这样的操作太不方便了. 根据管理员的需求,可以使用win ...
最新文章
- IntelliJ IDEA 重大更新:支持CPU火焰图,新增酷炫主题
- 我才是世界上最好的编程语言
- JSP数据库连接方式总结
- Java属性中指定Json的属性名称(序列化和反序列化)
- centos mysql_CentOS MySQL数据库备份工具mysqldump介绍
- websocket(二)--简单实现网页版群聊
- Android开发之Scroller
- av linux,linux下的开源clanav
- 使用C#进行图片转换格式,缩放,自动旋转,保留exif(转载)
- 延长计算机屏幕显示时间,设置Win7电源计划的方法介绍 延长续航时间
- 在原生js中的,table表格,display:block之后,样式混乱
- Win7 maven安装及配置
- HomeBrew太慢,如何替换默认HomeBrew源,使用阿里云的源
- 目录2. 计算机 13. 计算机智能 24. 软件 25. 操作系统 36. 互联网 37. 软件产业 38. 软件演示 49. 软件专利 410. 复杂性 411. 易用性
- Python 爬虫之代理服务器
- C#,字体多重阴影的绘制
- 新浪短连接(t.cn)在线生成工具
- 1414-二步侠PIPI(二分图应用)
- 修炼系列(八),你真的会写注释吗
- HDU_4379_The More The Better