安裝環境
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