1.FastDFS介绍
FastDFS是一款开源的轻量级分布式文件系统,
-纯C实现,支持Linux,FreeBSD等UNIX系统,
-类goolge FS,不是通用的文件系统,只能通过专有API访问,目前提供了C,java和PHP API
-为互联网应用量身定做,追求高性能和高扩展
-FastDFS可以看做是基于文件的key value pair存储系统,称作为分布式文件存储服务更合适
2.FastDFS github地址
https://github.com/happyfish100/
3.FastDFS上传原理
- storage定时向tracker上传状态信息
- client上传连接请求到tracker
- tracker查询可用的storage,并返回storage的ip和端口
- 上传文件fIlecontent和meta data
- 生成file_id,将上传的内容写入磁盘,并返回file_id路径和文件名
4.安装FastDFS依赖lib包
cd /usr/local/src/ git clone https://github.com/happyfish100/libfastcommon.git cd libfastcommon/ /make.sh ./make.sh install
或者tar.gz安装
cd /usr/local/src/ wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz tar -zxvf V1.0.7.tar.gz cd libfastcommon/ /make.sh ./make.sh install
5.安装FastDFS
cd /usr/local/src wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz tar -zxvf V5.05 cd fastdfs-5.05/ ./make.sh ./make.sh install
6.更改启动文件的路径
sed -i ‘s#/usr/local/bin/#/usr/bin/#g‘ /etc/init.d/fdfs_trackerd sed -i ‘s#/usr/local/bin/#/usr/bin/#g‘ /etc/init.d/fdfs_storaged
7.创建数据目录
[[email protected] ~]# mkdir -p /data/fdfs/tracker [[email protected] ~]# mkdir -p /data/fdfs/storage
8.配置tracker文件
cd /etc/fdfs/ [[email protected] fdfs]# ll total 20 -rw-r--r--. 1 root root 1461 Apr 20 03:00 client.conf.sample -rw-r--r--. 1 root root 7829 Apr 20 03:00 storage.conf.sample -rw-r--r--. 1 root root 7102 Apr 20 03:00 tracker.conf.sample [[email protected] fdfs]# cp tracker.conf.sample tracker.conf
9.配置追踪配置文件
[[email protected] ~]# grep -Ev ‘^$|^#‘ /etc/fdfs/tracker.conf disabled=false bind_addr= port=22122 connect_timeout=30 network_timeout=60 base_path=/data1/ max_connections=256 accept_threads=1 work_threads=4 store_lookup=2 store_group=group2 store_server=0 store_path=0 download_server=0 reserved_storage_space = 10% log_level=info run_by_group= run_by_user= allow_hosts=* sync_log_buff_interval = 10 check_active_interval = 120 thread_stack_size = 64KB storage_ip_changed_auto_adjust = true storage_sync_file_max_delay = 86400 storage_sync_file_max_time = 300 use_trunk_file = false slot_min_size = 256 slot_max_size = 16MB trunk_file_size = 64MB trunk_create_file_advance = false trunk_create_file_time_base = 02:00 trunk_create_file_interval = 86400 trunk_create_file_space_threshold = 20G trunk_init_check_occupying = false trunk_init_reload_from_binlog = false trunk_compress_binlog_min_interval = 0 use_storage_id = false storage_ids_filename = storage_ids.conf id_type_in_filename = ip store_slave_file_use_link = false rotate_error_log = false error_log_rotate_time=00:00 rotate_error_log_size = 0 log_file_keep_days = 0 use_connection_pool = false connection_pool_max_idle_time = 3600 http.server_port=8080 http.check_alive_interval=30 http.check_alive_type=tcp http.check_alive_uri=/status.html
参考文档:
http://www.cnblogs.com/Yin-BloodMage/p/5433629.html
时间: 2024-10-25 06:03:15