网上说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
[[email protected] ~]# rpm -qa|grep libevent libevent-1.4.13-4.el6.x86_64 [[email protected] ~]# rpm -e libevent-1.4.13-4.el6.x86_64 [[email protected] ~]# tar xvf libevent-2.0.21-stable.tar.gz [[email protected] ~]# cd libevent-2.0.21-stable [[email protected] libevent-2.0.21-stable]# ./configure && make && make install [[email protected] libevent-2.0.21-stable]# ln -s /usr/local/lib/libevent* /lib [[email protected] libevent-2.0.21-stable]# ln -s /usr/local/lib/libevent* /lib64/ [[email protected] ~]# tar xvf FastDFS_v5.02.tar.gz [[email protected] ~]# cd FastDFS [[email protected] FastDFS]# ./make.sh [[email protected] FastDFS]# ./make.sh install tracker [[email protected] ~]# 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 [[email protected] ~]# 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 [[email protected] ~]# 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 [[email protected] ~]# tar xvf fastdfs-nginx-module_v1.15.tar.gz [[email protected] ~]# ./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 模块安装 [[email protected] ~]# cd FastDFS/php_client/ [[email protected] php_client]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 [[email protected] 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 [[email protected] ~]# /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,这次是正式服务器安装,并且还需要把旧文件放在新环境上中间遇到了比较多的问题