1,安装libevent
-
wget https:
-
将其拷贝到 /usr/local/lib下
-
tar xvzf libevent-
2.0
.
20
-stable.tar.gz
-
./configure
-
make
-
make install
-
-
测试libevent是否安装成功
ls -al /usr/lib | grep libevent
出来一大列东西,就说明安装成功了。
-
如果libevent的安装目录为/usr/local/lib下,则还需要建立
libevent-
2.0
.so.
5
到
/usr/lib 的软连接,这样其他程序运行时才能找到libevent库:
-
ln -s /usr/local/lib/libevent-
2.0
.so.
5
/usr/lib/libevent-
2.0
.so.
5
-
否则会出现
./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
-
wget http:
-
将其拷贝到/usr/local下
-
tar xvzf FastDFS_v3.
11
.tar.gz
-
-
修改 make.sh
-
#WITH_HTTPD=1 --> WITH_HTTPD =1
-
-
./make.sh
-
./make.sh install
3,启动FastDFS-->tracker
创建目录/opt/fastdfs
[root
@ www.linuxidc.com
~]# mkdir /opt/fastdfs
修改tracker.conf配置
-
[root
@ www.linuxidc.com
~]# vim /etc/fdfs/tracker.conf
-
base_path=/home/yuqing/fastdfs -> base_path=/opt/fastdfs
-
#
改成你想要的
http
端口,将来
http
下载文件的端口就是它了。
http.server_port=8080
->
http.server_port=8090
-
#http
支持
##include http.conf
->
#include
http.conf
-
#
默认
4GB
,如果空间不足,建议调小,否则会报
no
free space
的异常,无法正常启动。
reserved_storage_space = 4GB
->
reserved_storage_space = 1GB
-
#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配置
-
[root
@ www.linuxidc.com
~]# vim /etc/fdfs/storage.conf
-
base_path=/home/yuqing/fastdfs --> /opt/fastdfs
-
store_path0=/home/yuqing/fastdfs --> store_path0=/opt/fastdfs
-
group_name=group1
-
tracker_server=
192.168
.
209.121
:
22122
--> tracker_server=
192.168.217.130
:
22122
-
##include http.conf --> #include http.conf
启动storage
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
5,上传测试
修改client.conf
-
[root
@ www.linuxidc.com
~]# vim /etc/fdfs/client.conf
-
vi /etc/fdfs/client.conf
-
base_path=/home/yuqing/fastdfs-> base_path=/opt/fastdfs
-
tracker_server=
192.168
.
209.121
:
22122
-> tracker_server=
192.168.217.130
:
22122
-
##include http.conf ->#include http.conf
-
[root
@ www.linuxidc.com
~]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload FastDFS_v3.
03
.tar.gz //假设当前目录下有
FastDFS_v3.
03
.tar.gz 这个文件,并且上传他 如果没有问题,出现下面一大陀文字
-
This is FastDFS client test program v3.
11
-
-
Copyright (C)
2008
, Happy Fish / YuQing
-
-
FastDFS may be copied only under the terms of the GNU General
-
Public License V3, which may be found in the FastDFS source kit.
-
Please visit the FastDFS Home Page http:
-
for
more detail.
-
-
[
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
-
-
tracker_query_storage_store_list_without_group:
-
server
1
. group_name=group1, ip_addr=
192.168
.
0.11
, port=
23000
-
-
group_name=group1, ip_addr=
192.168
.
0.11
, port=
23000
-
storage_upload_by_filename
-
group_name=group1, remote_filename=M00/
00
/
00
/CAAAC1BQPQqy0zXVAAWp7X_1XGc.tar.gz
-
source ip address:
192.168
.
0.11
-
file timestamp=
2012
-
09
-
12
15
:
43
:
06
-
file size=
371181
-
file crc32=
2146786407
-
file url: http:
-
storage_upload_slave_by_filename
-
group_name=group1, remote_filename=M00/
00
/
00
/CAAAC1BQPQqy0zXVAAWp7X_1XGc_big.tar.gz
-
source ip address:
8.0
.
0.11
-
file timestamp=
2012
-
09
-
12
15
:
43
:
06
-
file size=
371181
-
file crc32=
2146786407
-
file url: http:
6,
下载文件
在浏览器中,输入
http:
,
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();
}
}
分享到:
相关推荐
CentOS 6.2系统镜像有两个,安装系统只用到第一个镜像,第二个镜像是系统自带软件安装包。 安装CentOS 6.2系统的计算机内存必须等于或者大于628M(最小内存628M),才能启用图形安装模式。 CentOS 6.2文本...
CentOS6.2下配置Django+Python环境步骤
CentOS7离线安装fastdfs包,配合博客步骤使用
NULL 博文链接:https://itsaga.iteye.com/blog/2286554
centos系统上安装fastdfs
CentOS 6.2安装(超级详细图解教程)
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安装手册,用于宇视相关软件部署、开局所用。
在VMware中安装linux流程 CentOS 6.2安装教程
CentOS6.2安装(超级详细图解教程)
CentOS_6.2安装(超级详细图解教程
Linux(CentOS6.2)下安装SVN服务
centos6.2-64下安装oracle11G
centos 6.2安装sybase--步骤简单明了实用,详见文档
CentOS 6.2 Linux 安装截图详解
CentOS6.2硬盘安装指南
这是CentOS6.2下openldap安装配置详细文档
CentOS 6.2 rpm 方式安装 MySQL 的文档,简单实用!
自己整理的fastDFS安装文档,可能存在不完整的地方,需结合自己实际状况做调整
CentOS 6.2编译安装LAMP最详细教程!