lvs-dr实战

lvs-dr实现mysql负载均衡集群

1.配置lvs
DR配置:
[root@DR ~]# yum provides */bin/ipvsadm
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
No matches found
[root@DR ~]# yum provides *bin/ipvsadm
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
yei/filelists_db | 3.1 MB 00:00
ipvsadm-1.27-7.el7.x86_64 : Utility to administer the
: Linux Virtual Server
Repo : yei
Matched from:
Filename : /usr/sbin/ipvsadm
[root@DR ~]# yum -y install ipvsadm-1.27-7.el7.x86_64
[root@DR ~]# route add -host [root@DR ~]# 192.168.116.250/32 dev lo
[root@DR ~]# yum -y install net-tools
[root@DR ~]# ip addr add 192.168.116.250/32 dev lo
[root@DR ~]# yum provides *bin/rount
[root@DR ~]# ipvsadm -A -t 192.168.116.250:3306 -s wrr
[root@yeqixian ~]# ipvsadm -a -t 192.168.116.250:3306 -r 192.168.116.182:3306 -g
[root@yeqixian ~]# ipvsadm -a -t 192.168.116.250:3306 -r 192.168.116.181:3306 -g

[root@DR ~]# ipvsadm -Sn > /etc/sysconfig/ipvsadm
[root@DR ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.116.250:80 wrr
-> 192.168.116.181:80 Route 1 0 0
-> 192.168.116.182:80 Route 1 0 0

RS配置:
[root@RS1 ~]# vim /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
[root@RS1 ~]# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
[root@RS1 ~]# ip addr add 192.168.116.250/32 dev lo
[root@RS1 ~]# yum -y install net-tools
[root@RS1 ~]# route add -host 192.168.116.250/32 dev lo

[root@RS2 ~]# vim /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
[root@RS2 ~]# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
[root@RS2 ~]# ip addr add 192.168.116.250/32 dev lo
[root@RS2 ~]# yum -y install net-tools
[root@RS2 ~]# route add -host 192.168.116.250/32 dev lo

  1. 配置数据库

[root@yei ~]# yum -y install mariadb
[root@yei ~]# systemctl start mariadb

[root@yei ~]# mysql

MariaDB [(none)]> grant all on . to ‘root’@‘192.168.%.%’ identified by ‘123456’;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> create database yei;
Query OK, 1 row affected (0.00 sec)

[root@rs2 ~]# yum -y install mariadb
[root@rs2 ~]# systemctl start mariadb
[root@rs2 ~]# mysql

MariaDB [(none)]> grant all on . to ‘root’@‘192.168.%.%’ identified by ‘123456’;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> create database rs2;
Query OK, 1 row affected (0.00 sec)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值