1.步骤:
环境依赖的安装配置安装路径安装相关组件进行环境配置常见问题汇总
1-1. 环境依赖的安装
yum
install git gcc gcc-c++
make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel
wget vim -y
2-1 配置安装路径
storage 安装目录 /home/fastdfs/storagetracker 安装目录 /home/fastdfs/tracker应用安装目录 /service/applicaetion组件下载目录 /service/tools
3.1 安装相关组件
3.1.1 创建目录
mkdir -p service/
{application,tools
}
3.1.2 下载安装 libfatscommon 模块
cd /service/tools
git clone https://github.com/happyfish100/libfastcommon.git --depth 1
cd libfastcommon/
./make.sh
&& ./make.sh
install
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
3.1.3 下载安装 FastDFS 模块
cd ~ /service/tools
git clone https://github.com/happyfish100/fastdfs.git --depth 1
cd fastdfs/
./make.sh
&& ./make.sh
install
3.1.4 复制配置文件
cp /service/tools/fastdfs/conf/tracker.conf.sample /etc/fdfs/tracker.conf
cp /service/tools/fastdfs/conf/storage.conf.sample /etc/fdfs/storage.conf
cp /service/tools/fastdfs/conf/client.conf.sample /etc/fdfs/client.conf
cp /service/tools/fastdfs/conf/http.conf /etc/fdfs/
cp /service/tools/fastdfs/conf/mime.types /etc/fdfs/
3.1.5 安装 fastdfs-nginx-module 模块
cd ~ /service/tools
git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
cp /service/tools/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
3.1.6 安装nginx 模块
请参考我之前的文章 Nginx 安装
注意!!! 需要在配置项中添加 FastDFS模块
./configure --prefix
=/home/nginx --with-http_ssl_module --add-module
=/service/tools/fastdfs-nginx-module/src
4.1 进行环境配置
4.1.1 tracker的配置
vim /etc/fdfs/tracker.conf
port
=22122
base_path
=/home/fastdfs/tracker
disabled
= false
bind_addr
=
port
= 22122
connect_timeout
= 5
network_timeout
= 60
base_path
= /home/fastdfs/tracker
max_connections
= 1024
accept_threads
= 1
work_threads
= 4
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
= 20%
log_level
= info
run_by_group
=
run_by_user
=
allow_hosts
= *
sync_log_buff_interval
= 1
check_active_interval
= 120
thread_stack_size
= 256KB
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
= 1MB
trunk_alloc_alignment_size
= 256
trunk_free_space_merge
= true
delete_unused_trunk_files
= false
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
= 86400
trunk_compress_binlog_interval
= 86400
trunk_compress_binlog_time_base
= 03:00
trunk_binlog_max_backups
= 7
use_storage_id
= false
storage_ids_filename
= storage_ids.conf
id_type_in_filename
= id
store_slave_file_use_link
= false
rotate_error_log
= false
error_log_rotate_time
= 00:00
compress_old_error_log
= false
compress_error_log_days_before
= 7
rotate_error_log_size
= 0
log_file_keep_days
= 0
use_connection_pool
= true
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
4.1.2 storage的配置
vim /etc/fdfs/storage.conf
port
=23000
base_path
=/home/fastdfs/storage
store_path0
=/home/fastdfs/storage/data
tracker_server
=10.155.11.10:22122
http.server_port
=8888
disabled
= false
group_name
= group1
bind_addr
=
client_bind
= true
port
= 23000
connect_timeout
= 5
network_timeout
= 60
heart_beat_interval
= 30
stat_report_interval
= 60
base_path
= /home/fastdfs/storage
max_connections
= 1024
buff_size
= 256KB
accept_threads
= 1
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
disk_recovery_threads
= 3
store_path_count
= 1
store_path0
= /home/fastdfs/storage/data
subdir_count_per_path
= 256
tracker_server
= 10.211.11.10:22122
tracker_server
= 10.211.11.10:22122
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
= 1
sync_binlog_buff_interval
= 1
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
compress_old_access_log
= false
compress_access_log_days_before
= 7
rotate_error_log
= false
error_log_rotate_time
= 00:00
compress_old_error_log
= false
compress_error_log_days_before
= 7
rotate_access_log_size
= 0
rotate_error_log_size
= 0
log_file_keep_days
= 0
file_sync_skip_invalid_record
= false
use_connection_pool
= true
connection_pool_max_idle_time
= 3600
compress_binlog
= true
compress_binlog_time
= 01:30
check_store_path_mark
= true
http.domain_name
=
http.server_port
= 8888
4.2 开启服务
systemctl start fdfs_trackerd
Starting fdfs_trackerd
(via systemctl
):
[ OK
]
systemctl start fdfs_storaged
Starting fdfs_storaged
(via systemctl
):
[ OK
]
vim /etc/rc.d/rc.local
systemctl start fdfs_trackerd
systemctl start fdfs_storaged
4.3 配置客户端
vim /etc/fdfs/client.conf
base_path
=/home/fastdfs/storage
tracker_server
=10.155.11.10:22122
fdfs_upload_file /etc/fdfs/client.conf /usr/local/src/nginx-1.15.4.tar.gz
上传成功会显示文件目录:
http://10.155.11.10:8888/group1/M00/00/00/CtM3C178dCuAVe0IAAEtoZaCs2c959.jpg
4.4 Nginx 的相关配置
vim /etc/fdfs/mod_fastdfs.conf
tracker_server
=10.155.11.10:22122
url_have_group_name
=true
store_path0
=/home/fastdfs/storage
vim /usr/local/nginx/conf/nginx.conf
server
{
listen 8888
;
server_name localhost
;
location ~/group
[0-9
]/
{
ngx_fastdfs_module
;
}
error_page 500 502 503 504 /50x.html
;
location
= /50x.html
{
root html
;
}
}
./nginx -s reload
4.5 进行访问测试
如果 访问不了 就修改防火墙
firewall-cmd --zone
=public --add-port
=23000/tcp --permanent
或者
systemctl
enable firewalld.service
systemctl stop firewalld.service
systemctl disable firewalld.service
在浏览器上输入 地址 http://10.211.55.11:8888/group1/M00/00/00/CtM3C178dCuAVe0IAAEtoZaCs2c959.jpg
恭喜安装成功 !!!
5.1 常见问题
如配置文件配置 错误, 则会报如下错误, 请安装上面的流程重新梳理一遍
[2015-04-28 11:30:14
] ERROR - file: ini_file_reader.c, line: 315, include
file "http.conf" not exists, line:
"#include http.conf"
[2015-04-28 11:30:14
] ERROR - file: /root/fastdfs-nginx-module-master/src/common.c, line: 155, load conf
file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2
2015/04/28 11:30:14
[alert
] 19969