本文主要是介绍淘宝TFS文件系统配置(集群),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
对于拥有大量图片和小文件的站点,如电子商务网站,用tfs是非常理想的,淘宝就是NB.
四台服务器,系统都为Centos 5.6
一、基础环境的设置(只需在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.查看挂载分区
二、文档配置(安装略…可参考官网http://code.taobao.org/p/tfs/wiki/index/)
1.TFS的Nameserver(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.TFS的Nameserver(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.TFS的Dataserver(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.TFS的ads(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.TFS的Dataserver(192.168.2.243)配置...略和2.243相似,不能写,写不下了。
三、服务启动
1.启动tfs(192.168.2.240)的nameserver
/usr/local/tfs/scripts/tfs start_ns
2.启动tfs(192.168.2.241)的nameserver
/usr/local/tfs/scripts/tfs start_ns
3.启动tfs(192.168.2.242)的dataserver
/usr/local/tfs/scripts/tfs admin_ns
3.1查看到服务端的连接
3.2查看dataserver下的块
4.启动tfs(192.168.2.243)的dataserver
/usr/local/tfs/scripts/tfs admin_ns
四、测试
用tfstool工具连接到服务端上传图片
看到上传的图片已经保存成功
详解介绍可参考官方网站http://code.taobao.org/p/tfs/wiki/index/
这篇关于淘宝TFS文件系统配置(集群)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!