准备安装软件

[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. 使用u盘安装os x系统

    从 App Store 下载 OS X 安装器 请执行以下步骤下载要安装的 OS X 版本. 1. 从 Apple 菜单中,选取“App Store”. 2. 按住 Option 键并点按“已购项目” ...

  2. Nginx自定义404页面

    指定一个错误页面: error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } 指定一个url地址: ...

  3. (原)torch中提示Unwritable object <userdata> at <?>.callback.self.XXX.threads.__gc__

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6549432.html 参考网址: https://github.com/torch/threads/i ...

  4. Tensorflow异常集锦

    一.tensorflow checkpoint报错 在调用tf.train.Saver#save时,如果使用的路径是绝对路径,那么保存的checkpoint里面用的就是绝对路径:如果使用的是相对路径, ...

  5. linux运维常见英文报错中文翻译(菜鸟必知)

    linux常见英文报错中文翻译(菜鸟必知) 1.command not found  命令没有找到 2.No such file or directory  没有这个文件或目录 3.Permissio ...

  6. IT软件外包行业深入分析:现状、前途、趋势、待遇 什么是软件外包 外包公司是怎么工作的 软件外包公司的面试 软件外包公司需要什么样的人

    目录: [0] - 为什么要对大学生谈软件外包? [1] - 什么是软件外包? [2] - 软件为什么要外包? [3] - 为什么要承接软件外包 [4] - 做软件外包有前途吗? [5] - 外包公司 ...

  7. YAML中重复的KEY的判断

    package com.test.util; import java.io.BufferedReader; import java.io.FileInputStream; import java.io ...

  8. android 获取view在屏幕中的位置

    使用view中的getLocationOnScreen方法,即可: final int[] locations = new int[2]; Button btn = (Button) findView ...

  9. 安装gitlab遇到的问题

    参考文章: http://www.pickysysadmin.ca/2013/03/25/how-to-install-gitlab-5-0-on-centos-6/ 一直跟着这篇文章做,还挺顺利的, ...

  10. 章节1:SQL语言简易入门

    一.增.删.改.查 1.增(向表格中插入数据): INSERT INTO tb_TableName(ColumnName1,ColumnName2) VALUES(ColumnValue1,Colum ...