对于拥有大量图片和小文件的站点,如电子商务网站,tfs是非常理想的,淘宝就是NB.

 

四台服务器,系统都为Centos 5.6

淘宝TFS文件系统配置_第1张图片

 

一、基础环境的设置(只需在dataserver两台服务器上配置)

1.加载ext4模块,让系统支持ext4文件系统

modprobe ext4

2.安装ext4格式工具

yum y install  e4fsprogs e4fsprogs-devel

3.建立数据目录

mkdir /home/disk1

mkdir /home/disk2

mkdir /home/disk3

4.格式硬盘

mkfs.ext4 /dev/sdb

mkfs.ext4 /dev/sdc

mkfs.ext4 /dev/sdd

5.挂载硬盘

mount /dev/sdb /home/disk1

mount /dev/sdc /home/disk2

mount /dev/sdd /home/disk3

6.查看挂载分区淘宝TFS文件系统配置_第2张图片

淘宝TFS文件系统配置_第3张图片

二、文档配置(安装略可参考官网http://code.taobao.org/p/tfs/wiki/index/

 

1.TFSNameserver(192.168.2.240)主配置[ns.conf配置文件]

[public]

log_size=1073741824

log_num = 64

log_level=debug

task_max_queue_size = 10240

port = 8108

work_dir = /usr/local/tfs

dev_name = eth0

thread_count = 50

ip_addr = 192.168.2.240

[nameserver]

safe_mode_time = 300

ip_addr_list = 192.168.2.240|192.168.2.241

group_mask = 255.255.255.255

block_max_size = 83886080

max_replication = 2

min_replication = 2

use_capacity_ratio = 98

block_max_use_ratio = 98

heart_interval = 2

object_dead_max_time = 3600

cluster_id = 1

replicate_ratio_ = 50

max_write_filecount = 16

heart_thread_count = 2

heart_max_queue_size = 10

repl_max_time = 60

cmpact_delete_ratio =  15 

compact_max_load = 200

object_dead_max_time = 86400

object_clear_max_time = 300

max_wait_write_lease = 15

lease_expired_time = 3

max_lease_timeout = 3000

cleanup_lease_threshold = 102400

build_plan_interval = 10

run_plan_expire_interval = 120

build_plan_ratio = 25

dump_stat_info_interval = 60000000

build_plan_default_wait_time = 2

balance_max_diff_block_num = 5

add_primary_block_count = 3

block_chunk_num = 32

task_percent_sec_size = 200

task_max_queue_size = 10000

oplog_sync_max_slots_num = 1024

oplog_sync_thread_num = 1

 

2.TFSNameserver(192.168.2.241)从配置[ns.conf配置文件]

[public]

log_size=1073741824

log_num = 64

log_level=debug

task_max_queue_size = 10240

port = 8108

work_dir = /usr/local/tfs

dev_name = eth0

thread_count = 50

ip_addr = 192.168.2.241

[nameserver]

safe_mode_time = 300

ip_addr_list = 192.168.2.240|192.168.2.241

group_mask = 255.255.255.255

block_max_size = 83886080

max_replication = 2

min_replication = 2

use_capacity_ratio = 98

block_max_use_ratio = 98

heart_interval = 2

object_dead_max_time = 3600

cluster_id = 2

replicate_ratio_ = 50

max_write_filecount = 16

heart_thread_count = 2

heart_max_queue_size = 10

repl_max_time = 60

compact_delete_ratio =  15 

compact_max_load = 200

object_dead_max_time = 86400

object_clear_max_time = 300

max_wait_write_lease = 15

lease_expired_time = 3

max_lease_timeout = 3000

cleanup_lease_threshold = 102400

build_plan_interval = 10

run_plan_expire_interval = 120

build_plan_ratio = 25

dump_stat_info_interval = 60000000

build_plan_default_wait_time = 2

balance_max_diff_block_num = 5

add_primary_block_count = 3

block_chunk_num = 32

task_percent_sec_size = 200

task_max_queue_size = 10000

oplog_sync_max_slots_num = 1024

oplog_sync_thread_num = 1

 

  3.TFSDataserver(192.168.2.242)配置[ds.conf配置文件]

[public]

log_size=1073741824

log_num = 64

log_level=debug

task_max_queue_size = 10240

port = 9998

work_dir = /usr/local/tfs

dev_name= eth0

thread_count = 50

ip_addr = 192.168.2.242

[dataserver]

ip_addr = 192.168.2.11

ip_addr_list = 192.168.2.240|192.168.2.241

port = 8108

heart_interval = 2

check_interval = 2

replicate_threadcount = 2

block_max_size = 7549747

dump_visit_stat_interval = 60

backup_type = 1

backup_path = /home/tfs

mount_name = /home/disk

mount_maxsize = 14194304

base_filesystem_type = 1

superblock_reserve = 0

avg_file_size = 40960

mainblock_size = 7549747

extblock_size = 419430

block_ratio = 0.5

hash_slot_ratio = 0.5

ds_thread_count = 4

 

  4.TFSads(192.168.2.242)配置[ads.conf配置文件]

[public]

log_size=1073741824

log_num = 64

log_level=debug

task_max_queue_size = 10240

port = 12000

work_dir = /usr/local/tfs

dev_name = eth0

thread_count = 50

ip_addr = 192.168.2.242

[adminserver]

check_interval = 5

check_count = 5

warn_dead_count = 3

ds_fkill_waittime = 15

ds_script = /usr/local/tfs/bin/dataserver -f /usr/local/tfs/conf/ds.conf -d

ds_index_list = 1,2,3

[nameserver]

ip_addr = 192.168.2.11

port = 8108

[dataserver]

port = 9998

lock_file = /usr/local/tfs/bin/dataserver

mount_name = /home/disk

 

5.TFSDataserver(192.168.2.243)配置...略和2.243相似,不能写,写不下了。

            

三、服务启动

 

1.启动tfs192.168.2.240)的nameserver

/usr/local/tfs/scripts/tfs  start_ns

2.启动tfs192.168.2.241)的nameserver

/usr/local/tfs/scripts/tfs  start_ns

3.启动tfs192.168.2.242)的dataserver

/usr/local/tfs/scripts/tfs admin_ns

 

3.1查看到服务端的连接淘宝TFS文件系统配置_第4张图片

 

3.2查看dataserver下的块淘宝TFS文件系统配置_第5张图片

4.启动tfs192.168.2.243)的dataserver

/usr/local/tfs/scripts/tfs admin_ns  

 

四、测试

tfstool工具连接到服务端上传图片淘宝TFS文件系统配置_第6张图片

看到上传的图片已经保存成功淘宝TFS文件系统配置_第7张图片

 

详解介绍可参考官方网站http://code.taobao.org/p/tfs/wiki/index/