免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: happy_fish100
打印 上一主题 下一主题

FastDFS-开源分布式文件系统 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2008-07-23 13:04 |只看该作者
LZ,  正在研究你的软件。。
其中你的文档中提出:


<b>上传文件交互过程:
1. client询问tracker上传到的storage,不需要附加参数;
2. tracker返回一台可用的storage;
3. client直接和storage通讯完成文件上传。</b>

那么客户端要装软件吗?
如果是安装软件,感觉上不太使用了,
那么如果不需要安装,如果我要做 RR 轮叫写入的时候,是否还需要先问一下要写入到那个 SERVER 呢?

感觉上文档还是没有没有搞明白。。

论坛徽章:
4
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:11IT运维版块每日发帖之星
日期:2016-08-11 06:20:00IT运维版块每日发帖之星
日期:2016-08-15 06:20:00
12 [报告]
发表于 2008-07-23 13:12 |只看该作者
是这样的,使用FastDFS可以构建服务器存储集群,和FastDFS通信的client也应该是server,即:server对server的调用。FastDFS提供了client library,目前只有C语言版本的。

>>那么如果不需要安装,如果我要做 RR 轮叫写入的时候,是否还需要先问一下要写入到那个 SERVER 呢?
因为client不需要关心存储服务器都有哪些及它们的组织方式是怎么样的,只需要询问tracker server即可。

论坛徽章:
0
13 [报告]
发表于 2008-07-23 13:17 |只看该作者
hehe.. 感谢。

现在在测试中。。

架构

希望达到这样的效果
[server1] 数据存储实时备份 <----------------------> [server2] 数据存储同步并进行售票


[server2] 1.1.1.12 (传说中的售票员)
                         tracker.conf

disabled=false
bind_addr=1.1.1.12      [自己 IP 地址。。。留意]
port=22122
network_timeout=20
base_path=/dbtest
max_connections=1024

#0: round robin
#1: specify group
#2: load balance
store_lookup=2

#when store_lookup set to 1, must set store_group to the group name
store_group=group1   对应一下

#reserved storage space for system or other applications.
#if the free(available) space of any stoarge server in a group <= reserved_storage_space,
#no file can be uploaded to this group.
#bytes unit can be one of follows:
### G or g for gigabyte(GB)
### M or m for megabyte(MB)
### K or k for kilobyte(KB)
### no unit for byte(B)
reserved_storage_space = 100MB

然后叫醒售票员

[root@node2 conf]# /usr/local/bin/fdfs_trackerd  tracker.conf  &

测试一下

[root@node2 conf]# lsof -i:22122
COMMAND    PID USER   FD   TYPE DEVICE SIZE NODE NAME
fdfs_trac 3430 root    3u  IPv4  74226       TCP node2.cluster.com:22122 (LISTEN)

--------------------------------------------------------------------------------------
同一个节点中的 storage.conf

disabled=false
group_name=group1 [ 跟上面对应的一个存储组]
bind_addr=1.1.1.12  [还是自己IP]
port=23000
network_timeout=20
heart_beat_interval=30
stat_report_interval=60
base_path=/dbtest
sync_wait_msec=200
max_connections=1024

#tracker_server=10.62.245.107:22122
tracker_server=1.1.1.12:22122    [指向售票员- 就是自己咯]

在叫醒负责数据存储的搬运工

/usr/local/bin/fdfs_storaged storage.conf &

测试一下端口

[root@node2 conf]# lsof -i:23000
COMMAND    PID USER   FD   TYPE DEVICE SIZE NODE NAME
fdfs_stor 3435 root    3u  IPv4  74594       TCP node2.cluster.com:23000 (LISTEN)
fdfs_stor 3435 root    9u  IPv4  74599       TCP node2.cluster.com:saiseh->node1.cluster.com:23000 (ESTABLISHED)



=================================================


[server1] 1.1.1.11   负责数据同步的电脑
共享目录 /dbtest
-------------------------------------------------------------------
[root@node1 conf]# vi storage.conf
disabled=false
group_name=group1   [跟上面的存储属于同一个组]
bind_addr=1.1.1.11    [监听自己的IP还是监听对方的IP?]
port=23000
network_timeout=20
heart_beat_interval=30
stat_report_interval=60
base_path=/dbtest
sync_wait_msec=200
max_connections=1024

#tracker_server=10.62.245.107:22122
tracker_server=1.1.1.12:22122  [所谓的售票员IP及端口]


再次测试一下

[root@node1 conf]# /usr/local/bin/fdfs_storaged storage.conf  &
[root@node1 conf]# ps aux | grep storage
root      4802  0.0  0.2  22304   532 ?        Sl   14:32   0:00 /usr/local/bin/fdfs_storaged storage.conf
root      4808  0.0  0.2   3880   680 pts/1    R+   14:32   0:00 grep storage
[root@node1 conf]# lsof -i:23000
COMMAND    PID USER   FD   TYPE DEVICE SIZE NODE NAME
fdfs_stor 4802 root    3u  IPv4  80191       TCP node1.cluster.com:23000 (LISTEN)
fdfs_stor 4802 root    9u  IPv4  80196       TCP node1.cluster.com:4723->node2.cluster.com:23000 (ESTABLISHED)

--------------------------------------------------------------------
分别在两台电脑上测试一下

[root@node2 conf]# /usr/local/bin/fdfs_test  storage.conf upload /boot/grub/grub.conf
This is FastDFS client test program v1.1

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.

group_name=group1, ip_addr=1.1.1.11, port=23000
group_name=group1, remote_filename=A7/D3/SIbQ1gAAAmsASXXC
file timestamp=1216794838
file size=619
-------------------------------
另外一个测试结果

[root@node1 conf]# /usr/local/bin/fdfs_test  storage.conf upload /boot/grub/grub.conf
This is FastDFS client test program v1.1

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.

group_name=group1, ip_addr=1.1.1.12, port=23000
group_name=group1, remote_filename=9E/24/R3prUgAAAmtNrm_D  [每个人看到的结果可能都不一样吧]
file timestamp=1199205202
file size=619

----------------------------------------------
在其中一个电脑上运行监视程序 {我是在售票员机器上运行,在另外一个也可以看到相同效果}

[root@node2 conf]# /usr/local/bin/fdfs_monitor  storage.conf
group count: 1

Group 1:
group name = group1
free space = 4 GB
storage server count = 2
active server count = 2
storage_port = 23000
current write server index = 2

        Host 1:
                ip_addr = 1.1.1.11  ACTIVE
                total storage = 8GB
                free storage = 4GB
                total_upload_count = 1
                success_upload_count = 1
                total_set_meta_count = 0
                success_set_meta_count = 0
                total_delete_count = 0
                success_delete_count = 0
                total_download_count = 0
                success_download_count = 0
                total_get_meta_count = 0
                success_get_meta_count = 0
                last_source_update = 2008-07-23 14:33:58
                last_sync_update = 1970-01-01 08:00:00
        Host 2:
                ip_addr = 1.1.1.12  ACTIVE
                total storage = 8GB
                free storage = 4GB
                total_upload_count = 1
                success_upload_count = 1
                total_set_meta_count = 0
                success_set_meta_count = 0
                total_delete_count = 0
                success_delete_count = 0
                total_download_count = 0
                success_download_count = 0
                total_get_meta_count = 0
                success_get_meta_count = 0
                last_source_update = 2008-01-02 00:33:22
                last_sync_update = 2008-01-02 00:32:02




---------------------------------------------

再看看 /dbtest 这个用于数据同步的目录,一堆 00 ~ ff 的目录跟 squid 有点相似,估计就是用于缓存的吧,

问题来了。。。我怎么向这个目录传输文件能够同步呢???? 【文档上好像没有写哦】



-_-! 汗啊。。

哈皮鱼 ~~ 救命啊。。。。

[ 本帖最后由 signmem 于 2008-7-23 14:30 编辑 ]

论坛徽章:
4
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:11IT运维版块每日发帖之星
日期:2016-08-11 06:20:00IT运维版块每日发帖之星
日期:2016-08-15 06:20:00
14 [报告]
发表于 2008-07-23 13:52 |只看该作者

回复 #13 signmem 的帖子

/dbtest这个目录存在吗?
如果存在,看一下子目录logs下的日志文件trackerd.log

论坛徽章:
4
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:11IT运维版块每日发帖之星
日期:2016-08-11 06:20:00IT运维版块每日发帖之星
日期:2016-08-15 06:20:00
15 [报告]
发表于 2008-07-23 13:58 |只看该作者

回复 #13 signmem 的帖子

>>group_name=group1   [这个是什么啊?]
>>bind_addr=1.1.1.11    [必须是监听自己的IP]

group_name是组名或卷名,用于划分多个组/卷
bind_addr可以为空,表示不绑定本机IP地址。当然,你配置的例子中是没有问题。

程序没有运行起来,查一下日志文件吧。
/dbtest/logs/trackerd.log
/dbtest/logs/storaged.log

论坛徽章:
0
16 [报告]
发表于 2008-07-23 14:23 |只看该作者
[2008-01-01 23:53:50] file: tracker_service.c, line: 1405, client ip: 1.1.1.12, recv data fail, errno: 0, error info: Success
[2008-01-02 00:14:13] FastDFS v1.1, base_path=/dbtest, network_timeout=20, port=22122, bind_addr=1.1.1.12, max_connections=1024, store_lookup=2, store_group=, reserved_storage_space=100MB
[2008-01-02 00:19:55] file: tracker_service.c, line: 1405, client ip: 1.1.1.11, recv data fail, errno: 0, error info: Success





另外一个电脑上出现了错误日志

[2008-07-23 14:12:49] file: tracker_client_thread.c, line: 506, tracker server 1.1.1.12:22122, recv data fail, errno: 0, error info: Success.
[2008-07-23 14:13:09] file: storage_service.c, line: 1016, client ip: 1.1.1.12, recv data fail, errno: 2, error info: No such file or directory.
[2008-07-23 14:19:01] file: storage_service.c, line: 402, cmd=16, client ip: 1.1.1.12, data file: /dbtest/data/A0/B3/R3piIQAAAchYeYeS already exists, ignore it
[2008-07-23 14:19:01] file: storage_service.c, line: 402, cmd=16, client ip: 1.1.1.12, data file: /dbtest/data/A0/B3/R3piIQAAAchYeYeS-m already exists, ignore it
感觉上代码有问题。。。。我没法修复哦。。。。。。。。



我尝试过在这个目录下复制文件或者建立文件,另外一个电脑上没有反应啊。。。我的配置和做法都在上面 13 楼,麻烦看看。

[ 本帖最后由 signmem 于 2008-7-23 14:53 编辑 ]

论坛徽章:
4
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:11IT运维版块每日发帖之星
日期:2016-08-11 06:20:00IT运维版块每日发帖之星
日期:2016-08-15 06:20:00
17 [报告]
发表于 2008-07-23 15:27 |只看该作者

回复 #16 signmem 的帖子

祝贺啊!你已经成功地运行起来了。
有一个小问题,因为你两台服务器上用的存储目录/dbtest是共享目录,因为都是同一个目录,在storage1同步给storage2时,会检测到该文件已经存在!

难怪就会出现如下提示信息了:
[2008-07-23 14:19:01] file: storage_service.c, line: 402, cmd=16, client ip: 1.1.1.12, data file: /dbtest/data/A0/B3/R3piIQAAAchYeYeS already exists, ignore it
[2008-07-23 14:19:01] file: storage_service.c, line: 402, cmd=16, client ip: 1.1.1.12, data file: /dbtest/data/A0/B3/R3piIQAAAchYeYeS-m already exists, ignore it

论坛徽章:
4
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:11IT运维版块每日发帖之星
日期:2016-08-11 06:20:00IT运维版块每日发帖之星
日期:2016-08-15 06:20:00
18 [报告]
发表于 2008-07-23 15:33 |只看该作者

回复 #16 signmem 的帖子

>>我尝试过在这个目录下复制文件或者建立文件,另外一个电脑上没有反应啊。。。我的配置和做法都在上面 13 楼,麻烦看看。

另外,向存储集群上传文件必须使用FastDFS的Client Library,上传后,系统会自动将该文件同步到卷/组中的其他服务器。例如,组group1中有A、B、C、D共4台存储服务器,一个文件上传到B后,由B将这个文件同步到其余的3台服务器A、C和D。

论坛徽章:
0
19 [报告]
发表于 2008-07-23 17:54 |只看该作者
>>>> 向存储集群上传文件必须使用FastDFS的Client Library <<<< 怎么调用啊??

看是没有看懂怎么去使用或者控制目录下的文件。。。。。。。。

反正现在的问题是 cp,  mv, 等做法都无法同步数据,

比如我要把目录用于一个邮件服务器或者网页服务器中数据同步, 那还需要再次对服务器进行二次开发才能够支持,或者要重新写 FTP 客户端?????

那这个软件没有太大意义吧??

论坛徽章:
4
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:11IT运维版块每日发帖之星
日期:2016-08-11 06:20:00IT运维版块每日发帖之星
日期:2016-08-15 06:20:00
20 [报告]
发表于 2008-07-23 18:38 |只看该作者

回复 #19 signmem 的帖子

目前的确要使用Client Library。以后会考虑使用FUSE按mount方式使用,这样应该就能解决你的问题了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP