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访问方式: 没看我上篇博客的小伙伴,最好先去瞅 ...
随机推荐
- kvm/qemu虚拟机桥接网络创建与配置
首先阐述一下kvm与qemu的关系,kvm是修改过的qemu,而且使用了硬件支持的仿真,仿真速度比QEMU快. 配置kvm/qemu的网络有两种方法.其一,默认方式为用户模式网络(Usermode N ...
- CentOS 6 安装python3.6
参考博客:https://www.cnblogs.com/xiaodangshan/p/7197563.html 安装过程比较简单,需要注意,安装之后,为了不影响系统自带的python2.6版本,需要 ...
- jfinal如何查看post还是get请求?
jfinal如何查看post还是get请求? controller里面getRequest().getMethod()就行了. 值为 'GET' 或者 'POST'
- Qt Package Project 打包发布程序
在Qt项目开发完成后,我们想将项目打包发布成一个可执行文件,需要做如下步骤: 首先,将项目中的release文件中的可执行文件拷到一个新建的文件夹中,例如project.exe,用Qt自带的生成必备的 ...
- nginx配置虚拟主机之不同端口和不同IP地址
配置nginx虚拟主机不同端口和不同ip地址,和上编nginx基于域名配置虚拟主机博文类似,请先参考. zxl.com域名不同端口,配置文件内容如下: 1 2 3 4 5 6 7 8 9 10 11 ...
- <input type=file>上传唯一控件
值得注意的是:当一个表单里面包含这个上传元素的时候,表单的enctype必须指定为multipart/form-data,method必须指定为post,浏览器才会认识并正确执行.但是还有一点,浏览器 ...
- 编译支持opengl的opencv
opencv默认安装是不支持opengl的. 也就是如果调用一个支持opengl的窗口会报错,no opengl support ubuntu下安装opencv,支持opengl要在cmake的时候, ...
- codeforces 355C - Vasya and Robot
因为在允许的情况下,必然是左右手交替进行,这样不会增加多余的无谓的能量. 然后根据不同的分界点,肯定会产生左手或右手重复使用的情况,这是就要加上Qr/Ql * 次数. 一开始的想法,很直接,枚举每个分 ...
- is_link
'Symbolic Link' to File1 content containing path to File1'Hard Link' to File1 content containing Fi ...
- 2018/03/08 每日一学PHP 之 常量defind 和 const区别
常量defind 和 const区别 什么是常量? 如字面理解的,在脚本执行期间不可改变的的量. 定义一个常量应该注意的事项? 1:常量默认大小写敏感,错误的大小写不会被识别为常量. 2:常量只能是标 ...