首页 > 代码库 > fdfs安装使用
fdfs安装使用
fdfs是一个分布式文件存储系统
安装:
先下载fastdfs依赖的库
git clone tar xzf libfastcommon_v1.x.tar.gz cd libfastcommon ./make.sh ./make.sh install
安装完成后安装fastdfs
git clone tar xzf FastDFS_v5.x.tar.gz cd FastDFS ./make.sh ./make.sh install
此处介绍下自制rpm包
下载好俩个文件解压
mkdir rpmbuild/{SOURCES,SPECS} cp libfastcommon-1.0.36/libfastcommon.spec rpmbuild/SPECS/ cp libfastcommon-1.0.36.tar.gz rpmbuild/SOURCES/ rpmbuild -ba rpmbuild/SPECS/libfastcommon.spec
此处注意要事先查看libfastcommon-1.0.36/libfastcommon.spec,这里有标注此安装包的版本,然后将原有文件重命名后,再压缩成tar包。fastdfs同理。
安装完成后编写fdfs_store的配置文件:
[root@node2 data]# cat /etc/fdfs/storage.conf disabled=false group_name=group1 bind_addr= client_bind=true port=23000 //fdfs监听的端口号 connect_timeout=30 //连接超时时间 network_timeout=60 heart_beat_interval=30 //心跳时间 stat_report_interval=60 base_path=/data/fdfs/storage //数据存储位置 max_connections=256 //最大连接数 buff_size = 256KB accept_threads=1 work_threads=1 disk_rw_separated = true //读写隔离 disk_reader_threads = 1 disk_writer_threads = 1 sync_wait_msec=50 sync_interval=0 sync_start_time=00:00 sync_end_time=23:59 write_mark_file_freq=500 store_path_count=1 //存储有几个设备,dev1、dev2就是两个 store_path0=/data/fdfs/storage subdir_count_per_path=256 tracker_server=192.168.145.93:22122 //tracker节点的ip端口 log_level=info run_by_group= run_by_user= allow_hosts=* file_distribute_path_mode=0 file_distribute_rotate_count=100 fsync_after_written_bytes=0 sync_log_buff_interval=10 sync_binlog_buff_interval=10 sync_stat_file_interval=300 thread_stack_size=512KB upload_priority=10 if_alias_prefix= check_file_duplicate=0 file_signature_method=hash key_namespace=FastDFS keep_alive=0 use_access_log = false rotate_access_log = false access_log_rotate_time=00:00 rotate_error_log = false error_log_rotate_time=00:00 rotate_access_log_size = 0 rotate_error_log_size = 0 log_file_keep_days = 0 file_sync_skip_invalid_record=false use_connection_pool = false connection_pool_max_idle_time = 3600 http.domain_name= http.server_port=8888
编写fdfs_tracker节点配置文件
[root@node2 data]# cat /etc/fdfs/tracker.conf disabled=false bind_addr= port=22122 //tracker节点的端口 connect_timeout=30 network_timeout=60 base_path=/data/fdfs/tracker //tracker存储的数据和日志目录 max_connections=256 accept_threads=1 work_threads=4 //工作线程数,此处最好不要超过cpu的核心数 min_buff_size = 8KB max_buff_size = 128KB 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
建立tracker和store的数据目录
mkdir -pv /data/fdfs/tracker mkdir /data/fdfs/storage
启动tracker和store节点:
service fdfs_trackerd start service fdfs_storaged start
查看fdfs状态:
[root@node2 data]# fdfs_monitor /etc/fdfs/storage.conf
测试上传下载文件:
[root@node2 data]# fdfs_upload_file -h Usage: fdfs_upload_file <config_file> <local_filename> [storage_ip:port] [store_path_index] fdfs_upload_file /etc/fdfs/storage.conf /etc/fstab
[root@node2 data]# fdfs_download_file -h Usage: fdfs_download_file <config_file> <file_id> [local_filename] [<download_offset> <download_bytes>] fdfs_download_file /etc/fdfs/storage.conf group1/M00/00/00/wKiRXVi-mFCAPFjuAAADJe451Y02464221 /tmp/a
至此安装完毕
本文出自 “landanhero” 博客,请务必保留此出处http://landanhero.blog.51cto.com/788351/1951180
fdfs安装使用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。