lvs+keepalived+mariadb集群
1、环境准备
节点1:172.16.2.95
节点2:172.16.2.160
节点3:172.16.2.220
LVS1:172.16.2.67
LVS2:172.16.2.234
2、mariadb集群的安装
https://www.cnblogs.com/linyouyi/p/11515639.html
3、在三台安装mariadb机器操作
echo > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo > /proc/sys/net/ipv4/conf/lo/arp_announce
echo > /proc/sys/net/ipv4/conf/all/arp_ignore
echo > /proc/sys/net/ipv4/conf/all/arp_announce
ifconfig lo: 172.16.2.253 broadcast 172.16.2.253 netmask 255.255.255.255 up
#ifconfig lo: 172.16.2.253 netmask 255.255.255.255 up
route add -host 172.16.2.253 lo:
3.1、查看虚拟ip
//01
[root@hadoop01 linyouyi]# ip addr show lo
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN group default qlen
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
valid_lft forever preferred_lft forever
inet 172.16.2.253/ brd 172.16.2.253 scope global lo:
valid_lft forever preferred_lft forever
inet6 ::/ scope host
valid_lft forever preferred_lft forever
[root@hadoop01 linyouyi]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.2.1 0.0.0.0 UG eth0
0.0.0.0 172.16.2.1 0.0.0.0 UG eth0
169.254.169.254 172.16.2.1 255.255.255.255 UGH eth0
172.16.2.0 0.0.0.0 255.255.255.0 U eth0
172.16.2.253 0.0.0.0 255.255.255.255 UH lo
172.17.0.0 0.0.0.0 255.255.0.0 U docker0
//02
[root@hadoop02 mariadb]# ip addr show lo
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN qlen
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
valid_lft forever preferred_lft forever
inet 172.16.2.253/ brd 172.16.2.253 scope global lo:
valid_lft forever preferred_lft forever
inet6 ::/ scope host
valid_lft forever preferred_lft forever
[root@hadoop02 mariadb]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.2.1 0.0.0.0 UG eth0
169.254.169.254 172.16.2.1 255.255.255.255 UGH eth0
172.16.2.0 0.0.0.0 255.255.255.0 U eth0
172.16.2.253 0.0.0.0 255.255.255.255 UH lo
172.17.0.0 0.0.0.0 255.255.0.0 U docker0
//03
[root@hadoop03 mariadb]# ip addr show lo
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN qlen
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
valid_lft forever preferred_lft forever
inet 172.16.2.253/ brd 172.16.2.253 scope global lo:
valid_lft forever preferred_lft forever
inet6 ::/ scope host
valid_lft forever preferred_lft forever
[root@hadoop03 mariadb]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.2.1 0.0.0.0 UG eth0
169.254.169.254 172.16.2.1 255.255.255.255 UGH eth0
172.16.2.0 0.0.0.0 255.255.255.0 U eth0
172.16.2.253 0.0.0.0 255.255.255.255 UH lo
172.17.0.0 0.0.0.0 255.255.0.0 U docker0
4、LVS1安装keepalived-1.3.5和ipvsadm-1.27
[root@LVS1 ~]# yum -y install keepalived ipvsadm
[root@LVS1 ~]# cd /etc/keepalived
[root@LVS1 keepalived]# cp keepalived.conf keepalived.conf.bak
[root@LVS1 keepalived]# vim keepalived.conf
global_defs {
notification_email {
admin@linyouyi.com
}
notification_email_from ka@localhost
smtp_server 127.0.0.1
smtp_connect_timeout
router_id lvs1
} vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id
priority
advert_int
authentication {
auth_type pass
auth_pass forlvs
}
virtual_ipaddress {
172.16.2.253
}
} virtual_server 172.16.2.253 {
delay_loop
lb_algo rr
lb_kind DR
nat_mask 255.255.255.255
persistence_timeout
protocol TCP
real_server 172.16.2.95 {
weight
TCP_CHECK {
connect_timeout
nb_get_retry
delay_before_retry
connect_port
}
}
real_server 172.16.2.220 {
weight
TCP_CHECK {
connect_timeout
nb_get_retry
delay_before_retry
connect_port
}
}
real_server 172.16.2.160 {
weight
TCP_CHECK {
connect_timeout
nb_get_retry
delay_before_retry
connect_port
}
}
} [root@LVS1 keepalived]# systemctl start keepalived
[root@LVS1 keepalived]# ipvsadm -Ln
IP Virtual Server version 1.2. (size=)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.16.2.253: rr persistent
-> 172.16.2.95: Route
-> 172.16.2.160: Route
-> 172.16.2.220: Route
// 但是其他的机器总是访问不了vip,不知道是云主机不能用keepalived虚拟ip还是啥原因,还没找到
4.1、测试
[root@LVS1 keepalived]# ip addr show eth0
: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP group default qlen
link/ether fa::3e:2f:b0:e0 brd ff:ff:ff:ff:ff:ff
inet 172.16.2.67/ brd 172.16.2.255 scope global dynamic eth0
valid_lft 85187sec preferred_lft 85187sec
inet 172.16.2.253/ scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe2f:b0e0/ scope link
valid_lft forever preferred_lft forever
//把数据库220的mariadb停掉
[root@LVS1 keepalived]# ipvsadm
IP Virtual Server version 1.2. (size=)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP cx--.novalocal:mysql rr persistent
-> 172.16.2.95:mysql Route
-> 172.16.2.160:mysql Route
5、LVS1安装keepalived-1.3.5和ipvsadm-1.27
[root@LVS2 keepalived]# vim keepalived.conf
global_defs { router_id lvs2
} vrrp_instance VI_1 {
state BACKUP priority } }
//配置文件这几项改一下,其余的步骤和LVS1一样
5.1、测试LVS高可用
把LVS1的keepalived停掉,看VIP会不会自动移动到LVS2
[root@LVS1 keepalived]# systemctl stop keepalived [root@LVS2 ~]# ip addr show eth0
: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP group default qlen
link/ether fa::3e:a3:: brd ff:ff:ff:ff:ff:ff
inet 172.16.2.234/ brd 172.16.2.255 scope global dynamic eth0
valid_lft 62412sec preferred_lft 62412sec
inet 172.16.2.253/ scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fea3:/ scope link
valid_lft forever preferred_lft forever
[root@LVS2 ~]# ipvsadm
IP Virtual Server version 1.2. (size=)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP cx--.novalocal:mysql rr persistent
-> 172.16.2.95:mysql Route
-> 172.16.2.160:mysql Route
-> 172.16.2.220:mysql Route
但是其他的机器总是访问不了vip,不知道是云主机不能用keepalived虚拟ip还是啥原因,还没找到,似乎是云服务器的vip需要申请,跟服务商申请。反正就是云服务器跟虚拟机不一样
https://www.cnblogs.com/galengao/articles/7417520.html
//每台主机查一下arp,发现VIP的HWaddress都是incomplete,也就是无法获取mac硬件地址,所以不知道指向那台机器,因此无法ping通,无法访问
[root@cx-- ~]# arp -n
Address HWtype HWaddress Flags Mask Iface
172.16.2.1 ether fa::3e:3d:4d:a0 C eth0
10.42.2.0 (incomplete) flannel.
172.16.2.95 ether fa::3e:dc:a1:c6 C eth0
172.16.2.222 (incomplete) eth0
172.16.2.67 ether fa::3e:2f:b0:e0 C eth0
172.17.0.2 ether ::ac::: C docker0
10.42.1.0 (incomplete) flannel.
172.17.0.4 ether ::ac::: C docker0
172.16.2.254 ether fa::3e:de:bd:f9 C eth0
172.16.2.234 ether fa::3e:a3:: C eth0
172.16.2.253 (incomplete) eth0
172.17.0.3 ether ::ac::: C docker0
172.16.2.17 ether fa::3e:f3:5e:6f C eth0 //清空arp缓存依然不行
[root@LVS1 keepalived]# arp -n|awk '/^[1-9]/{system("arp -d "$1)}'
SIOCDARP(dontpub): Network is unreachable
SIOCDARP(dontpub): Network is unreachable
ipvsadm -lnc
lvs+keepalived+mariadb集群的更多相关文章
- 003.Keepalived搭建LVS高可用集群
一 基础环境 1.1 IP规划 OS:CentOS 6.8 64位 节点类型 IP规划 主机名 类型 主 Director Server eth0:172.24.8.10 DR1 公共IP eth1: ...
- HA(High available)-Keepalived高可用性集群(双机热备)单点实验-菜鸟入门级
HA(High available)-Keepalived高可用性集群 Keepalived 是一个基于VRRP虚拟路由冗余协议来实现的WEB 服务高可用方案,虚拟路由冗余协议 (Virtual ...
- 高性能Linux服务器 第11章 构建高可用的LVS负载均衡集群
高性能Linux服务器 第11章 构建高可用的LVS负载均衡集群 libnet软件包<-依赖-heartbeat(包含ldirectord插件(需要perl-MailTools的rpm包)) l ...
- 实现基于LVS负载均衡集群的电商网站架构
背景 上一期我们搭建了小米网站,随着业务的发展,网站的访问量越来越大,网站访问量已经从原来的1000QPS,变为3000QPS,网站已经不堪重负,响应缓慢,面对此场景,单纯靠单台LNMP的架构已经无法 ...
- 项目实战2—实现基于LVS负载均衡集群的电商网站架构
负载均衡集群企业级应用实战-LVS 实现基于LVS负载均衡集群的电商网站架构 背景:随着业务的发展,网站的访问量越来越大,网站访问量已经从原来的1000QPS,变为3000QPS,网站已经不堪重负,响 ...
- Linux Cluster 基础之LVS调度算法与集群类型
Linux Cluster 基础之LVS调度算法与集群类型 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.LB Cluster 1>.什么是LB LB 集群是 load ...
- 1-2、LVS之Linux集群系统基础
Linux Cluster: 为了满足同一目的的需要,将多台主机组织起来解决统一问题的计算机的集合叫集群 Web Arch 虚拟化和云计算 自动化运维工具:ansible, puppet, zabbi ...
- LVS之2---基于LVS负载均衡集群架构
LVS之2---基于LVS负载均衡集群架构实现 目录 LVS之2---基于LVS负载均衡集群架构实现 ipvsadm software package Options 常用命令 保存及重载规则 内存映 ...
- 负载均衡的mariadb集群搭建
集群介绍: Galera是一个MySQL(也支持MariaDB,Percona)的同步多主集群软件,目前只支持InnoDB引擎. 主要功能: 同步复制 真正的multi-master,即所有节点可以同 ...
随机推荐
- datagrid+toolbar 不分页 显示
1 新建DataGrid.js文件 /*** * * *el: table id * ***/ function showDataGrid(el) { $(el).datagrid({ title: ...
- c++11 委派构造函数
委派构造函数可以减少构造函数的书写量: class Info { public: Info() : type(), name('a') { InitRest(); } Info(int i) : ty ...
- 微信小程序点击顶部导航栏切换样式
类似这样的效果 <view class='helpCateList'> <!-- 类别 --> <scroll-view class='scroll-view' scro ...
- 【Flutter学习】页面跳转之路由及导航
一,概述 移动应用通常通过成为‘屏幕’或者‘页面’的全屏元素显示其内容,在Flutter中,这些元素统称为路由,它们由导航器Navigator组件管理.导航器管理一组路由Route对象,并提供了管理堆 ...
- sql server 基础语法4 实践练习+子查询
drop table class create table class ( classId ) primary key not null, cName ) ) insert into class ', ...
- python random模块随机取list中的某个值
import random from random import randint ''' random.randint()随机生一个整数int类型,可以指定这个整数的范围,同样有上限和下限值,pyth ...
- 62、saleforce的schedule
//需要实现 Schedulable接口,实现 execute方法 public class MerchandiseSchedule implements Schedulable{ public vo ...
- Java中vector用法整理
ArrayList会比Vector快,他是非同步的,如果设计涉及到多线程,还是用Vector比较好一些 import java.util.*; /** * 演示Vector的使用.包括Vector的创 ...
- upc组队赛3 T-net【贪心】
T-net 题目描述 T-net which is a new telecommunications company, plans to install its base stations in th ...
- 20140922 tcpip3次握手 分段 分页 spooling 位示图
tcpip3次握手 http://www.cnblogs.com/CBDoctor/archive/2012/10/17/2727073.html 操作系统:http://blog.csdn.ne ...