安装环境
Cnetos 6.7 64位
fastdfs-5.05.tar.gz
一共三个节点 node1:192.168.30.93;node2:192.168.30.94;node3:192.168.30.95
一、安装前准备
1、因为FDFS为开源的java程序,所以需要安装jdk
2、下载安装依赖包libfastcommon
# wget https://github.com/happyfish100/libfastcommon/archive/master.zip # unzip master.zip # cd libfastcommon-master/ # ./make.sh # ./make.sh install
二、安装fastdfs-5.05.tar.gz
1、以下操作在三个节点都要进行:
# cp fastdfs-5.05.tar.gz /usr/src # tar zxvf fastdfs-5.05.tar.gz # cd fastdfs-5.05 # ./make.sh # ./make.sh install
2、源码安装完成后,可在/usr/bin下查看fdfs的可执行文件
3、/etc/fdfs下为配置模板
三、修改配置文件
1、本次部署一共三个节点,94和95作为tracker节点,负责调度,引导存储,另外这三个节点都作为storage节点,负责存储。
2、配置tracker节点,94和95配置相同
# cd /etc/fdfs # cp tracker.conf.sample tracker.conf # vim tracker.conf disabled=false #此项需要设置为false port=22122 #此项为tracker监听端口 base_path=/home/yuqing/fastdfs #此项为tracker的日志和同步的bin文件存放目录 store_lookup=2 #此项为存储方式,其中0为轮流存储,1为指定组,2为智能存储,首选空间较大组 store_group=group2 #当存储方式为1时,指定的存储组 http.server_port=8080 #这个是如果要做web界面时候用的http端口
3、配置storage节点,三个节点配置相同
# cp storage.conf.sample storage.conf # vim storage.conf disabled=false #设置为false group_name=group1 #表示组名 port=23000 #storage监听端口 base_path=/home/yuqing/fastdfs #storage日志及bin文件存放位置 store_path_count=1 #存储路径数 store_path0=/home/yuqing/fastdfs #文件存储位置 tracker_server=192.168.209.121:22122 #tracker节点位置,可写多项,因此将94、95按格式填写 http.server_port=8888 #web接口,如果不加nginx可不管,但是要tracker和storage一样
4、配置client
# cp client.conf.sample client.conf # vim client.conf base_path=/home/yuqing/fastdfs #文件存储位置 tracker_server=192.168.0.197:22122 #同上 http.tracker_server_port=80 #同上
四、启动服务
1、启动tracker
# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start # tail -f /home/yuqing/fastdfs/logs/trackerd.log [2016-08-31 16:06:11] INFO - FastDFS v5.05, base_path=/data/linkdood/logs/fastdfs, run_by_group=, run_by_user=, connect_timeout=30s, network_timeout=60s, port=22122, bind_addr=, max_connections=256, accept_threads=1, work_threads=4, store_lookup=2, store_group=, store_server=0, store_path=0, reserved_storage_space=10.00%, downloa d_server=0, allow_ip_count=-1, sync_log_buff_interval=10s, check_active_interval= 120s, thread_stack_size=64 KB, storage_ip_changed_auto_adjust=1, storage_sync_file _max_delay=86400s, storage_sync_file_max_time=300s, use_trunk_file=0, slot_min_siz e=256, slot_max_size=16 MB, trunk_file_size=64 MB, trunk_create_file_advance=0, tr unk_create_file_time_base=02:00, trunk_create_file_interval=86400, trunk_create_fil e_space_threshold=20 GB, trunk_init_check_occupying=0, trunk_init_reload_from_binlo g=0, trunk_compress_binlog_min_interval=0, use_storage_id=0, id_type_in_filename=ip , storage_id_count=0, rotate_error_log=0, error_log_rotate_time=00:00, rotate_error _log_size=0, log_file_keep_days=0, store_slave_file_use_link=0, use_connection_pool =0, g_connection_pool_max_idle_time=3600s
如果查看日志为以上信息,表示启动成功。
2、启动storage
# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start # tail -f /home/yuqing/fastdfs/logs/storaged.log [2016-08-31 16:08:28] INFO - file: storage_param_getter.c, line: 191, use_storage_id=0, id_type_in_filename=ip, storage_ip_changed_auto_adjust=1, store_path=0, reserved_stor age_space=10.00%, use_trunk_file=0, slot_min_size=256, slot_max_size=16 MB, trunk_file _size=64 MB, trunk_create_file_advance=0, trunk_create_file_time_base=02:00, trunk_crea te_file_interval=86400, trunk_create_file_space_threshold=20 GB, trunk_init_check_occu pying=0, trunk_init_reload_from_binlog=0, trunk_compress_binlog_min_interval=0, store_s lave_file_use_link=0 [2016-08-31 16:08:28] INFO - file: storage_func.c, line: 254, tracker_client_ip: 192.168 .30.94, my_server_id_str: 192.168.30.94, g_server_id_in_filename: -2079846228 [2016-08-31 16:08:28] INFO - file: tracker_client_thread.c, line: 310, successfully con nect to tracker server 192.168.30.94:22122, as a tracker client, my ip is 192.168.30.94
如果查看日志看到以上信息,表示启动成功。
3、启动检测进程
# /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
active为已激活的存储节点
STORAGE SERVER的状态通常有七种:
# FDFS_STORAGE_STATUS:INIT :初始化,尚未得到同步已有数据的源服务器
# FDFS_STORAGE_STATUS:WAIT_SYNC :等待同步,已得到同步已有数据的源服务器
# FDFS_STORAGE_STATUS:SYNCING :同步中
# FDFS_STORAGE_STATUS:DELETED :已删除,该服务器从本组中摘除
# FDFS_STORAGE_STATUS:OFFLINE :离线
# FDFS_STORAGE_STATUS:ONLINE :在线,尚不能提供服务
# FDFS_STORAGE_STATUS:ACTIVE :在线,可以提供服务
正常状态必须是ACTIVE
如果为WAIT_SYNC等待一会即可
如果是INIT,可删除节点重新加入
删除命令为
# /usr/bin/fdfs_monitor /etc/fdfs/client.conf delete group1 192.168.30.95
然后显示storage3为删除
存储文件命令为
# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/test.txt group1/M00/00/00/wKgeXlfGo2yAB9YY653.txt
文件下载命令
# /usr/bin/fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/wKgeXlfGo2yAB9YY653.txt
删除文件命令
# /usr/bin/fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wKgeXlfGo2yAB9YY653.txt
原文地址:http://bolemon.blog.51cto.com/10275874/1844911