網上說fastdfs5.2 增加了好多功能修復了一些bug,正好我們用的4.多的版本用手機上傳圖片的時候遇到各種問題,然後決定換成5.2版本的以下是安裝的一些筆記
環境:centos 6.5
fastdfs版本 5.2
tracker 192.168.1.100
storage 192.168.1.101
storage 192.168.1.102
[root@localhost ~]# rpm -qa|grep libevent libevent-1.4.13-4.el6.x86_64 [root@localhost ~]# rpm -e libevent-1.4.13-4.el6.x86_64 [root@localhost ~]# tar xvf libevent-2.0.21-stable.tar.gz [root@localhost ~]# cd libevent-2.0.21-stable [root@localhost libevent-2.0.21-stable]# ./configure && make && make install [root@localhost libevent-2.0.21-stable]# ln -s /usr/local/lib/libevent* /lib [root@localhost libevent-2.0.21-stable]# ln -s /usr/local/lib/libevent* /lib64/ [root@localhost ~]# tar xvf FastDFS_v5.02.tar.gz [root@localhost ~]# cd FastDFS [root@localhost FastDFS]# ./make.sh [root@localhost FastDFS]# ./make.sh install tracker [root@localhost ~]# grep -Ev '^$|^#' /etc/fdfs/tracker.conf disabled=false bind_addr= port=22122 connect_timeout=30 network_timeout=60 base_path=/opt/fastdfs max_connections=256 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=fastdfs run_by_user=fastdfs 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 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 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 storage [root@localhost ~]# grep -Ev '^$|^#' /etc/fdfs/storage.conf disabled=false group_name=root bind_addr= client_bind=true port=23000 connect_timeout=30 network_timeout=60 heart_beat_interval=30 stat_report_interval=60 base_path=/opt/fastdfs max_connections=256 buff_size = 256KB work_threads=4 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 store_path0=/opt/fastdfs subdir_count_per_path=256 tracker_server=192.168.1.100:22122 log_level=info run_by_group=fastdfs run_by_user=fastdfs 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 file_sync_skip_invalid_record=false use_connection_pool = false connection_pool_max_idle_time = 3600 http.domain_name= http.server_port=888 [root@localhost ~]# grep -Ev '^$|^#' /etc/fdfs/mod_fastdfs.conf connect_timeout=2 network_timeout=30 base_path=/tmp load_fdfs_parameters_from_tracker=true storage_sync_file_max_delay = 86400 use_storage_id = false storage_ids_filename = storage_ids.conf tracker_server=192.168.1.100:22122 storage_server_port=23000 group_name=root url_have_group_name = false store_path_count=1 log_level=info log_filename= response_mode=proxy if_alias_prefix= http.need_find_content_type=false flv_support = true flv_extension = flv group_count = 0 [root@localhost ~]# tar xvf fastdfs-nginx-module_v1.15.tar.gz [root@localhost ~]# ./configure --user=www --group=www --add-module=/root/fastdfs-nginx-module/src/ --with-http_stub_status_module --with-http_ssl_module --prefix=/usr/local/nginx nginx.conf 配置 server { listen 80; server_name localhost; root /opt/fastdfs/data; access_log logs/a.access.log; error_log logs/a.error.log; location /root/M00 { alias /opt/fastdfs/data; ngx_fastdfs_module; } } php 模塊安裝 [root@localhost ~]# cd FastDFS/php_client/ [root@localhost php_client]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 [root@localhost php_client]# ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install php.ini配置如下 extension = fastdfs_client.so fastdfs_client.base_path = /opt/fastdfs fastdfs_client.connect_timeout = 2 fastdfs_client.network_timeout = 60 fastdfs_client.log_level = info fastdfs_client.log_filename = fastdfs_client.http.anti_steal_secret_key = fastdfs_client.tracker_group_count = 1 fastdfs_client.tracker_group0 = /etc/fdfs/client.conf fastdfs_client.use_connection_pool = false fastdfs_client.connection_pool_max_idle_time = 3600 tracker啓動 /usr/local/bin/fdfs_tracker /etc/fdfs/tracker.conf start storage啓動 /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf start [root@localhost ~]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload 20150114.txt This is FastDFS client test program v5.02 Copyright (C) 2008, Happy Fish / YuQing FastDFS may be copied only under the terms of the GNU General Public License V3, which may be found in the FastDFS source kit. Please visit the FastDFS Home Page http://www.csource.org/ for more detail. [2015-01-14 13:49:33] DEBUG - base_path=/opt/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0 tracker_query_storage_store_list_without_group: server 1. group_name=, ip_addr=192.168.1.101, port=23000 server 2. group_name=, ip_addr=192.168.1.102, port=23000 group_name=root, ip_addr=192.168.1.101, port=23000 storage_upload_by_filename group_name=root, remote_filename=M00/00/6A/fdAJ2FS2A22AQhHvAAAAXlctSVo396.txt source ip address: 192.168.1.101 file timestamp=2015-01-14 13:49:33 file size=94 file crc32=1462585690 example file url: http://192.168.1.101:8080/root/M00/00/6A/fdAJ2FS2A22AQhHvAAAAXlctSVo396.txt storage_upload_slave_by_filename group_name=root, remote_filename=M00/00/6A/fdAJ2FS2A22AQhHvAAAAXlctSVo396_big.txt source ip address: 192.168.1.101 file timestamp=2015-01-14 13:49:34 file size=94 file crc32=1462585690 example file url: http://192.168.1.101:8080/root/M00/00/6A/fdAJ2FS2A22AQhHvAAAAXlctSVo396_big.txt
好了總算是弄通了!
中間過程中遇到了一些問題在這做下記錄
報錯(一):
ERROR - file: tracker_func.c, line: 360, getgrnam fail, errno: 2, error info: No such file or directory
上邊這個錯服務啓動不起來,網上查了半天,最後纔想到因爲沒有創建對應的帳號fastdfs,創建好帳號後,可以正常啓動了
報錯(二)
ERROR - file: tracker_client_thread.c, line: 275, connect to tracker server 192.168.1.100:22122 fail, errno: 4
, error info: Interrupted system call
這個錯是防火牆的原因,當時只把端口加到防火牆了,但是沒有重啓,所以沒有生效
報錯(三)
ERROR - file: tracker_proto.c, line: 48, server: 192.168.1.102:23000, response status 17 != 0
這個錯是因爲以前的文件系統挪到現在新環境中,並且多加了一臺storage ,兩邊一直報這個錯,這段時間上傳文件兩個storage不能同步,我猜想可能是兩個storage之間正在校對文件,20分鐘後日志也不報錯了,文件也正常同步了
以前都是在測試機器上安裝fastdfs,這次是正式服務器安裝,並且還需要把舊文件放在新環境上中間遇到了比較多的問題