`
ckwang17
  • 浏览: 26260 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

CentOS 6.2 下安装FastDFS

 
阅读更多

1,安装libevent

  1. wget https: //github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz  
  2. 将其拷贝到 /usr/local/lib下
  3. tar xvzf libevent- 2.0 . 20 -stable.tar.gz   
  4. ./configure   
  5. make   
  6. make install   
  7.  
  8. 测试libevent是否安装成功
    ls -al /usr/lib | grep libevent
    出来一大列东西,就说明安装成功了。

  9. 如果libevent的安装目录为/usr/local/lib下,则还需要建立 libevent- 2.0 .so. 5 到 /usr/lib 的软连接,这样其他程序运行时才能找到libevent库:
  10. ln -s /usr/local/lib/libevent- 2.0 .so. 5  /usr/lib/libevent- 2.0 .so. 5  
  11. 否则会出现
    ./tracker/fdfs_trackerd: error while loading shared libraries: 
    libevent-2.0.so.5: cannot open shared object file: No such file or directory)


2,安装FastDFS

  1. wget http: //fastdfs.googlecode.com/files/FastDFS_v3.11.tar.gz  
  2. 将其拷贝到/usr/local下
  3. tar xvzf FastDFS_v3. 11 .tar.gz   
  4.   
  5. 修改 make.sh   
  6. #WITH_HTTPD=1 --> WITH_HTTPD   =1
  7.   
  8. ./make.sh   
  9. ./make.sh install  


3,启动FastDFS-->tracker

创建目录/opt/fastdfs

[root @ www.linuxidc.com  ~]# mkdir /opt/fastdfs  

修改tracker.conf配置

  1. [root @ www.linuxidc.com  ~]# vim /etc/fdfs/tracker.conf   
  2. base_path=/home/yuqing/fastdfs -> base_path=/opt/fastdfs   
  3. # 改成你想要的 http 端口,将来 http 下载文件的端口就是它了。

    http.server_port=8080  ->  http.server_port=8090

     

  4. #http 支持

    ##include http.conf  ->  #include http.conf

     

  5. # 默认 4GB ,如果空间不足,建议调小,否则会报 no free space 的异常,无法正常启动。

    reserved_storage_space = 4GB -> reserved_storage_space = 1GB

     

  6. #tracker server storage server 供服务的端口,使用默认的即可,也可以自定义

    port=22122  

启动tracker

/usr/local/bin/fdfs_trackerd  /etc/fdfs/tracker.conf 

进入/opt/fastdfs/ fastdfs_tracker/logs/trackerd.log 查看 tracker 的启动日志, 恭喜你, tracker server 已经启动成功!


重启

/usr/local/bin/restart.sh  /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf


关闭

/usr/local/bin/stop.sh /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf


4,启动FastDFS-->storage

创建目录/opt/fastdfs

[root@ www.linuxidc.com ~]# mkdir /opt/fastdfs 

修改storage.conf配置

  1. [root @ www.linuxidc.com  ~]# vim /etc/fdfs/storage.conf   
  2. base_path=/home/yuqing/fastdfs --> /opt/fastdfs   
  3. store_path0=/home/yuqing/fastdfs --> store_path0=/opt/fastdfs   
  4. group_name=group1   
  5. tracker_server= 192.168 . 209.121 : 22122  --> tracker_server= 192.168.217.130 : 22122   
  6. ##include http.conf --> #include http.conf  

启动storage

/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

5,上传测试

 

修改client.conf

  1. [root @ www.linuxidc.com  ~]# vim /etc/fdfs/client.conf   
  2. vi /etc/fdfs/client.conf   
  3. base_path=/home/yuqing/fastdfs-> base_path=/opt/fastdfs   
  4. tracker_server= 192.168 . 209.121 : 22122  -> tracker_server= 192.168.217.130 : 22122   
  5. ##include http.conf ->#include http.conf 
  1. [root @ www.linuxidc.com  ~]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload FastDFS_v3. 03 .tar.gz               //假设当前目录下有 FastDFS_v3. 03 .tar.gz 这个文件,并且上传他   如果没有问题,出现下面一大陀文字
  2. This is FastDFS client test program v3. 11   
  3.   
  4. Copyright (C)  2008 , Happy Fish / YuQing   
  5.   
  6. FastDFS may be copied only under the terms of the GNU General   
  7. Public License V3, which may be found in the FastDFS source kit.   
  8. Please visit the FastDFS Home Page http: //www.csource.org/    
  9. for  more detail.   
  10.   
  11. [ 2012 - 09 - 12   15 : 43 : 03 ] DEBUG - base_path=/opt/fastdfs, connect_timeout= 30 , network_timeout= 60 , tracker_server_count= 1 , anti_steal_token= 0 , anti_steal_secret_key length= 0   
  12.   
  13. tracker_query_storage_store_list_without_group:    
  14.         server  1 . group_name=group1, ip_addr= 192.168 . 0.11 , port= 23000   
  15.   
  16. group_name=group1, ip_addr= 192.168 . 0.11 , port= 23000   
  17. storage_upload_by_filename   
  18. group_name=group1, remote_filename=M00/ 00 / 00 /CAAAC1BQPQqy0zXVAAWp7X_1XGc.tar.gz   
  19. source ip address:  192.168 . 0.11   
  20. file timestamp= 2012 - 09 - 12   15 : 43 : 06   
  21. file size= 371181   
  22. file crc32= 2146786407   
  23. file url: http: //192.168.0.10:8080/group1/M00/00/00/CAAAC1BQPQqy0zXVAAWp7X_1XGc.tar.gz   
  24. storage_upload_slave_by_filename   
  25. group_name=group1, remote_filename=M00/ 00 / 00 /CAAAC1BQPQqy0zXVAAWp7X_1XGc_big.tar.gz   
  26. source ip address:  8.0 . 0.11   
  27. file timestamp= 2012 - 09 - 12   15 : 43 : 06   
  28. file size= 371181   
  29. file crc32= 2146786407   
  30. file url: http: //192.168.0.10:8080/group1/M00/00/00/CAAAC1BQPQqy0zXVAAWp7X_1XGc_big.tar.gz  

6, 下载文件

在浏览器中,输入 http: //192.168.0.10:8080/group1/M00/00/00/CAAAC1BQPQqy0zXVAAWp7X_1XGc_big.tar.gz    tracker server 会自动重定向到存储文件的 storage server ,文件下载成功。至此,已经成功搭建了 FastDFS ,编写你自己的 client 来进行访问吧;

7,监视器

# fdfs_monitor /etc/fdfs/storage.conf

 

 

测试代码

package com.test;
import java.net.InetSocketAddress;

import org.csource.common.NameValuePair;
import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient;
import org.csource.fastdfs.StorageServer;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerGroup;
import org.csource.fastdfs.TrackerServer;
public class JavaClient {
	public JavaClient(){}
	
	public static void doTest(){
		
		try
		{
			String local_file_name ="/Users/ckwang17/Desktop/DCIM/100NCD90/DSC_0003.JPG";
			String conf_filename = "/Users/ckwang17/Student/workspace/fastdfs/src/com/test/fdfs_client.conf";
			NameValuePair []pair = {new  NameValuePair("1111","222")};
			
			ClientGlobal.init(conf_filename);
			TrackerGroup group = new TrackerGroup(
					new InetSocketAddress[]{
						new InetSocketAddress("192.168.217.130",22122)
						});
			TrackerClient client = new TrackerClient(group);
			TrackerServer ts = client.getConnection();
			
			StorageServer storage = client.getStoreStorage(ts);
			//System.out.println(storage.getSocket().);
			
			StorageClient s_client = new StorageClient(ts,storage);
			
			String url [] = s_client.upload_file(local_file_name, "jpg", pair);
			
			storage.close();
			for (int i = 0; i < url.length; i++) {
				System.out.println(url[i]);
				s_client.download_file(url[0], url[1], "/Users/ckwang17/Student/workspace/fastdfs/11.jpg");
			}
			
		}catch(Exception io){
			io.printStackTrace();
		}
		
	}
	public static void main(String[] args)throws Exception {
		doTest();
	}
}
 
分享到:
评论
1 楼 stevendu 2014-02-27  
系统是CentOS release 6.2 64位
libevent: libevent-2.0.21-stable
FastDFD: FastDFS_v4.06

2个Tracker,3个Storage,自打安装部署完成后,报错:
Storage服务:
DEBUG - file: tracker_proto.c, line: 48, server: 10.9.10.60:22122, response status 2 != 0


Tracker服务:
[2014-02-27 15:07:23] DEBUG - file: tracker_mem.c, line: 4650, storage server group1::10.9.10.61 join in, remain changelog bytes: 0
[2014-02-27 15:07:23] DEBUG - file: tracker_mem.c, line: 5347, storage server group1::10.9.10.61 offline


您知道如何解决吗?

相关推荐

    制作U盘安装CentOS 6.2

    制作U盘安装CentOS 6.2是一个常见的系统部署任务,尤其对于IT专业人士而言,了解这一过程至关重要。这里我们将深入探讨如何使用给定的文件来完成这个任务。 首先,我们需要两个关键工具,从提供的文件列表中可以...

    CentOS 6.2安装(超级详细图解教程)

    CentOS 6.2 安装超详细图解教程 CentOS 6.2 安装是许多 Linux 初学者和服务器管理员需要掌握的基本技能之一。本资源提供了超详细的图解教程,指导用户从下载 CentOS 6.2 镜像文件到安装完成整个过程。通过这个教程...

    CentOS6.2下配置Django+Python环境步骤

    在CentOS 6.2系统下配置Django与Python环境是一项关键任务,尤其对于那些希望在稳定的企业级Linux操作系统上部署动态网站或Web应用的开发者而言。以下将详细阐述整个配置流程,涵盖从安装必要的软件包到最终启动...

    centos6.2安装(详细图解安装).doc

    centos6.2安装 CentOS 6.2安装 实验环境:VMware 6.5.2 安装镜像:CentOS-6.2-i386-bin-DVD1.iso CentOS-6.2镜像共两张DVD1和DVD2,安装操作系统只用DVD1即可 镜像下载地址: 32位DVD1...

    centos6.2安装手册

    centos6.2安装手册,用于宇视相关软件部署、开局所用。

    centos系统上安装fastdfs

    安装日志中会提示 FastDFS 安装到了 /etc/fdfs 目录下。 配置 FastDFS 需要将三个示例文件复制一份,去掉.sample:cp client.conf.sample client.conf、cp storage.conf.sample storage.conf、cp tracker.conf....

    CentOS7离线安装fastdfs包

    本篇文章将详细介绍如何在CentOS7上进行离线安装FastDFS的过程,以及配合博客步骤来实现这一目标。 首先,我们需要获取FastDFS的安装包。通常,我们可以从FastDFS的官方网站或者其他可信源下载最新的源码包,比如`...

    CentOS6.5下安装fastDFS

    ### CentOS 6.5 下安装 FastDFS #### 一、前言 FastDFS 是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储、文件同步、文件访问(文件上传、文件下载等),解决了大容量存储和负载均衡的...

    CentOS6.2硬盘安装指南

    ### CentOS6.2硬盘安装全解析 #### 一、下载CentOS6.2镜像文件 在准备硬盘安装CentOS6.2之前,首要任务是从官方或其他可信赖的渠道下载正确的ISO镜像文件。根据需求,可以选择不同类型的镜像: 1. **CentOS-6.2-...

    centos6.2下安装sybase--详细操作步骤.doc

    在CentOS 6.2操作系统环境下安装Sybase是一项重要的任务,尤其对于那些依赖于Sybase数据库系统的用户。本文将详细阐述在CentOS 6.2上安装Sybase的步骤,确保您能够顺利进行。 首先,我们需要创建一个专门用于运行...

    centos6.2-64下安装oracle11G

    在CentOS 6.2 64位操作系统中安装Oracle 11g涉及多个关键步骤,包括系统和配置要求、软件环境准备、用户环境设置以及后续的安装过程。以下是详细的知识点说明: 1. **系统及配置要求**: - 操作系统版本:CentOS ...

    Centos 6.2下安装Sybase ASE-15_0

    安装过程中,你需要按照"centos6.2下安装sybase--详细操作步骤.doc"中的指导进行。这通常包括解压安装文件,运行配置脚本,配置数据库实例,指定实例的端口、日志路径和数据文件位置。在配置过程中,确保遵循Sybase...

    CentOS6.2 NTP时间服务器搭建

    在 CentOS 6.2 操作系统上,NTP 服务器是系统自带的,不需要安装任何软件包。只需要配置 NTP 服务器的配置文件 `/etc/ntp.conf`,并添加 restrict 语句来限制访问权限。 ``` #vim /etc/ntp.conf restrict 220.130....

    CentOS 6.2 RPM 安装 MySQL

    CentOS 6.2 rpm 方式安装 MySQL 的文档,简单实用!

    CentOS 6.2编译安装LAMP最详细教程!

    CentOS 6.2编译安装LAMP最详细教程!

Global site tag (gtag.js) - Google Analytics