准备安装软件

[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. Linux-TCP 出现 RST 的几种情况

    导致“Connection reset”的原因是服务器端因为某种原因关闭了Connection,而客户端依然在读写数据,此时服务器会返回复位标志“RST”,然后此时客户端就会提示“java.net.S ...

  2. ios实例开发精品文章推荐(7.22)

    UIView 基本方法 UIView的一些基本方法理解:loadView.viewDidLoad.viewDidUnload.viewWillAppear,viewWillDisappear init ...

  3. [转] mysql --prompt介绍

    mysql --prompt修改命令行链接mysql时的提示符,shell脚本示例如下 #!/bin/bash case $1 in crm) cmd='mysql -h192.168.1.2 -ur ...

  4. 【Android】详解Android动画

    目录结构: contents structure [+] 补间动画 使用java代码实现Alpha.Rotate.Scale.Translate动画 通过xml文件实现Alpha.Rotate.Sca ...

  5. VS2017 IDE开发工具选型、安装和使用

    原文地址:https://blog.csdn.net/boonya/article/details/78739500 距离上次使用VS工具已是2年前了,这次准备选择比较新的版本来开发桌面程序了.总的来 ...

  6. Android中3种全屏方法及3种去掉标题栏的方法

    一.去掉标题栏的方法 第一种:入门的时候经常使用的一种方法 复制代码代码如下:  requestWindowFeature(Window.FEATURE_NO_TITLE); //去掉标题栏注意这句一 ...

  7. HANA初印象

    今天手懒,看了一些SAP HANA 的一些外文介绍,不翻译了,直接剽窃过来,供参考. 1. HANA 是什么东西? “HANA doesn't actually mean anything, but ...

  8. 第二篇:呈现内容_第三节:CompositeControl呈现

    一.CompositeControl的呈现过程 CompositeControl派生自WebControls,重写了Render(HtmlTextWriter writer)方法.在调用基类WebCo ...

  9. SQLServer2005 CASE WHEN在项目中实例-查询显示值替换

    1.利用SqlServer中的case when来把数据查询出来的数据替换成其它值显示 2.结果对比: 普通select查询出来的结果如下: 用了case when方法后显示结果如下: 3.具体使用代 ...

  10. jQueryWEUI自定义对话框-带有textarea

    jQueryWEUI  示例下载 在jQueryWEUI中提供了很多类型的对话框, 可以去访问看一下. 今天记录的则是,自己定义的一个带有文本域的对话框,这样,可以不通过调转页面,实现一些信息的提交. ...