Linux中安装FastDFS轻量级分布式文件系统
先来介绍一下什么是FastDFS
FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。特别适合以文件为载体的在线服务,如相册网站、视频网站等等。
FastDFS为互联网量身定制,充分考虑了冗余备份、负载均衡、线性扩容等机制,并注重高可用、高性能等指标,使用FastDFS很容易搭建一套高性能的文件服务器集群提供文件上传、下载等服务。
1.选择操作环境
本文选用CentOS 7做测试
2.配置编译环境
1)安装FastDFS依赖环境。
yum install gcc-c++ -y
yum install pcre pcre-devel openssl ssl-devel perl-devel -y
2)安装FastDFS依赖包libfastcommon。
cd /usr/local/src
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.38.tar.gz
tar -zxvf V1.0.38.tar.gz
cd libfastcommon-1.0.38/
./make.sh
./make.sh install
3)安装FastDFS。
cd /usr/local/src
wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz
tar -zxvf V5.11.tar.gz
cd fastdfs-5.11/
./make.sh
./make.sh install
4)将配置文件复制到系统为fdfs预设的目录。
cd /usr/local/src/fastdfs-5.11/conf
cp mime.types http.conf /etc/fdfs/
5) 查看安装FastDFS过程中产生的可执行文件。
ls -la /usr/bin/fdfs*
显示类似如下内容表示安装成功。
-rwxr-xr-x 1 root root 381896 Jul 9 14:45 /usr/bin/fdfs_appender_test-rwxr-xr-x 1 root root 381680 Jul 9 14:45 /usr/bin/fdfs_appender_test1-rwxr-xr-x 1 root root 372592 Jul 9 14:45 /usr/bin/fdfs_append_file-rwxr-xr-x 1 root root 372392 Jul 9 14:45 /usr/bin/fdfs_crc32-rwxr-xr-x 1 root root 372624 Jul 9 14:45 /usr/bin/fdfs_delete_file-rwxr-xr-x 1 root root 373360 Jul 9 14:45 /usr/bin/fdfs_download_file-rwxr-xr-x 1 root root 372976 Jul 9 14:45 /usr/bin/fdfs_file_info-rwxr-xr-x 1 root root 382640 Jul 9 14:45 /usr/bin/fdfs_monitor-rwxr-xr-x 1 root root 1138424 Jul 9 14:45 /usr/bin/fdfs_storaged-rwxr-xr-x 1 root root 387728 Jul 9 14:45 /usr/bin/fdfs_test-rwxr-xr-x 1 root root 386984 Jul 9 14:45 /usr/bin/fdfs_test1-rwxr-xr-x 1 root root 520352 Jul 9 14:45 /usr/bin/fdfs_trackerd-rwxr-xr-x 1 root root 373584 Jul 9 14:45 /usr/bin/fdfs_upload_appender-rwxr-xr-x 1 root root 374616 Jul 9 14:45 /usr/bin/fdfs_upload_file
6)配置FastDFS。
分别对tracker,storage,client进行配置。
a.创建目录。
mkdir /home/fastdfs/tracker -pmkdir /home/fastdfs/storage -pcd /etc/fdfs/
b.配置tracker。
cp tracker.conf.sample tracker.confvim tracker.conf
将内容修改为“base_path=/home/fastdfs/tracker”和“thread_stack_size = 128KB”,如下面加粗部分所示:
# the base path to store data and log files
base_path=/home/fastdfs/tracker
......
# thread stack size, should >= 64KB
# default value is 64KB
thread_stack_size = 128KB
c. 启动tracker。
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
d. 配置storage。
cd /etc/fdfs/cp storage.conf.sample storage.confvim storage.conf
将内容修改为“base_path=/home/fastdfs/storage”、“store_path0=/home/fastdfs/storage”和“tracker_server=XX.XX.XX.XX:22122”。
“tracker_server”中的“XX.XX.XX.XX”为本机的虚拟IP地址,可以通过ifconfig命令查询获取。
修改后的内容,如下面加粗部分所示,其中“192.168.1.206”为示例,应根据实际虚拟IP地址填写。
# the base path to store data and log files
base_path=/home/fastdfs/storage
...
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
store_path0=/home/fastdfs/storage
#store_path1=/home/yuqing/fastdfs2
.....
# 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.1.206:22122
e. 启动storage。
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
f. 查看storage启动日志。
vim /home/fastdfs/storage/logs/storaged.log
查看最后几行,显示类似如下所示,表示启动成功。
[2019-07-09 17:03:51] INFO - file: tracker_client_thread.c, line: 310, successfully connect to tracker server 192.168.1.206:22122, as a tracker client, my ip is 192.168.1.206[2019-07-09 17:04:21] INFO - file: tracker_client_thread.c, line: 1263, tracker server 192.168.1.206:22122, set tracker leader: 192.168.1.206:22122
g.配置client。
cd /etc/fdfs/cp client.conf.sample client.confvi client.conf
将内容修改为“base_path=/home/fastdfs/tracker”和“tracker_server=XX.XX.XX.XX:22122”。
“tracker_server”中的“XX.XX.XX.XX”为本机的虚拟IP地址,可以通过ifconfig命令查询获取。
修改后的内容,如下面加粗部分所示,其中“192.168.1.206”为示例,应根据实际虚拟IP地址填写。
# the base path to store log files
base_path=/home/fastdfs/tracker
......
# 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.1.206:22122
7) 安装和配置fastdfs-nginx-module。
a. 安装fastdfs-nginx-module。
cd /usr/local/srcwget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gztar -zxvf V1.20.tar.gz
b.配置fastdfs-nginx-module的“config”文件。
cd /usr/local/src/fastdfs-nginx-module-1.20/src/vim config
按照如下加粗所示,修改“ngx_module_incs”和“CORE_INCS”。
ngx_addon_name=ngx_http_fastdfs_module
if test -n "${ngx_module_link}"; then
ngx_module_type=HTTP
ngx_module_name=$ngx_addon_name
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
ngx_module_libs="-lfastcommon -lfdfsclient"
ngx_module_srcs="$ngx_addon_dir/ngx_http_fastdfs_module.c"
ngx_module_deps=
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='/etc/fdfs/mod_fast
dfs.conf'"
. auto/module
else
HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -lfastcommon -lfdfsclient"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='/etc/fdfs/mod_fast
dfs.conf'"
fi
c. 配置fastdfs-nginx-module的“mod_fastdfs.conf”文件。
cp /usr/local/src/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf /etc/fdfs/vi /etc/fdfs/mod_fastdfs.conf
将内容修改为“base_path=/home/fastdfs”、“tracker_server=XX.XX.XX.XX:22122”、“url_have_group_name = true”和“store_path0=/home/fastdfs/storage”。
“tracker_server”中的“XX.XX.XX.XX”为本机的虚拟IP地址,可以通过ifconfig命令查询获取。
修改后的内容,如下面加粗部分所示,其中“192.168.1.206”为示例,应根据实际虚拟IP地址填写。
# the base path to store log files
base_path=/home/fastdfs
......
# FastDFS tracker_server can ocur more than once, and tracker_server format is
# "host:port", host can be hostname or ip address
# valid only when load_fdfs_parameters_from_tracker is true
tracker_server=192.168.1.206:22122
......
# if the url / uri including the group name
# set to false when uri like /M00/00/00/xxx
# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
# default value is false
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
# must same as storage.conf
store_path0=/home/fastdfs/storage
8) 安装和配置Nginx。
a.安装Nginx。
yum -y install make zlib-devel gcc-c++ libtool openssl openssl-devel./configure make && make installcd /usr/local/src/wget http://nginx.org/download/nginx-1.15.2.tar.gztar -zxvf nginx-1.15.2.tar.gzcd nginx-1.15.2./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/fastdfs-nginx-module-1.20/src/make &&make install
b. 配置Nginx。
cd /usr/local/nginx/conf/
vi nginx.conf
server {listen80;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location ~/M00{root /home/fastdfs/storage/data;ngx_fastdfs_module;}location / {root html;index index.html index.htm;}
3. 测试已完成编译的软件
1) 启动nginx
cd /usr/local/nginx/sbin/
./nginx
2)测试。
a.生成测试文件。
cd /usr/local/src
touch a.txt
vi a.txt
插入如下内容并保存。
kungpeng test fastdfs ok!
b.生成文件链接。
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf a.txt
回显信息如下:
[root@ecs-001 src]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf a.txt
group1/M00/00/00/wKgBzl0khdiAWJcGAAAAGmbRVtQ604.txt
记录返回的信息为“group1/FAST/00/00/wKgBzl0khdiAWJcGAAAAGmbRVtQ604.txt”。
c.放行CentOS系统的80端口,在浏览器中输入“http://[IP地址]:80/group1/M00/00/00/wKgBzl0khdiAWJcGAAAAGmbRVtQ604.txt”可以看到返回的“a.txt”相关信息。
参考此篇文章:什么是FastDFS_FastDFS如何配置-华为云 (huaweicloud.com)
Linux中安装FastDFS轻量级分布式文件系统相关推荐
- 轻量级分布式文件系统FastDFS使用安装说明手册(新手入门级)
轻量级分布式文件系统FastDFS使用安装说明手册(新手入门级) 实验室所在的课题组以研究云计算为主,但所有的研究都是在基于理论的凭空想像,缺少分布式环境的平台的实践,云计算神马的都是浮云了.因此,我 ...
- 实战:轻量级分布式文件系统FastDFS(GraphicsMagick图片压缩)
轻量级分布式文件系统FastDFS--实现用户头像上传/压缩屏幕适配 一.需求分析 1.1 业务场景: 用户上传的头像图片大小不一.手机和PC等设备显示尺寸也存在差异,因此需要能根据http请求指定的 ...
- ubuntu16.04下FastDFS+Nginx分布式文件系统
前言: 以前的项目上传的文件都是保存到本地或者是局域网内的共享文件夹下,由于数据量,服务器的负载均衡(分机的某些图片无法访问的问题处理)等因素的情况下,就想到用fastdfs来文件管理, FastDF ...
- Centos安装FastDFS集群文件系统
简介 FastDFS是一个开源的轻量级分布式文件系统.它解决了大数据量存储和负载均衡等问题.特别适合以中小文件(建议范围:4KB < file_size <500MB)为载体的在线服务,如 ...
- ubuntu16.04+fastdfs+nginx分布式文件系统
FastDFS简介 FastDFS是一个由C语言实现的开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储,文件同步,文件访问(文件上传,下载)等:解决了大容量存储和负载均衡的问题.特别适 ...
- 1 CentOS 6下FastDFS实现分布式文件系统
FastDFS FastDFS是用c语言编写的一款开源的分布式文件系统.FastDFS为互联网量身定制,充分考虑了冗余备份.负载均衡.线性扩容等机制,并注重高可用.高性能等指标,使用FastDFS很容 ...
- FastDFS(分布式文件系统)使用介绍
FastDFS(分布式文件系统)使用介绍 一.基本介绍 1.FastDFS 的特性 2.FastDFS 的存储策略 二.使用 FastDFS 实现分布式文件存储 1.安装 FastDFS 软件 2.验 ...
- ubuntu 安装yum_如何在 Linux 中安装微软的 .NET Core SDK | Linux 中国
本分步操作指南文章解释了如何在 Linux 中安装 .NET Core SDK 以及如何使用 .NET 开发出第一个应用程序.-- Sk致谢译自 | ostechnix.com 作者 | Sk译者 | ...
- hive安装需要安装mysql区别_HIVE安装系列之一:在Linux中安装mysql,为其作为hive的metastore做准备...
安装mysql的Linux机器是Centos6的系统,机器名字叫combanc05 mysql我采用的是5.5版本. 安装过程中需要解决新旧版的冲突问题,并允许mysql被远程访问.以便其作为hive ...
最新文章
- arrays中copyof复制两个数组_数组,及二维数组
- 【重磅】央行发大招!最全面的支付安全风险大检查来了……
- mac要装anaconda吗_Anaconda安装教程|Windows,Linux ,Mac OS
- open source project for recommendation system
- Android 绑定远程服务出现 Not Allowed to bind service
- DOM 精通了?请问 Node 和 Element 有何区别?
- 【计算机网络笔记】计算机网络五层体系结构
- 成功解决1406, “Data too long for column ‘txt‘ at row 1“
- Hive入门学习随笔(一)
- 我们眼中的资管管理行业三要素
- MFC入门之二MFC基于对话框学习控件二
- OpenCms显示默认作者
- 关于word2010指定位置插入页码及三线表格绘制问题
- 雷电模拟器一直android正在启动,雷电安卓模拟器启动后没反应、无法启动、闪退的3种解决办法-针对2020年4月4号出现的...
- 微信哪个电话能转人工服务器,微信人工客服电话多少?微信客服怎么打转人工(这份教程收好了)...
- Laravel + Elasticsearch 实现中文搜索
- 甲方和大厂外包,哪个更好?这是最醍醐灌顶的回答
- java单书号表示什么_单书号和双书号有何区别?
- 搭建LDAP服务器详细流程
- Direct3D9 教程01
热门文章
- 局域网即时通信软件都有哪些?要如何选择?
- 匹配文件后缀名的正则表达式
- Atom编辑器活跃用户突破一百万
- 千亿级包点市场,沙田包子如何靠“冷冻生胚技术”打天下?
- 02 - 汽车功能安全系列之概念阶段开发 - Item Definition HARA
- ACREL-5000能耗监测及ACREL-2000电力监控系统的研究与应用
- windows下php的版本如何选择?
- MapperScan扫描多个包写法
- MYSQL索引使用技巧及注意事项
- 完美安装BatteryHistorian-Note: Could not parse aggregated battery stats.