FastDFS+nginx+keepalived集群搭建
安装环境
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集群搭建的更多相关文章
- FastDFS+Nginx+fastdfs-nginx-module集群搭建
一.实验环境说明 操作系统: Centos 6.6 x64 FastDFS 相关版本: fastdfs-5.05 fastdfs-nginx-module-v1.16 libfastcommon-v1 ...
- Centos7+nginx+keepalived集群及双主架构案例
目录简介 一.简介 二.部署nginx+keepalived 集群 三.部署nginx+keepalived双主架构 四.高可用之调用辅助脚本进行资源监控,并根据监控的结果状态实现动态调整 一.简介 ...
- tomcat+nginx+redis集群搭建并解决session共享问题。
1 集群搭建 https://www.cnblogs.com/yjq520/p/7685941.html 2 session共享 https://blog.csdn.net/tuesdayma/art ...
- Nginx+Keepalived 集群方案
1.Keepalived高可用软件 Keepalived软件起初是专为LVS负载均衡软件设计的,用来管理并监控LVS集群系统中各个服务节点的状态,后来又加入了可以实现高可用的VRRP功能.因此,kee ...
- 构建企业级Nginx+Keepalived集群架构
随着Nginx在国内的发展潮流,越来越多的互联网公司都在使用Nginx. Nginx高性能.稳定性成为IT人士青睐的http和反向代理服务器,今天我们来实战构建Nginx+Keepalived高可用架 ...
- 企业级Nginx+Keepalived集群实战(双主架构)
随着Nginx在国内的发展潮流,越来越多的互联网公司都在使用Nginx,Nginx高性能.稳定性成为IT人士青睐的HTTP和反向代理服务器.Nginx负载均衡一般位于整个网站架构的最前端或者中间层,如 ...
- FastDFS教程IV-文件服务器集群搭建
1.简介 本文主要介绍FastDFS文件服务器的集群搭建,在阅读本文之前,您需具备FastDFS文件服务器单节点安装,扩容,迁移等方面的知识.同时,您还需了解Keepalived,nginx方 ...
- 多puppetmaster,多ca,keepalived+haproxy(nginx)puppet集群搭建
多puppetmaster,多ca,keepalived+haproxy(nginx)puppet集群搭建 一.服务器详情 192.168.122.111 pm01.jq.com pm01 #(pup ...
- fastdfs集群版搭建(一)- storage集群搭建与统一入口访问
前言 接着上篇博客:详细的最新版fastdfs单机版搭建,今天来讲讲fastdfs的集群搭建,限于篇幅,今天先搭建stoarge集群,并实现统一的http访问方式: 没看我上篇博客的小伙伴,最好先去瞅 ...
随机推荐
- 微信公众号关联(小游戏 小程序 跳转 盒子 wx.navigateToMiniProgram)
参考: 公众号关联小程序 关联公众号 关联后,登录小游戏,可在设置-关联设置中看到关联的公众号 在小游戏中使用wx.navigateToMiniProgram wx.navigateToMiniPro ...
- [工具] Sublime Text 使用指南
http://bbs.it-home.org/thread-46291-1-1.html 摘要(Abstract) 更新记录 更正打开控制台的快捷键为Ctrl + ` 更正全局替换的快捷键为Ctrl ...
- Ubuntu 16.04系统下apt-get和dpkg区别
两者的区别是dpkg绕过apt包管理数据库对软件包进行操作,所以你用dpkg安装过的软件包用apt可以再安装一遍,系统不知道之前安装过了,将会覆盖之前dpkg的安装.1.dpkg是用来安装.deb文件 ...
- 有哪些sql优化工具
https://www.oschina.net/p/soar-xiaomi https://www.oschina.net/news/101034/xiaomi-opensource-soar SOA ...
- yii---模型的创建
在 model/ 路径新建 Test.php 模型 我们类的名称一定要与数据表的名称相同. 继承 yii\db\ActiveRecord 类: 在模型类中 声明 tableName() 指定表名 // ...
- Mongodb 副本集 数据同步简单测试
副本集的搭建,请见 CENTOS6.5 虚拟机MONGODB创建副本集 接下来将简单说明下副本集之间的数据同步. 1.首先,进入primary节点 MOGO_PATH/bin/mongo -por ...
- ztree学习---将默认勾选的展开
这里只给出前台页面上的代码,数据可以从后台获取,注意,在封装数据的时候,注意:Id(节点的id,可以是数字也可以是字符串) , pid(父亲节点的id) , name(节点名称)不能少 . html页 ...
- 把本地项目文件上传到github远程仓库的教程
参考廖雪峰的git教程:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 非常详 ...
- HDU 3038 - How Many Answers Are Wrong - [经典带权并查集]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3038 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
- oracle中动态SQL使用详细介绍
Oracle编译PL/SQL程序块分为两个种:通常静态SQL采用前一种编译方式,而动态SQL采用后一种编译方式,需要了解的朋友可以参考下 1.静态SQLSQL与动态SQL Oracle编译PL ...