准备安装软件

[root@blog third_package]# cp fastdfs-nginx-module_v1.16.tar.gz FastDFS_v5.08.tar.gz libfastcommon-master.zip nginx-1.8.0.tar.gz  /opt

安装libfastcommon-master

[root@blog opt]# unzip /opt/libfastcommon-master.zip
Archive: /opt/libfastcommon-master.zip
[root@blog opt]#
[root@blog opt]# cd libfastcommon-master
[root@blog libfastcommon-master]#
[root@blog libfastcommon-master]# ./make.sh
[root@blog libfastcommon-master]# ./make.sh install

安装FastDFS

[root@blog opt]# tar -zxvf /opt/FastDFS_v5.08.tar.gz
[root@blog opt]# cd FastDFS
[root@blog FastDFS]# ./make.sh
[root@blog FastDFS]# ./make.sh install

拷贝配置文件

[root@blog fdfs]# ll /etc/fdfs/
total 20
-rw-r--r-- 1 root root 1461 May 23 11:02 client.conf.sample
-rw-r--r-- 1 root root 7927 May 23 11:02 storage.conf.sample
-rw-r--r-- 1 root root 7200 May 23 11:02 tracker.conf.sample
[root@blog fdfs]# cp /opt/FastDFS/conf/storage.conf /opt/FastDFS/conf/tracker.conf /etc/fdfs/
[root@blog /]# cp /opt/FastDFS/conf/client.conf /etc/fdfs/
[root@blog conf]# cp /opt/FastDFS/conf/http.conf /etc/fdfs/
[root@blog fdfs]# rm ./*.sample
rm: remove regular file `./client.conf.sample'? y
rm: remove regular file `./storage.conf.sample'? y
rm: remove regular file `./tracker.conf.sample'? y

创建存放数据和日志的文件夹

[root@blog /]# mkdir -p /my_fastdfs/{storage,tracker}

修改后的storage.conf,主要修改base_path、store_path0、tracker_server:

[root@blog /]# grep -v "^#"  /etc/fdfs/storage.conf | grep -v "^$"
disabled=false
group_name=group1
bind_addr=
client_bind=true
port=23000
connect_timeout=30
network_timeout=60
heart_beat_interval=30
stat_report_interval=60
base_path=/my_fastdfs/storage
max_connections=256
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
store_path_count=1
store_path0=/my_fastdfs/storage
subdir_count_per_path=256
tracker_server=IP: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=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
log_file_keep_days = 0
file_sync_skip_invalid_record=false
use_connection_pool = false
connection_pool_max_idle_time = 3600
http.domain_name=
http.server_port=8888

修改后的tracker.conf,主要修改base_path:

[root@blog /]# grep -v "^#"  /etc/fdfs/tracker.conf | grep -v "^$"
disabled=false
bind_addr=
port=22122
connect_timeout=30
network_timeout=60
base_path=/my_fastdfs/tracker
max_connections=256
accept_threads=1
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=
run_by_user=
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
trunk_compress_binlog_min_interval = 0
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
log_file_keep_days = 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

修改后的client.conf

主要修改base_path、tracker_server:

[root@blog /]# grep -v "^#"  /etc/fdfs/client.conf | grep -v "^$"
connect_timeout=30
network_timeout=60
base_path=/my_fastdfs/storage
tracker_server=IP:22122
log_level=info
use_connection_pool = false
connection_pool_max_idle_time = 3600
load_fdfs_parameters_from_tracker=false
use_storage_id = false
storage_ids_filename = storage_ids.conf
http.tracker_server_port=80

启动FastDFS

[root@blog /]# /etc/init.d/fdfs_storaged start
Starting FastDFS storage server:
[root@blog /]# /etc/init.d/fdfs_trackerd start
Starting FastDFS tracker server:
[root@blog /]# ps -ef | grep -E fdfs
root 23485 1 0 11:24 ? 00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
root 23596 1 0 11:26 ? 00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
root 23656 20047 0 11:27 pts/3 00:00:00 grep -E fdfs

测试上传、下载文件

[root@blog tmp]# cd /tmp/ && echo '123' > hello.html
[root@blog tmp]# fdfs_upload_file /etc/fdfs/client.conf hello.html
group1/M00/00/00/rBIlOFkjrW2Ac6TAAAAABFqCAvc47.html
[root@blog tmp]# fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/rBIlOFkjrW2Ac6TAAAAABFqCAvc47.html hello.html.bak
[root@blog tmp]# cat hello.html.bak
123

安装fastdfs-nginx-module

[root@blog opt]# tar -zxvf fastdfs-nginx-module_v1.16.tar.gz

查找fastfds、fastcommon在哪

[root@blog fastdfs-nginx-module]# find /usr/ -name fastdfs
/usr/include/fastdfs
^C
[root@blog fastdfs-nginx-module]# find /usr/ -name fastcommon
/usr/include/fastcommon

根据上述查得的实际路径修改config

[root@blog fastdfs-nginx-module]# cat /opt/fastdfs-nginx-module/src/config
ngx_addon_name=ngx_http_fastdfs_module
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/fastdfs /usr/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/local/lib -lfastcommon -lfdfsclient"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"

安装nginx和添加fastdfs-nginx-module

[root@blog opt]# tar -zxvf nginx-1.8.0.tar.gz
[root@blog opt]# cd nginx-1.8.0
[root@blog nginx-1.8.0]# ./configure --prefix=/usr/local/nginx --add-module=/opt/fastdfs-nginx-module/src
[root@blog nginx-1.8.0]# make
[root@blog nginx-1.8.0]# make install

拷贝、修改mod_fastdfs.conf

主要修改base_path、tracker_server、store_path0、url_have_group_name:

[root@blog nginx-1.8.0]# cp /opt/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
[root@blog nginx-1.8.0]# grep -v "^#" /etc/fdfs/mod_fastdfs.conf | grep -v "^$"
connect_timeout=2
network_timeout=30
base_path=/my_fastdfs/storage
load_fdfs_parameters_from_tracker=true
storage_sync_file_max_delay = 86400
use_storage_id = false
storage_ids_filename = storage_ids.conf
tracker_server=IP:22122
storage_server_port=23000
group_name=group1
url_have_group_name = true
store_path_count=1
store_path0=/my_fastdfs/storage
log_level=info
log_filename=
response_mode=proxy
if_alias_prefix=
flv_support = true
flv_extension = flv
group_count = 0

在/usr/local/nginx/conf/nginx.conf添加此段

	location /group1/M00 {
# root html;
ngx_fastdfs_module;
}

启动nginx

拷贝需要的文件

[root@blog conf]# cp /usr/local/nginx/conf/mime.types /etc/fdfs

启动nginx,并查看错误日志是否报错

[root@blog conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ngx_http_fastdfs_set pid=27789
[root@blog conf]# less /usr/local/nginx/logs/error.log

查看是否能访问:

http://IP/group1/M00/00/00/rBIlOFkjrW2Ac6TAAAAABFqCAvc47.html

【FastDFS】FastDFS在CentOS的搭建的更多相关文章

  1. fastDFS 一二事 - 简易服务器搭建(单linux)

    什么是FastDFS FastDFS是一个叫余庆的哥们用c语言编写的一款开源的分布式文件系统 功能有冗余备份.负载均衡.线性扩容等,高可用.高性能 可以用FastDFS搭建一套高性能的文件服务器集群提 ...

  2. FastDFS+nginx+keepalived集群搭建

    安装环境 nginx-1.6.2 libfastcommon-master.zip FastDFS_v5.05.tar.gz(http://sourceforge.net/projects/fastd ...

  3. CentOS下搭建LAMP环境详解

    前言:在这里将介绍如何在CentOS下搭建LAMP环境(全部使用源码编译安装),用于web服务器开发. •LAMP: Linux + Apache + PHP + Mysql. •系统: CentOS ...

  4. CentOs上搭建git服务器

    CentOs上搭建git服务器 首先安装setuptools wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0 ...

  5. Centos下搭建 nginx+uwsgi+python

    python做web应用最麻烦的还是配置服务器了,此话不假,光中间件就有好几种选择,fastcgi.wsgi.uwsgi,难 免让人眼花缭乱. 而听说uwsgi的效率是fastcgi和wsgi的10倍 ...

  6. 在CentOS 上搭建nginx来部署静态页面网站

    在centOs 上搭建nginx来部署静态页面网站 一.部署服务器环境 nginx:轻量级.高性能的HTTP及反向代理服务器,占用内存少,并发能力强,相比老牌的apache作为web服务器,性能更加卓 ...

  7. CentOS 7 搭建PXC 数据库集群

    CentOS 7 搭建PXC 数据库集群 PXC( Percona XtraDB Cluster ) 特点如下: 1.同步复制,事务要么在所有节点提交或不提交,保证了数据的强一致性. 2.多主复制,可 ...

  8. centos上搭建git服务--3

    前言:当我们想要实现几个小伙伴合作开发同一个项目,或者建立一个资源分享平台的时候,GIT就是一个很好的选择.当然,既然是一个共有平台,那么把这个平台放到个人计算机上明显是不合适的,因此就要在服务器上搭 ...

  9. CentOS中搭建Redis伪分布式集群【转】

    解压redis 先到官网https://redis.io/下载redis安装包,然后在CentOS操作系统中解压该安装包: tar -zxvf redis-3.2.9.tar.gz 编译redis c ...

  10. CentOS下搭建LNMP+WordPress+http2.0教程

    此文是本人CentOS下搭建WordPress的一些笔记,环境搭建时间::将看过的几篇文章总结下来,形成一条龙长文.不用大家再找来找去. 本文大概分为此几部分: 一.基础命令更新: 二.服务器加速(非 ...

随机推荐

  1. commit your changes or stash them before you can merge

    今天用git pull来更新代码,遇到了下面的问题: 今天git pull 出现以下问题 Please commit your changes or stash them before you mer ...

  2. 事务的四个属性ACID

    事务四大特征:原子性,一致性,隔离性和持久性. 1. 原子性(Atomicity) 一个原子事务要么完整执行,要么干脆不执行.这意味着,工作单元中的每项任务都必须正确执行.如果有任一任务执行失败,则整 ...

  3. NFS客户端、服务器协商读写粒度(rsize、wsize)流程 【转】

    rsize和wsize决定了网络文件系统(NFS)一次网络交互所能够读写的数据块的大小,rsize和wsize的大小对网络文件系统(NFS)的性能有重要影响.rsize和wsize的大小是在用户配置的 ...

  4. Redis学习之路(001)- Redis介绍以及安装(Linux)

    redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcached类似,但很大程度补偿了memcached的不足,它支持存储的value类型相对更多,包括strin ...

  5. 树莓派进阶之路 (009) - 树莓派ftp脚本(原创)

    FTP.sh #!/bin/sh cd echo "彻底卸载原有的ftp" sudo apt-get remove --purge vsftpd #(--purge 选项表示彻底删 ...

  6. Fedora 20 安装搜狗拼音输入法

    1.卸载ibus sudo yum remove ibus    gsettings set org.gnome.settings-daemon.plugins.keyboard active fal ...

  7. 使用 WM_COPYDATA 在进程间共享数据

    开发中有时需要进程间传递数据,比如对于只允许单实例运行的程序,当已有实例运行时,再次打开程序,可能需要向当前运行的实例传递信息进行特殊处理.对于传递少量数据的情况,最简单的就是用SendMessage ...

  8. PHP中数字检测is_numeric与ctype_digit的区别介绍

    PHP中的两个函数is_numeric和ctype_digit都是检测字符串是否是数字,但也存在一点区别 is_numeric:检测是否为数字字符串,可为负数和小数 ctype_digit:检测字符串 ...

  9. sublime 技巧与快捷键篇

    技巧大全:https://www.zhihu.com/question/24896283   项目排除文件夹,更便于ctrl + p的搜索,比如可恶的node_modules "folder ...

  10. 精确光源(Punctual Light Sources)

    <Physically-Based Shading Models in Film and Game Production>(SIGGRAPH 2010 Course Notes) (地址: ...