调用fastdfsapi是同步的还是异步的

调用fastdfsapi是同步的还是异步的,第1张

FastDFS API 是同步的。在调用 FastDFS API 时,程序会一直等待 API 返回结果,直到得到预期的结果或者超时才会结束。这是由于 FastDFS 设计的特点决定的,它的设计目标是提供高性能、高可用性的分布式文件系统,而同步的 API 能够更帆薯伍好地保证数据的一致性和可靠性。在同步的 API 中,用户可以明确地知道何时得到了上传、下载文件的结果,便于进行后续 *** 作。然而,同步的 API 在处理大量数据时可能会导致阻塞,因此在需要手高高并发和高吞吐量的应用场景中,需要根据实际情况选择态或适合的异步 API 或者使用多线程等技术来提高系统性能。

Google了一下,流行的开源分布式文件系统有很多,介绍如下:

mogileFS:Key-Value型元文件系统,不支持FUSE,应用程序访问它时需要API,主要用在web领域处理海量小图片,效率相比mooseFS高很多。

fastDFS:国人在mogileFS的基础上进行改进的key-value型文件系统,同样不支持FUSE,提供比mogileFS更好的性能。

mooseFS:支持FUSE,相对比较轻量级,对master服务器有单点依赖,用perl编写,性能相对较差,国内用的人比较多

glusterFS:支持FUSE,比mooseFS庞大

ceph:支持FUSE,唯差客户端已经进入了linux-2.6.34内核,也就是说可以像ext3/rasierFS一样,选择ceph为文件系统。彻底的分布式,没有单点依赖,用C编写,性能较好。基于不成熟的btrfs,其本身也非常不成熟。

lustre:Oracle公司的企业级产品,非常庞大,对内核和ext3深度依赖

NFS:老牌网络文件系统,具体不了解,反正NFS最近几年没发展,肯定不能用。

鉴于fastDFS是国人开发,也有国内的一些大公司在使用,so…

普通的文件架构其实一两年内也是没有问题的,但有句话叫未雨绸缪,于是决定折腾折腾。

源码下载:http://code.google.com/p/fastdfs

寻求帮助:http://www.csource.org

一、安装libevent

fastDFS需要安装libevent比较新的版本,将本机的比较低的版本卸载了。

rpm -qa libevent

libevent-1.4.13-1.el6.x86_64

rpm -e --nodeps libevent

安装一个最新稳定版

wget https://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz

tar zxvf libevent-2.0.18-stable.tar.gz

cd libevent-2.0.18-stable

./configure

make &&make install

为libevent创建软链接到/lib库下,64位系统对应/lib64

ln -s /usr/local/lib/libevent* /lib/

ln -s /usr/local/lib/libevent* /lib64/

二、安装FastDFS

wget http://fastdfs.googlecode.com/files/FastDFS_v3.06.tar.gz

tar zxvf FastDFS_v3.06.tar.gz

cd FastDFS

./make.sh

./make.sh install

三、配置FastDFS

环境:

tracker server

192.168.1.5

storage server

192.168.1.51

192.168.1.52

1、配置并启动 tracker server

①配置薯没 tracker.conf

mkdir /data/fastdfs

vim /etc/fdfs/tracker.conf

base_path=/data/fastdfs

②启动 tracker

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

③开机启动

vim /etc/rc.local

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

2、配置并启动 storage server

①配置 tracker.conf

mkdir /data/fastdfs

mkdir /data/images

vim /etc/fdfs/storage.conf

base_path=/data/fastdfs

store_path0=/data/images

tracker_server=192.168.1.5:22122

②启动 tracker

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

③开机启动

vim /etc/数山纳rc.local

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

3、为storage节点安装fastdfs-nginx-module模块

①安装模块

安装Nginx详见:

需重新编译Nginx

wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.10.tar.gz

tar zxvf fastdfs-nginx-module_v1.10.tar.gz

wget http://nginx.org/download/nginx-1.2.0.tar.gz

tar zxvf nginx-1.2.0.tar.gz

cd nginx-1.2.0

./configure --prefix=/usr/local/nginx --add-module=../fastdfs-nginx-module/src

make &&make install

cd ..

②配置

编辑nginx.conf

vim /usr/local/nginx/conf/nginx.conf

server {

listen 80

server_name localhost

location /M00 {

alias /data/images/data

ngx_fastdfs_module

}

......

}

给 storage 的存储目录做一个软连接

ln -s /data/images/data/ /data/images/data/M00

拷贝mod_fastdfs.conf 到 /etc/fdfs/

cp fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

vim /etc/fdfs/mod_fastdfs.conf

base_path=/data/fastdfs

tracker_server=192.168.1.5:22122

store_path0=/data/images

启动nginx

/usr/local/nginx/sbin/nginx

四、使用FastDFS

1、上传文件

FastDFS安装包中,自带了客户端程序,通过程序可以进行文件上传。在使用这个客户端程序之前,首先需要配置client.conf,然后再进行文件上传及下载。

在tracker上修改客户端配置文件client.conf

vim /etc/fdfs/client.conf

base_path=/data/fastdfs

tracker_server=192.168.1.5:22122

vim a.html

This Is FastDFS Test.

上传文件

/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload a.html

This is FastDFS client test program v3.06

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://www.csource.org/

for more detail.

[2012-04-29 12:42:53] INFO - base_path=/data/tracker, 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.1.51, port=23000

server 2. group_name=group1, ip_addr=192.168.1.52, port=23000

group_name=group1, ip_addr=192.168.1.51, port=23000

storage_upload_by_filename

group_name=group1, remote_filename=M00/00/00/wKgBM0-cxs32qFyYAAAADigvbpc90.html

source ip address: 192.168.1.51

file timestamp=2012-04-29 12:42:53

file size=14

file crc32=674197143

file url: http://192.168.1.5/group1/M00/00/00/wKgBM0-cxs32qFyYAAAADigvbpc90.html

storage_upload_slave_by_filename

group_name=group1, remote_filename=M00/00/00/wKgBM0-cxs32qFyYAAAADigvbpc90_big.html

source ip address: 192.168.1.51

file timestamp=2012-04-29 12:42:53

file size=14

file crc32=674197143

file url: http://192.168.1.5/group1/M00/00/00/wKgBM0-cxs32qFyYAAAADigvbpc90_big.html

上传成功

试试用

http://192.168.1.51/M00/00/00/wKgBM0-cxs32qFyYAAAADigvbpc90_big.html

访问看看吧。

看了几天了,还是有些地方不是很明白,暂时搁置,不能再浪费时间了。

不可以。

1、fastdfs最新版本5.05,还没有在windows系统下安装的fastdfs。

2、当然windows虽然不能安装fastdfs服务器软件,但在windows中可以使用C#等接口访问Linux下的fastdfs。

3、windows server 2008自带DFS,类似fastdfs,也是一种分布式文件系统,可以与Linux共同承担DFS服务器的作用,是不得不在windows使用DFS的一个选择。

对计算机软誉棚腔件的维护主要和脊有以下几点:

(1)对所有的系统软件要做备份。当遇到异常情况或某种偶然原因,可能会破坏系统软件,此时就需要重新安装软件系统,如果没有备份的系统软件,将使计算机难以恢复工作。

(2)对重要的应用程序和数据也应该做备份。

(3)经常注意清理磁盘上无用的文件,以有效地利用磁盘空间。

(4)避免进行非法的软件复制。

(5)经常检测,防止计算机传染上病毒。

(6)为保证计算机正常工作,在必要时利用软件工具对系统区进行保护。

总之,计算机的使用是与维护分不开的庆衫,既要注意硬件的维护,又要注意软件的维护。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8277896.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-14
下一篇2023-04-14

发表评论

登录后才能评论

评论列表(0条)

    保存