安装环境

  nginx-1.6.2
  libfastcommon-master.zip
  FastDFS_v5.05.tar.gz(http://sourceforge.net/projects/fastdfs/files/)
  fastdfs-nginx-module_v1.16.tar.gz
  ngx_cache_purge-2.3.tar.gz(用于清除指定url的缓存)

  keepalived

  VM虚拟机redhat6.5-x64:192.168.1.201、192.168.1.202、192.168.1.203、192.168.1.204、
              192.168.1.201、192.168.1.202、192.168.1.203、192.168.1.204、
  Xshell4

部署方案

  

安装步骤

  步骤一:203、204、205、206、207、208安装FastDFS

  参考:https://www.cnblogs.com/cac2020/p/9534967.html

  步骤二:配置跟踪器(192.168.1.203 、192.168.1.204 节点)

  

    mkdir -p /fastdfs/tracker&& cp /etc/fdfs/tracker.conf.sample tracker.conf && vim /etc/fdfs/tracker.conf
修改内容:
base_path=/fastdfs/tracker
#关键点:轮询分配到各个group里
store_lookup=
启动:
/etc/init.d/fdfs_trackerd start

  步骤三:配置FastDFS存储(192.168.1.205-208)

  205、206作为group1 , 207、208作为group2

  

mkdir -p /fastdfs/storage && cp /etc/fdfs/storage.conf.sample storage.conf && vim /etc/fdfs/storage.conf
修改内容:
disabled=false
group_name=group1 #组名,第一组(、)为 group1 第二组(、)为 group2
port= #storage 端口号,同组的端口号必须相同
base_path=/fastdfs/storage
store_path_count= #存储路径个数 需要和 store_path 个数匹配
store_path0=/fastdfs/storage #设置存储路径
tracker_server=192.168.1.203: #tracker 服务器的 ip 和端口
tracker_server=192.168.1.204: #多个 tracker 直接添加多条记录
http.server_port= #设置 http 端口号
启动:
/etc/init.d/fdfs_storaged start

  到此为止我们的 FastDFS 集群环境已经搭建完成!!!!

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  步骤四:4个存储节点(205 206 207 208)整合Nginx

.安装整合包fastdfs-nginx-module_v1..tar.gz
tar -zxvf /usr/local/software/fastdfs-nginx-module_v1..tar.gz -C /usr/local/fast/
vim /usr/local/fast/fastdfs-nginx-module/src/config
修改内容:去掉第四行中的 local 文件层次 .安装Nginx 加载fastdfs-nginx-module模块
tar -zxvf /usr/local/software/nginx-1.6..tar.gz -C /usr/local
cd /usr/local/nginx-1.6. && ./configure --add-module=/usr/local/fast/fastdfs-nginx-module/src/
重新编译命令: make && make install .修改整合模块配置
cp /usr/local/fast/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ && vim /etc/fdfs/mod_fastdfs.conf
修改内容:
注意:第一组(、)和第二组(、) 节点修改内容,只有组名不同
connect_timeout=
tracker_server=192.168.1.203:
tracker_server=192.168.1.204:
storage_server_port=
url_have_group_name = true
store_path0=/fastdfs/storage
group_name=group1 #第一组为 group1 第二组为 group2
group_count = #追加以下内容
[group1]
group_name=group1
storage_server_port=
store_path_count=
store_path0=/fastdfs/storage [group2]
group_name=group2
storage_server_port=
store_path_count=
store_path0=/fastdfs/storage
.复制配置文件
cd /usr/local/fast/FastDFS/conf/ && cp http.conf mime.types /etc/fdfs/
.创建软连接,在/fastdfs/storage 文件存储目录下创建软连接,将其链接到实际存放数据的目录。
命令: ln -s /fastdfs/storage/data/ /fastdfs/storage/data/M00
.修改 Nginx 配置文件4个节点
命令:vim usr/local/nginx.conf
修改内容:
listen ;
server_name localhost;
location ~/group([-])/M00 {
#alias /fastdfs/storage/data;
ngx_fastdfs_module;
}
启动4个节点Nginx: /usr/local/nginx/sbin/nginx

  步骤五:在2个跟踪器节点上安装nginx为4个存储节点提供负载均衡

.安装ngx_cache_purge-2.3.tar.gz(清除指定url的缓存)
tar -zxvf /usr/local/software/ngx_cache_purge-2.3.tar.gz –C /usr/local/fast/ .安装Nginx 加入 ngx_cache_purge (加入清除缓存模块)
tar -zxvf /usr/local/software/nginx-1.6..tar.gz -C /usr/local
cd /usr/local/nginx-1.6. && ./configure --add-module=/usr/local/fast/ngx_cache_purge-2.3/src/
重新编译命令: make && make install .修改nginx配置
vim /usr/local/nginx/conf/nginx.conf
修改内容:
events {
worker_connections ;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
keepalive_timeout ;
#设置缓存
server_names_hash_bucket_size ;
client_header_buffer_size 32k;
large_client_header_buffers 32k;
client_max_body_size 300m; proxy_redirect off;
proxy_set_header Host $http_host; proxy_set_header Cookie $http_cookie; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout ;
proxy_read_timeout ;
proxy_send_timeout ;
proxy_buffer_size 16k;
proxy_buffers 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
#设置缓存存储路径、存储方式、分配内存大小、磁盘最大空间、缓存期限
proxy_cache_path /fastdfs/cache/nginx/proxy_cache levels=:
keys_zone=http-chche:200m max_size=1g inactive=30d;
proxy_temp_path /fastdfs/cache/nginx/proxy_cache/tmp; # weight 权重 max_fails 失败重试次数 fail_timeout 连接失败超时时间
#设置 group1 的服务器
upstream fdfs_group1 {
server 192.168.1.205: weight= max_fails= fail_timeout=30s;
server 192.168.1.206: weight= max_fails= fail_timeout=30s;
} #设置 group2 的服务器
upstream fdfs_group2 {
server 192.168.1.207: weight= max_fails= fail_timeout=30s;
server 192.168.1.208: weight= max_fails= fail_timeout=30s;
} server {
listen ;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main; #设置 group 的负载均衡参数
location /group1/M00 {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache http-cache;
proxy_cache_valid 12h;
proxy_cache_key $uri$is_args$args;
proxy_pass http://fdfs_group1;
expires 30d;
} location /group2/M00 {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache http-cache;
proxy_cache_valid 12h;
proxy_cache_key $uri$is_args$args;
proxy_pass http://fdfs_group2;
expires 30d;
} #设置清除缓存的访问权限
location ~/purge(/.*) {
allow 127.0.0.1;
allow 192.168.1.0/;
deny all;
proxy_cache_purge http-cache $$is_args$args;
}
#error_page /.html;
# redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
}
} .按以上nginx 配置文件的要求,创建对应的缓存目录2个跟踪器节点都需要:
mkdir -p /fastdfs/cache/nginx/proxy_cache
mkdir -p /fastdfs/cache/nginx/proxy_cache/tmp
启动ngnix:/usr/local/nginx/sbin/nginx

  步骤六:201、202节点安装keepalived+nginx,对203、204提供负载均衡并对外外提供统一访问IP

.安装nginx
修改nginx配置
vim /usr/local/nginx/conf/nginx.conf
修改内容:
upstream fastdfs_tracker {
server 192.168.1.203: weight= max_fails= fail_timeout=30s;
server 192.168.1.204: weight= max_fails= fail_timeout=30s;
}
server {
listen ;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page /50x.html;
location = /50x.html {
root html;
} ## FastDFS Proxy 代理路径设置为 /fastdfs
location /fastdfs {
root html;
index index.html index.htm;
proxy_pass http://fastdfs_tracker/;
proxy_set_header Host $http_host;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 300m;
}
} .安装keepalived
修改keepalived配置
参考:https://www.cnblogs.com/cac2020/p/9528106.html

最后注意:千万不要使用 kill - 命令强杀 FastDFS 进程,否则可能会导致 binlog 数据丢失  

关闭集群步骤:
、 两台一级负载节点
关闭 keepalived 命令:service keepalived stop
关闭 nginx 命令:/usr/local/nginx/sbin/nginx –s stop 、 两台二级负载节点,跟踪器节点
关闭 nginx 命令:/usr/local/nginx/sbin/nginx –s stop
关闭 trackerd 跟踪器命令:/etc/init.d/fdfs_trackerd stop 、 四台三级负载节点,存储节点
关闭 nginx 命令:/usr/local/nginx/sbin/nginx –s stop
关闭 storage 存储器命令: /etc/init.d/fdfs_storaged stop
注意:千万不要使用 kill - 命令强杀 FastDFS 进程,否则可能会导致 binlog 数据丢失

参考手册:keepalived+nginx+fastdfs集群安装手册.pdf

FastDFS+nginx+keepalived集群搭建的更多相关文章

  1. FastDFS+Nginx+fastdfs-nginx-module集群搭建

    一.实验环境说明 操作系统: Centos 6.6 x64 FastDFS 相关版本: fastdfs-5.05 fastdfs-nginx-module-v1.16 libfastcommon-v1 ...

  2. Centos7+nginx+keepalived集群及双主架构案例

    目录简介 一.简介 二.部署nginx+keepalived 集群 三.部署nginx+keepalived双主架构 四.高可用之调用辅助脚本进行资源监控,并根据监控的结果状态实现动态调整 一.简介 ...

  3. tomcat+nginx+redis集群搭建并解决session共享问题。

    1 集群搭建 https://www.cnblogs.com/yjq520/p/7685941.html 2 session共享 https://blog.csdn.net/tuesdayma/art ...

  4. Nginx+Keepalived 集群方案

    1.Keepalived高可用软件 Keepalived软件起初是专为LVS负载均衡软件设计的,用来管理并监控LVS集群系统中各个服务节点的状态,后来又加入了可以实现高可用的VRRP功能.因此,kee ...

  5. 构建企业级Nginx+Keepalived集群架构

    随着Nginx在国内的发展潮流,越来越多的互联网公司都在使用Nginx. Nginx高性能.稳定性成为IT人士青睐的http和反向代理服务器,今天我们来实战构建Nginx+Keepalived高可用架 ...

  6. 企业级Nginx+Keepalived集群实战(双主架构)

    随着Nginx在国内的发展潮流,越来越多的互联网公司都在使用Nginx,Nginx高性能.稳定性成为IT人士青睐的HTTP和反向代理服务器.Nginx负载均衡一般位于整个网站架构的最前端或者中间层,如 ...

  7. FastDFS教程IV-文件服务器集群搭建

    1.简介     本文主要介绍FastDFS文件服务器的集群搭建,在阅读本文之前,您需具备FastDFS文件服务器单节点安装,扩容,迁移等方面的知识.同时,您还需了解Keepalived,nginx方 ...

  8. 多puppetmaster,多ca,keepalived+haproxy(nginx)puppet集群搭建

    多puppetmaster,多ca,keepalived+haproxy(nginx)puppet集群搭建 一.服务器详情 192.168.122.111 pm01.jq.com pm01 #(pup ...

  9. fastdfs集群版搭建(一)- storage集群搭建与统一入口访问

    前言 接着上篇博客:详细的最新版fastdfs单机版搭建,今天来讲讲fastdfs的集群搭建,限于篇幅,今天先搭建stoarge集群,并实现统一的http访问方式: 没看我上篇博客的小伙伴,最好先去瞅 ...

随机推荐

  1. 【BZOJ3328】PYXFIB 数论+矩阵乘法

    [BZOJ3328]PYXFIB Description Input 第一行一个正整数,表示数据组数据 ,接下来T行每行三个正整数N,K,P Output T行,每行输出一个整数,表示结果 Sampl ...

  2. Thinkphp框架下设置session的过期时间

    打开项目中的配置文件,添加session的过期配置,如下: 'SESSION_OPTIONS' => array( 'name' => 'BJYSESSION', //设置session名 ...

  3. js 字符中 带 函数 再传对象参数

    不替换 ( .replace(/\"/g, "\\\"") )则会有错误: Uncaught SyntaxError: missing ) after argu ...

  4. POJ 1149 - PIGS - [最大流构图]

    Time Limit: 1000MS Memory Limit: 10000K Description Mirko works on a pig farm that consists of M loc ...

  5. SQL Fundamentals: Basic SELECT statement基本的select语句(控制操作的现实列)(FROM-SELECT)

    SQL Fundamentals || Oracle SQL语言 Capabilities of the SELECT Statement(SELECT语句的功能) Data retrieval fr ...

  6. 《MYSQL必知必会》

    1. 同一个数据库中不允许出现同名表:不同的数据库中可以出现同名表2. 每一行记录都用有一个key(一列或一组列作为key)3. 作为key的列不允许值为空(NULL)4. 多个列作为key时,多个列 ...

  7. Numba:高性能Python编译器

    一.简介 Numba是一个开源JIT编译器,它将Python和NumPy代码的子集转换为快速机器代码. 二.主要特点 加速Python功能 Numba使用行业标准的LLVM编译器库在运行时将Pytho ...

  8. npm的用户名添加不上的原因

    npm添加不上的错误e401 1.用cnpm提交,会提交的tao.org这个域名了,用npm提交试试 2.如果npm提交不上,那就查看配置文件配置中 registry=http://registry. ...

  9. PHP生成zip压缩包

    /* * $res = new MakeZip($dir,$zipName); *@ $dir是被压缩的文件夹名称,可使用路径,例 'a'或者'a/test.txt'或者'test.txt' *@ $ ...

  10. 实习培训——Servlet(7)

    实习培训——Servlet(7) 1  Servlet 异常处理 当一个 Servlet 抛出一个异常时,Web 容器在使用了 exception-type 元素的 web.xml 中搜索与抛出异常类 ...