一、配置tracker

目标:

FastDFS是一个分布式文件系统,主要的服务器角色有Tracker和Storage。本例安装一台Tracker,实现以下功能:

  • 接受客户端的访问
  • 检索存储节点,为客户端提供一台可用的storage

方案:

准备一台虚拟机,安装FastDFS Tracker。

主机的主机名及对应的IP地址如下表所示。

步骤:

1)配置yum源,并安装所需的软件包。

[root@fdfs_tracker1 ~]# yum install -y gcc libevent make
    [root@fdfs_tracker1 ~]# yum install -y libevent-devel-*.rpm

2)解压缩FastDFS安装包,查看安装说明文档进行安装。

[root@fdfs_tracker1 fdfs]# tar xzf FastDFS_v4.06.tar.gz
    [root@fdfs_tracker1 fdfs]# cd FastDFS
    [root@fdfs_tracker1 FastDFS]# vim INSTALL
    [root@fdfs_tracker1 fdfs]# ./make.sh
    [root@fdfs_tracker1 fdfs]# ./make.sh install
    [root@fdfs_tracker1 FastDFS]# vim INSTALL
    [root@fdfs_tracker1 FastDFS]# cp init.d/fdfs_trackerd /etc/init.d/

3)创建存储目录(存储日志等)。

[root@fdfs_tracker1 FastDFS]# mkdir -pv /data/fastdfs

4)修改配置文件。

[root@fdfs_tracker1 FastDFS]# vim /etc/fdfs/tracker.conf
    base_path=/data/fastdfs/     # 设置基础目录
    max_connections=4096         # 设置最大连接数
    store_group=group1           # 设置存储组名
    use_storage_id = true        # 使用stroage_id代替ip地址

5)创建storage_id文件。

[root@fdfs_tracker1 FastDFS]# cp conf/storage_ids.conf /etc/fdfs/

6)编辑storage id文件,加入存储组声明。

[root@fdfs_tracker1 FastDFS]# vim /etc/fdfs/storage_ids.conf
    100001   group1  192.168.113.60

7)修改客户端配置文件。

[root@fdfs_tracker1 FastDFS]# vim /etc/fdfs/client.conf
    base_path=/data/fastdfs
    tracker_server=192.168.113.50:22122

8)控制tracker启动。

[root@fdfs_tracker1 FastDFS]# /etc/init.d/fdfs_trackerd
    用法:/etc/init.d/fdfs_trackerd {start|stop|status|restart|condrestart}

9)查看tracker运行状态。

[root@fdfs_tracker1 FastDFS]# /etc/init.d/fdfs_trackerd status
    fdfs_trackerd (pid 28928) 正在运行...
    [root@fdfs_tracker1 FastDFS]# netstat -tlnp | grep tracker
    tcp  0    0   0.0.0.0:22122      0.0.0.0:*    LISTEN      28928/fdfs_trackerd

二、配置storage

目标:

安装FastDFS Storage存储节点,存储节点被划分到相应的组里。同一个组中的服务器保存完全相同的内容, 不同分组存不同的内容。存储节点具有以下功能:

  • 接受Tracker的调度
  • 响应客户端请求
  • 将客户端发来的文件存储至相应存储位置
  • 读取请求的文件,发送给客户端

方案:

准备一台虚拟机,安装FastDFS Tracker。

主机的主机名及对应的IP地址如下表所示。

步骤:

1)配置yum源,并安装所需的软件包。

[root@fdfs_storage1 ~]# yum install -y gcc libevent make
    [root@fdfs_storage1 ~]# yum install -y libevent-devel-*.rpm

2)解压缩、查看安装指南进行安装

[root@fdfs_storage1 fdfs]# tar xzf FastDFS_v4.06.tar.gz
    [root@fdfs_storage1 fdfs]# cd FastDFS
    [root@fdfs_storage1 FastDFS]# vim INSTALL
    [root@fdfs_storage1 fdfs]# ./make.sh
    [root@fdfs_storage1 fdfs]# ./make.sh install
    [root@fdfs_storage1 FastDFS]# vim INSTALL
    [root@fdfs_storage1 FastDFS]# cp init.d/fdfs_storaged /etc/init.d/

3)创建数据存储目录(存储日志、数据文件等)

[root@fdfs_storage1 FastDFS]# mkdir -pv /data/fastdfs

4)修改配置文件。

[root@fdfs_storage1 FastDFS]# vim /etc/fdfs/storage.conf
    base_path=/data/fastdfs/      # 设置基础工作目录
    max_connections=4096           # 设置最大连接数
    store_path0=/data/fastdfs/    # 设置上传文件目录
    tracker_server=192.168.113.50:22122    # 设置连接的Tracker
    upload_priority=10              # 设置组内服务器优先级

5)控制storage启动

[root@fdfs_storage1 FastDFS]# /etc/init.d/fdfs_storaged
    用法:/etc/init.d/fdfs_storaged {start|stop|status|restart|condrestart}

6)查看storage工作状态

[root@fdfs_storage1 FastDFS]# /etc/init.d/fdfs_storaged status
    fdfs_storaged (pid 28916) 正在运行...
    [root@fdfs_storage1 FastDFS]# netstat -tlnp | grep storage
    tcp        0      0 0.0.0.0:23000               0.0.0.0:*                   LISTEN      28916/fdfs_storaged

三、文件测试及web访问

目标:

为实现文件的上传、下载和删除等功能,FastDFS提供相应的命令行工具。测试这些工具的使用。

为了方便用户访问,可以在storage上配置web访问功能,使得文件通够通过web页面进行访问。

步骤:

步骤一:通过fdfs_test

1)上传文件

测试程序会对一个文件上传两次。返回的文件id也是两个并上传文件附加属性。storage上生成4个文件

[root@fdfs_tracker ~]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload install.log

查看上传到storage的文件

[root@fdfs_storage1 FastDFS]# ls /data/fastdfs/data/00/00/
    wKhxPFc3oD6ARewxAAC6OPZ7hp8271_big.log    wKhxPFc3oD6ARewxAAC6OPZ7hp8271.log
    wKhxPFc3oD6ARewxAAC6OPZ7hp8271_big.log-m  wKhxPFc3oD6ARewxAAC6OPZ7hp8271.log-m

2)删除文件

[root@fdfs_tracker1 fastdfs]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf\
     delete group1 M00/00/00/wKhxPFc3oD6ARewxAAC6OPZ7hp8271_big.log

步骤二:通过其他相关命令

1)通过fdfs_upload_file上传文件

[root@fdfs_tracker1 fastdfs]# /usr/local/bin/fdfs_upload_file\
     /etc/fdfs/client.conf /etc/passwd
    group1/M00/00/00/wKhxPFc3pEyAFrHBAAAGKI1fx1k5058918

2)通过fdfs_download_file下载文件

[root@fdfs_tracker1 ~]# /usr/local/bin/fdfs_download_file /etc/fdfs/client.conf\
     group1/M00/00/00/wKhxPFc3pEyAFrHBAAAGKI1fx1k5058918

3)通过fdfs_delete_file删除文件

[root@fdfs_tracker1 ~]# /usr/local/bin/fdfs_delete_file /etc/fdfs/client.conf\
     group1/M00/00/00/wKhxPFc3pEyAFrHBAAAGKI1fx1k5058918

步骤三:配置web访问

1)在storage上安装nginx

[root@fdfs_storage1 ~]# yum install -y pcre pcre-devel zlib zlib-devel
    [root@fdfs_storage1 fdfs]# tar xzf fastdfs-nginx-module_v1.16.tar.gz
    [root@fdfs_storage1 fdfs]# tar xzf nginx-1.7.10.tar.gz
    [root@fdfs_storage1 fdfs]# cd nginx-1.7.10
    [root@fdfs_storage1 nginx-1.7.10]# useradd -s /sbin/nologin nginx
    [root@fdfs_storage1 nginx-1.7.10]# ./configure --prefix=/usr/local/nginx \
    --user=nginx --group=nginx --add-module=../fastdfs-nginx-module/src/
    [root@fdfs_storage1 nginx-1.7.10]# make && make install

2)为nginx修改fastdfs模块配置

[root@fdfs_storage1 fdfs]# cp fastdfs-nginx-module/src/mod_fastdfs.conf \
    /etc/fdfs
    [root@fdfs_storage1 fdfs]# vim /etc/fdfs/mod_fastdfs.conf
    tracker_server=192.168.113.50:22122
    group_name=group1
    url_have_group_name = true
    store_path0=/data/fastdfs/

3)修改ngin配置文件并启动

[root@fdfs_storage1 fdfs]# vim /usr/local/nginx/conf/nginx.conf
    # location / {
    #    root   html;
    #    index  index.html index.htm;
    # }                                      将这段说明注释掉,增加以下说明
     location / {
                ngx_fastdfs_module;
            }
    [root@fdfs_storage1 fdfs]# /usr/local/nginx/sbin/nginx

4)测试web访问

[root@fdfs_tracker1 ~]# /usr/local/bin/fdfs_upload_file \
    /etc/fdfs/client.conf tedu.jpg
    group1/M00/00/00/wKhxPFc4f2yAVLH7AACwEV-ILDc194.jpg
    [root@fdfs_tracker1 ~]# firefox\
     http://192.168.113.60/group1/M00/00/00/wKhxPFc4f2yAVLH7AACwEV-ILDc194.jpg &

结果如下图所示

Cluster基础(五):配置tracker、配置storage、文件测试及web访问的更多相关文章

  1. Linux基础五:网络配置与管理

    五.网络配置与管理 1.网络知识 2.命令 ifconfig命令  <=>  ip  addr  show 命令--查看本地所有网卡配置信息 ens32:本地以太网网卡,lo:本地回环网卡 ...

  2. spring mvc: 可参数化的视图控制器(在配置中指定jsp文件)MultiActionController/SimpleUrlHandlerMapping/ParameterizableViewController

    spring mvc: 可参数化的视图控制器(在配置中指定jsp文件)MultiActionController/SimpleUrlHandlerMapping/ParameterizableView ...

  3. Expo大作战(五)--expo中app.json 文件的配置信息

    简要:本系列文章讲会对expo进行全面的介绍,本人从2017年6月份接触expo以来,对expo的研究断断续续,一路走来将近10个月,废话不多说,接下来你看到内容,讲全部来与官网 我猜去全部机翻+个人 ...

  4. Service系统服务(五):PXE基础装机环境、配置并验证DHCP服务、配置PXE引导、验证PXE网络装机、PXE+kickstart自动装机

    一.PXE基础装机环境 目标: 本例要求为后续的PXE服务器构建提供RHEL7软件仓库,完成下列任务: 1> 在CentOS真机部署Web目录/var/www/html/rh7dvd   2&g ...

  5. Spring Cloud Alibaba基础教程:Nacos配置的多文件加载与共享配置

    前情回顾: <Spring Cloud Alibaba基础教程:使用Nacos实现服务注册与发现> <Spring Cloud Alibaba基础教程:支持的几种服务消费方式> ...

  6. nginx应用总结(1)--基础认识和应用配置

    在linux系统下使用nginx作为web应用服务,用来提升网站访问速度的经验已五年多了,今天在此对nginx的使用做一简单总结. 一.nginx服务简介Nginx是一个高性能的HTTP和反向代理服务 ...

  7. nginx应用总结(1)-- 基础知识和应用配置梳理

    在linux系统下使用nginx作为web应用服务,用来提升网站访问速度的经验已五年多了,今天在此对nginx的使用做一简单总结. 一.nginx服务简介Nginx是一个高性能的HTTP和反向代理服务 ...

  8. 阿里云服务器Linux CentOS安装配置(五)jetty配置、部署

    阿里云服务器Linux CentOS安装配置(五)jetty配置.部署 1.官网下载jetty:wget http://repo1.maven.org/maven2/org/eclipse/jetty ...

  9. JAVA EE Hibernate基础一之环境配置

    对于JAVA开发高级,hibernate是java三大框架之一,足以见得它的重要性,那么对于hibernate的使用大家有了解多少呢?从今天开始我将带领大家一道共同探讨一下hibernate的知识,h ...

随机推荐

  1. MySQL使用命令导出/导入数据

    导出数据库文件 常用命令 mysqldump -uroot -pMyPassword databaseName tableName1 tableName2 > /home/foo.sql mys ...

  2. 【ABAP系列】SAP ABAP 关于ALV布局保存选项的讲解

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP ABAP 关于ALV布局保存 ...

  3. Web高级 JavaScript中的算法

    算法 排序算法 稳定排序 待排序序列中相等元素在排序完成后,原有先后顺序不变. 非稳定排序 有序度 待排序序列中有序关系的元素对个数. 逆序度 1. 插入排序 遍历有序数组,对比待插入的元素大小,找到 ...

  4. Apache solr 6.6.0安装

    Apache solr 6.6.0安装 最近使用了Apache solr搜索引擎框架,solr是基于lucene的一个搜索服务器,lucene也是Apache的一个开源项目:对于学习搜索引擎来说,这个 ...

  5. PyTorch笔记之 squeeze() 和 unsqueeze()

    1.squeeze() 函数 squeeze() 用来去掉向量的一个维度,只有维度为 1 的那一维才能去掉 example: 初始化1个向量shape为(1,2,3)的向量 import torch ...

  6. Developer Express 第三方控件使用系列方法

    本人目前从事的开发工作主要是以C#语言进行的相关C/S的开发,在工作中也要求使用Developer Express第三方控件所以这一系列的控件使用说明都将以C#语言进行代码说明.平时工作中会慢慢的收集 ...

  7. [Luogu 4688] [Ynoi2016]掉进兔子洞 (莫队+bitset)

    [Luogu 4688] [Ynoi2016]掉进兔子洞 (莫队+bitset) 题面 一个长为 n 的序列 a.有 m 个询问,每次询问三个区间,把三个区间中同时出现的数一个一个删掉,问最后三个区间 ...

  8. 靶形数独 (dfs+预处理+状态压缩)

    #2591. 「NOIP2009」靶形数独 [题目描述] 小城和小华都是热爱数学的好学生,最近,他们不约而同地迷上了数独游戏,好胜的他们想用数独来一比高低.但普通的数独对他们来说都过于简单了,于是他们 ...

  9. P3379 【模板】最近公共祖先(LCA)(欧拉序+rmq)

    P3379 [模板]最近公共祖先(LCA) 用欧拉序$+rmq$维护的$lca$可以做到$O(nlogn)$预处理,$O(1)$查询 从这里剻个图 #include<iostream> # ...

  10. 创建带标签页的MDI WinForms应用程序

    http://www.cnblogs.com/island/archive/2008/12/02/mditab.html 创建MDI应用程序 先创建”Windows窗体应用程序”解决方案Tabable ...