过程问题:

make: gcc:命令未找到

解决:

yum -y install gcc

一、环境和版本:

Linux环境:CentOS 7.6

libfastcommon版本:1.0.39

FastDFS版本:V5.11

fastdfs-nginx-module版本:V1.2

nginx版本:1.12.2

二、搭建步骤:

1、搭建FastDFS集群

(1)环境准备(在两台服务器上分别操作)

yum -y install pcre pcre-devel

yum install -y zlib-devel

mkdir -p /opt/fastdfs /data/fastdfs/tracker /data/fastdfs/storage /data/fastdfs/client /data/fastdfs/file

为下一步下载源码做准备

cd /opt/fastdfs

(2)安装libfastcommon(在两台服务器上分别操作)

wget https://github.com/happyfish100/libfastcommon/archive/V1.0.39.tar.gz

tar -zxvf V1.0.39.tar.gz

cd libfastcommon-1.0.39/

./make.sh

./make.sh install

(3)安装FastDFS(在两台服务器上分别操作)

cd /opt/fastdfs

wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz

tar -zxvf V5.11.tar.gz

\cd fastdfs-5.11/

./make.sh

./make.sh install

配置文件准备

cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf 	#tracker节点

cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf 	#storage节点

cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf	 #客户端文件,测试用

cp /opt/fastdfs/fastdfs-5.11/conf/http.conf /etc/fdfs/ 	#供nginx访问使用

cp /opt/fastdfs/fastdfs-5.11/conf/mime.types /etc/fdfs/ 	#供nginx访问使用

(4)tracker server配置:

vim /etc/fdfs/tracker.conf
需要修改的内容如下

port=22122 # tracker服务器端口(默认22122,一般不修改)

base_path=/data/fastdfs/tracker # 存储日志和数据的根目录

启动服务

service fdfs_trackerd start

查看服务状态, 查看服务是否启动,端口是否打开

netstat -tulnp

(5)storage server配置:

vim /etc/fdfs/storage.conf

需要修改的内容如下

port=23000 # storage服务端口(默认23000,一般不修改)

base_path=/data/fastdfs/storage # 数据和日志文件存储根目录

store_path0=/data/fastdfs/file # 第一个存储目录

tracker_server=172.18.183.5:22122 # tracker服务器IP和端口

tracker_server=172.18.183.8:22122 # tracker服务器IP和端口

http.server_port=8888 # http访问文件的端口(默认8888,看情况修改,和nginx中保持一致)

启动服务

service fdfs_storaged start

查看服务是否启动,端口是否打开

netstat -tulnp
firewall-cmd --permanent --add-port=22122/tcp
firewall-cmd --permanent --add-port=23000/tcp
firewall-cmd --reload

查看日志

journalctl -xe

查看集群状态

fdfs_monitor /etc/fdfs/storage.conf list
storage server有7个状态,如下:
FDFS_STORAGE_STATUS_INIT :初始化,尚未得到同步已有数据的源服务器
FDFS_STORAGE_STATUS_WAIT_SYNC :等待同步,已得到同步已有数据的源服务器
FDFS_STORAGE_STATUS_SYNCING :同步中
FDFS_STORAGE_STATUS_DELETED :已删除,该服务器从本组中摘除(注:本状态的功能尚未实现)
FDFS_STORAGE_STATUS_OFFLINE :离线
FDFS_STORAGE_STATUS_ONLINE :在线,尚不能提供服务
FDFS_STORAGE_STATUS_ACTIVE :在线,可以提供服务
当storage server的状态为 FDFS_STORAGE_STATUS_ONLINE 时,当该storage server向tracker server发起一次heart beat时,tracker server将其状态更改为 FDFS_STORAGE_STATUS_ACTIVE

(6)Client配置:

vim /etc/fdfs/client.conf

需要修改的内容如下

base_path=/data/fastdfs/client

tracker_server=172.18.183.5:22122 # tracker服务器IP和端口

tracker_server=172.18.183.8:22122 # tracker服务器IP和端口

保存后测试,随便上传一张图片到服务器,然后在该目录下执行以下命令返回ID表示成功

fdfs_upload_file /etc/fdfs/client.conf halo.jpg

返回值如下

group1/M00/00/00/rBK3BV58iTKABs-cABYoCsMn6JA740.jpg

(7)安装nginx和fastdfs-nginx-module(在两台服务器上分别操作)

#下载nginx module
cd /opt/fastdfs/
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz
tar -zxvf V1.20.tar.gz
cp /opt/fastdfs/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf /etc/fdfs
#编辑 fastdfs-n/ginx-module-1.20/src/config 文件
vim /opt/fastdfs/fastdfs-nginx-module-1.20/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/local/include/fastdfs /usr/include/fastcommon"
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/local/include/fastdfs /usr/include/fastcommon"
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

安装nginx,并且添加nginx module

cd /opt/fastdfs/
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar -zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2/
./configure --prefix=/usr/local/nginx --add-module=/opt/fastdfs/fastdfs-nginx-module-1.20/src
make && make install

配置nginx访问

vim /etc/fdfs/mod_fastdfs.conf
connect_timeout=10

base_path=/data/fastdfs/file

tracker_server=172.18.183.5:22122 # tracker服务器IP和端口

tracker_server=172.18.183.8:22122 #tracker服务器IP2和端口

group_name=group1         #当前服务器的group名

url_have_group_name=true #url中包含group名称

store_path0=/data/fastdfs/file #存储路径

配置nginx.config

vim /usr/local/nginx/conf/nginx.conf

增加或者修改如下内容

worker_processes  4;
worker_cpu_affinity 1000 0100 0010 0001;
error_log logs/error.log; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; sendfile on;
keepalive_timeout 65; server {
listen 8888;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location ~/group([0-9])/M00 {
ngx_fastdfs_module;
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}

测试下载,用外部浏览器访问刚才已传过的文件。

http://172.18.183.5:8888/group1/M00/00/00/rBK3BV58iTKABs-cABYoCsMn6JA740.jpg

http://172.18.183.8:8888/group1/M00/00/00/rBK3BV58iTKABs-cABYoCsMn6JA740.jpg

Linux安装fastdfs集群部署的更多相关文章

  1. FastDFS集群部署

    之前介绍过关于FastDFS单机部署,详见博文:FastDFS+Nginx(单点部署)事例 下面来玩下FastDFS集群部署,实现高可用(HA) 服务器规划: 跟踪服务器1[主机](Tracker S ...

  2. FastDFS集群部署(转载 写的比较好)

    FastDFS集群部署   之前介绍过关于FastDFS单机部署,详见博文:FastDFS+Nginx(单点部署)事例 下面来玩下FastDFS集群部署,实现高可用(HA) 服务器规划: 跟踪服务器1 ...

  3. 初识zookeeper以及安装和集群部署

    初识zookeeper以及安装和集群部署     一.Zookeeper单体版安装     在安装zookeeper之前要先安装jdk环境,具体在linux环境安装jdk1.8请参照linux笔记. ...

  4. (1)Consul在linux环境的集群部署

    1.Consul概念 1.1什么是Consul? Consul是一种服务网格解决方案,是HashiCorp公司推出的开源组件,由Go语言开发,部署起来很容易,只需要极少的可执行程序和配置.同时Cons ...

  5. 关于Linux单机、集群部署FastDFS分布式文件系统的步骤。

    集群部署:2台tarcker服务器,2台storage服务器. 192.168.201.86   ---------(trackerd+storage+nginx) 192.168.201.87   ...

  6. 分布式FastDFS集群部署

    FastDFS FastDFS的作者余庆在其 GitHub 上是这样描述的:"FastDFS is an open source high performance distributed f ...

  7. Fastdfs集群部署以及基本操作

    FastDFS引言 本地存储与分布式文件系统 本地存储的缺点: 是否有备份? 没有 成本角度? 贵 ​ 服务器 :用于计算 ---- cpu/内存 ​ 用于存储 ---- 硬盘大 存储瓶颈? 容量有限 ...

  8. redis CentOS6.5安装及集群部署

    .下载redis source包 链接:https://pan.baidu.com/s/122ZCjNvjl9Jx6M2YsLrncw 密码:92ze 2.解压 tar -xzf redis-3.2. ...

  9. Spark学习笔记--Linux安装Spark集群详解

    本文主要讲解如何在Linux环境下安装Spark集群,安装之前我们需要Linux已经安装了JDK和Scala,因为Spark集群依赖这些.下面就如何安装Spark进行讲解说明. 一.安装环境 操作系统 ...

随机推荐

  1. ASP.NET和ASP.NETCore多环境配置对比

    前言 多环境配置应该都很熟悉了,最为常见的便是Debug和Release,例如下图是新建的一个asp.net项目,配置文件展开共有三个文件组成 据我所知,大多公司从来没编辑过Web.Debug.con ...

  2. go-micro使用Consul做服务发现的方法和原理

    go-micro v4默认使用mdns做服务发现.不过也支持采用其它的服务发现中间件,因为多年来一直使用Consul做服务发现,为了方便和其它服务集成,所以还是选择了Consul.这篇文章将介绍go- ...

  3. [AcWing 35] 反转链表

    迭代版本 点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next ...

  4. SpringBoot详解

    1.Hello,World! 1.1.SpringBoot简介 回顾什么是Spring Spring是一个开源框架,2003 年兴起的一个轻量级的Java 开发框架,作者:Rod Johnson . ...

  5. css盒子模型简析

    盒子模型分为标准盒子模型和怪异的盒子模型 1.标准的盒模型 (content-box) 你设置的宽和高(width/height)是内容的部分宽高,所以盒子的实际宽度=内容的宽高+boder+padd ...

  6. Docker中Nginx,部署Tomcat,部署es + kibana,Docker的可视化,Commit镜像

    docker安装使用Nginx # 搜索信息 docker search nginx # 下载镜像 docker pull nginx # 运行测试 # --name给容器命名 # -p 宿主机端口: ...

  7. vue - Vue中的ajax

    只有在ajax才能找回一点点主场了,vue中的ajax一天整完,内容还行,主要是对axios的运用. 明天按理说要开始vuex了,这个从来都是只耳闻没有眼见过,明天来看看看看是个什么神奇的东西. 一. ...

  8. sqlserver limit

    select Loaction.Lat,Loaction.Long from Company order by CompanyId OFFSET 4 ROWS FETCH NEXT 2 ROWS ON ...

  9. Linux常用命令(超详细)

    一.基本命令 1.1 关机和重启 关机 shutdown -h now 立刻关机 shutdown -h 5 5分钟后关机 poweroff 立刻关机 重启 shutdown -r now 立刻重启 ...

  10. OpenHarmony3.1 Release版本特性解析——硬件资源池化架构介绍

    李刚 OpenHarmony 分布式硬件管理 SIG 成员 华为技术有限公司分布式硬件专家 OpenHarmony 作为面向全场景.全连接.全智能时代的分布式操作系统,通过将各类不同终端设备的能力进行 ...