keepalived实现web高可用集群

1、实验环境

两台CentOS-7.5虚拟机
web1:10.0.11.203
web2:10.0.11.204
VIP :10.0.11.210
web类型:nginx
客户端:自用笔记本(win10)

2、准备两台web服务器

1)web1网卡情况
[[email protected] ~]#
[[email protected] ~]# ip a

2)web2网卡情况
[[email protected] ~]#
[[email protected] ~]# ip a

3)安装nginx

web1端:
[[email protected] ~]#
[[email protected] ~]# yum install nginx
[[email protected] ~]# rpm -qa nginx
nginx-1.16.1-1.el7.x86_64
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# > /usr/share/nginx/html/index.html #清空默认网页
[[email protected] ~]# echo web1 > /usr/share/nginx/html/index.html #让网页显示web1
[[email protected] ~]# cat /usr/share/nginx/html/index.html
web1
[[email protected] ~]#
[[email protected] ~]# systemctl start nginx #启动nginx
[[email protected] ~]# systemctl enable nginx #设置nginx开机自启动
C:\Users\Administrator>curl 10.0.11.203

web2端:
[[email protected] ~]#
[[email protected] ~]# yum install nginx
[[email protected] ~]# rpm -qa nginx
nginx-1.16.1-1.el7.x86_64
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# > /usr/share/nginx/html/index.html
[[email protected] ~]# echo web2 > /usr/share/nginx/html/index.html
[[email protected] ~]# cat /usr/share/nginx/html/index.html
web2
[[email protected] ~]#
[[email protected] ~]# systemctl start nginx
[[email protected] ~]# systemctl enable nginx
C:\Users\Administrator>curl 10.0.11.204

4)安装keepalived
说明:两台web服务器都需要安装keepalived服务

web1端:
[[email protected] ~]#
[[email protected] ~]# yum install keepalived
[[email protected] ~]# rpm -qa keepalived
keepalived-1.3.5-16.el7.x86_64
[[email protected] ~]#

web2端:
[[email protected] ~]#
[[email protected] ~]# yum install keepalived
[[email protected] ~]# rpm -qa keepalived
keepalived-1.3.5-16.el7.x86_64
[[email protected] ~]#

5)配置两台keepalived并启动

web1端:
[[email protected] ~]#
[[email protected] ~]# > /etc/keepalived/keepalived.conf #清空原来的配置
[[email protected] ~]# vim /etc/keepalived/keepalived.conf #编辑配置文件,自定义keepalived配置文件
[[email protected] ~]# cat /etc/keepalived/keepalived.conf

[[email protected] ~]#
[[email protected] ~]# systemctl start keepalived #启动
[[email protected] ~]# systemctl enable keepalived #设置开机启动

web2端:
[[email protected] ~]#
[[email protected] ~]# > /etc/keepalived/keepalived.conf
[[email protected] ~]# vim /etc/keepalived/keepalived.conf
[[email protected] ~]# cat /etc/keepalived/keepalived.conf

[[email protected] ~]#
[[email protected] ~]# systemctl start keepalived #启动
[[email protected] ~]# systemctl enable keepalived #设置开机启动

3、测试访问
方法:用客户端通过VIP测试访问web

C:\Users\Administrator>curl 10.0.11.210 #个人笔记本通过VIP测试访问web

拔掉web1服务器的网线,用客户端通过VIP测试访问web:
C:\Users\Administrator>curl 10.0.11.210

再次将web1服务器的网线接好,用客户端通过VIP测试访问web:
C:\Users\Administrator>curl 10.0.11.210

4、实验结论:
利用keepalived成功实现了web服务器集群的高可用

原文地址:https://blog.51cto.com/14783377/2486373

时间: 2024-10-29 19:07:38

keepalived实现web高可用集群的相关文章

keepalived + nginx 实现高可用集群方案

keepalived + nginx 实现高可用集群方案 一.使用场景介绍: nginx做负载均衡,来达到分发请求的目的,但是不能很好的避免单点故障,假如nginx服务器挂点了,那么所有的服务也会跟着瘫痪 .keepalived+nginx,就能很好的解决这一问题. 二.原理介绍: Keepalived 是一种高性能的服务器高可用或热备解决方案,Keepalived 可以用来防止服务器单点故 障的发生,通过配合 Nginx 可以实现 web 前端服务的高可用. Keepalived 以 VRRP

LVS+Keepalived+Nginx+Tomcat高可用集群搭建(转)

LVS+Keepalived+Nginx+Tomcat高可用集群搭建 最近公司重整架构,十几台服务器而且还要尽可能节约成本.我就谷歌了一下在几种集群之前进行比较最终采用了Keepalived+Nginx做负债均衡高可用.虽然之前也研究过集群,看过很多集群方面的原理和架构,但毕竟没有真正操作过以下案例是在虚拟机中完成实验其实对于高可用搭建来说只用给出Keepalived和Nginx的配置即可后面的一些安装搭建完全是本人项目需要可以不用理睬仅供参考. 本文只是实验搭建记录方便以后在服务器中实施搭建.

MM(主主数据库)+keepalived主备高可用集群

博客分享的第一篇技术文章: 项目主要搭建:主主数据库高可用集群搭建. 数据库互为主备,应用技术:MM+keepalived 使用的是虚拟机搭建的实验向大家展示: 数据库1:192.168.4.7 数据库2:192.168.4.77 VIP:192.168.4.68 web1:192.168.4.69 web2:192.168.4.70 一.安装mysql,部署主主同步结构. 直接yum安装 配置主主同步: 由于主数据库192.168.4.7里面存放着数据,所以需要先导出数据,方法很多,我们采取m

通过keepalived搭建lvs高可用集群

1.配置keepalived Keepalived的配置仅需要一个配置文件即可完成对HA cluster和LVS服务节点监控,在通过Keepalived搭建高可用的LVS集群实例中,主.备Director Server都需要安装Keepalived软件,安装成功后,默认的配置文件路径(可以通过rpm -ql keepalived查看)是:/etc/keppalived/keeplived.conf.一个完整的keepalived的配置文件由3个部分组成,分别是全局定义部分.vrrp实例定义部分以

基于云端虚拟机的LVS/DR+Keepalived+nginx的高可用集群架构配置

最近,公司要我部署一个集群架构,选来选取还是选择了大家都很熟悉的基于DR的LVS+Keepalived做负载分发,然后使用轻量级的nginx做中间代理层,这里呢先暂时实现一个简单web应用功能,对于代理功能和后续的web层部署.数据层安排将择机更新! 首先看一下集群框架:   下面开始我们的集群搭建行程: 一.IP规划: 做一件事情需要想想怎么去做既简单又有条理,我们做项目也应该如此.所以这里一定先做一个简单的规划,对于你后续测试的时候出现不能分发的情况有所解决. 负载均衡层          

keepalived+Nginx实现高可用集群

keepalived安装Nginx安装 配置keepalived#修改配置vim /etc/keepalived/keepalived.conf #配置文件 ! Configuration File for keepalived global_defs { #从服务器最改一下这个 router_id node1 #表示运行keepalived服务器的一个标识.发邮件时显示在邮件主题的信息 } #监控服务.NGINX mysql等 vrrp_script chk_nginx { script "/

创建简单WEB高可用集群

环境介绍 node1:192.168.168.201 node2:192.168.168.202 1.配置主机名 [[email protected] ~]# vim /etc/sysconfig/network #编辑节点1主机名配置文件 #编辑 HOSTNAME=node1.linuxpanda.com [[email protected] ~]# hostname node1.linuxpanda.com #主机名立即生效 [[email protected] ~]# vim /etc/s

Nginx+Keepalived+Proxy_Cache 配置高可用集群和高速缓存

环境: CentOS release 6.5 x86_64    192.168.100.90 CentOS release 6.5 x86_64    192.168.100.91 在主备服务器上部署Nginx 下载 #wget http://nginx.org/download/nginx-1.6.3.tar.gz #  wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz 安装 # yum install gcc ope

linux企业常用服务---haproxy+nginx搭建web高可用集群

部署前准备: iptables和selinux没配置,关掉 挂载系统镜像作为本地yum源,修改yum文件 源码包准备 nginx.1.6.0.tar.gz  haproxy-1.4.24.tar.gz 实验环境描述: 两个nginx分别为192.168.100.110 and192.168.100.120 一个haproxy为192.168.100.160 1 .分别在110和120上搭建nginx yum -y install pcre-devel zlib-devel ##安装依赖包 use