FastDFS安装

3 篇文章 0 订阅
1 篇文章 0 订阅

先下载安装包

到GitHub上下载fastdfs、libfastcommon、fastdfs-nginx-module

https://github.com/happyfish100/

还需要nginx,去官网下载

http://nginx.org/en/download.html

需要的依赖包

根据自己实际情况安装依赖

#可先查询是否安装
yum list installed |grep XXX
#编译需要
yum install make cmake gcc gcc++
#没有vim-enhanced可能编译的时候会报错
yum install vim-enhanced
yum install pcre pcre-devel
yum install zlib zlib-devel

ps: 我的安装目录为/usr/local/下

安装libfastcommon和fastdfs

#解压libfastcommon-master.zip
unzip libfastcommon-master.zip
cd libfastcommon-master
#编译并安装
./make.sh && ./make.sh install

#解压fastdfs-master.zip
unzip fastdfs-master.zip
cd fastdfs-master
#编译并安装
./make.sh && ./make.sh install

#解压fastdfs-nginx-module-master.zip
unzip fastdfs-nginx-module-master.zip
cd fastdfs-nginx-module-master/src

修改fastdfs-nginx-module配置文件

#修改配置文件
vim fastdfs-nginx-module-master/src/config

ngx_addon_name=ngx_http_fastdfs_module
if test -n "${ngx_module_link}"; then
    ngx_module_type=HTTP
    ngx_module_name=$ngx_addon_name
    ngx_module_incs="/usr/include" #路径修改成这个
    ngx_module_libs="-lfastcommon -lfdfsclient"
    ngx_module_srcs="$ngx_addon_dir/ngx_http_fastdfs_module.c"
    ngx_module_deps=
    CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
    . auto/module
else
    HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
    NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
    CORE_INCS="$CORE_INCS /usr/include" #路径修改成这个
    CORE_LIBS="$CORE_LIBS -lfastcommon -lfdfsclient"
    CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
fi

配置文件拷贝到/etc/fdfs下

/usr/local/fastdfs-master/conf下的client.conf http.conf mime.types storage.conf storage_ids.conf tracker.conf拷贝到/etc/fdfs

/usr/local/fastdfs-master/conf
client.conf  http.conf  mime.types  storage.conf  storage_ids.conf  tracker.conf

/usr/local/fastdfs-nginx-module-master/src下的mod_fastdfs.conf拷贝到/etc/fdfs下

/usr/local/fastdfs-nginx-module-master/src
common.c  common.h  config  mod_fastdfs.conf  ngx_http_fastdfs_module.c

安装nginx

#解压nginx-1.18.0.tar.gz
tar vxfz nginx-1.18.0.tar.gz
cd nginx-1.18.0
#安装插件
./configure --add-module=/usr/local/fastdfs-nginx-module-master/src
#安装nginx
make && make install
#安装完成后会在nginx-1.18.0同级目录生成一个nginx文件夹
cd ../nginx
#修改配置文件
vim conf/nginx.conf

#在server下添加一个location
location /group1/M00 {
   root   /home/yuqing/fastdfs/data;
   ngx_fastdfs_module;
}

#保存退出

修改配置文件

vim /etc/fdfs/storage.conf


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/yuqing/fastdfs
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_path0对应
store_path_count = 1
#保存文件的目录,可设置多个
store_path0 = /home/yuqing/fastdfs
#store_path1 = /home/yuqing/fastdfs2

subdir_count_per_path = 256
#集群服务IP和端口
tracker_server = 192.168.2.54:22122
tracker_server = 192.168.2.55: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 =
# the port of the web server on this storage server
http.server_port = 8888

vim /etc/fdfs/tracker.conf

disabled = false

bind_addr =

port = 22122
connect_timeout = 5
network_timeout = 60

# 保存文件的路径
base_path = /home/yuqing/fastdfs
max_connections = 1024
accept_threads = 1
work_threads = 4
min_buff_size = 8KB
max_buff_size = 128KB
store_lookup = 2
#多个集群需要配置,store_lookup=1则必须配置
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

mod_fastdfs.conf和storage.conf保持一致就行了

vim /etc/fdfs/mod_fastdfs.conf


# connect timeout in seconds
# default value is 30s
connect_timeout=2

# network recv and send timeout in seconds
# default value is 30s
network_timeout=30

# the base path to store log files
base_path=/home/yuqing/fastdfs

# if load FastDFS parameters from tracker server
# since V1.12
# default value is false
load_fdfs_parameters_from_tracker=true

# storage sync file max delay seconds
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# since V1.12
# default value is 86400 seconds (one day)
storage_sync_file_max_delay = 86400

# if use storage ID instead of IP address
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# default value is false
# since V1.13
use_storage_id = false

# specify storage ids filename, can use relative or absolute path
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# since V1.13
storage_ids_filename = storage_ids.conf

# FastDFS tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
# valid only when load_fdfs_parameters_from_tracker is true
tracker_server=192.168.2.54:22122
tracker_server=192.168.2.55:22122

# the port of the local storage server
# the default value is 23000
storage_server_port=23000

# the group name of the local storage server
group_name=group1

# if the url / uri including the group name
# set to false when uri like /M00/00/00/xxx
# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
# default value is false
url_have_group_name = true

# path(disk or mount point) count, default value is 1
# must same as storage.conf
store_path_count=1

# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/home/yuqing/fastdfs
#store_path1=/home/yuqing/fastdfs1

# standard log level as syslog, case insensitive, value list:
### emerg for emergency
### alert
### crit for critical
### error
### warn for warning
### notice
### info
### debug
log_level=info

# set the log filename, such as /usr/local/apache2/logs/mod_fastdfs.log
# empty for output to stderr (apache and nginx error_log file)
log_filename=

# response mode when the file not exist in the local file system
## proxy: get the content from other storage server, then send to client
## redirect: redirect to the original storage server (HTTP Header is Location)
response_mode=proxy

# the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a
# multi aliases split by comma. empty value means auto set by OS type
# this paramter used to get all ip address of the local host
# default values is empty
if_alias_prefix=

# use "#include" directive to include HTTP config file
# NOTE: #include is an include directive, do NOT remove the # before include
#include http.conf


# if support flv
# default value is false
# since v1.15
flv_support = true

# flv file extension name
# default value is flv
# since v1.15
flv_extension = flv


# set the group count
# set to none zero to support multi-group on this storage server
# set to 0  for single group only
# groups settings section as [group1], [group2], ..., [groupN]
# default value is 0
# since v1.14
group_count = 0

# group settings for group #1
# since v1.14
# when support multi-group on this storage server, uncomment following section
#[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/home/yuqing/fastdfs
#store_path1=/home/yuqing/fastdfs1

# group settings for group #2
# since v1.14
# when support multi-group, uncomment following section as neccessary
#[group2]
#group_name=group2
#storage_server_port=23000
#store_path_count=1
#store_path0=/home/yuqing/fastdfs

运行tracker和storage

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start

运行nginx

cd /usr/local/nginx/sbin/
./nginx
#停止nginx命令
./nginx -s stop
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值