叢集-LVS-NAT,DR
阿新 • • 發佈:2020-11-13
目錄
LVS-DR模式搭建Mysql叢集
環境描述
- 關閉所有防火牆和selinux
主機 | 服務 | LVS角色 |
---|---|---|
vm5(192.168.225.134) | Load balancer | |
vm2(192.168.225.128) | mysql | real server |
vm4(192.168.225.131) | mysql | real server |
vm3(192.168.225.130) | NFS(vm2,vm4) | storage |
- vm3,vm2,vm4 uid,gid一致
[root@vm3 opt]# id mysql uid=888(mysql) gid=888(mysql) groups=888(mysql) [root@vm3 mysql_data]# vi /etc/exports /opt/mysql_data 192.168.225.0/24(rw,all_squash,anonuid=888,anongid=888)
-
Virtual IP:
設定為192.168.225.200(便於實踐,實際上因該為公網地址) -
NFS共享儲存搭建
vm2,vm4掛在共享目錄
- vm2
[root@vm2 opt]# cat >> /etc/fstab <<EOF > 192.168.225.130:/opt/mysql_data /opt/mysql_data/data nfs defaults,_netdev 0 0 > EOF [root@vm2 opt]# mount -a [root@vm2 opt]# df -hT Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 979M 0 979M 0% /dev tmpfs tmpfs 991M 0 991M 0% /dev/shm tmpfs tmpfs 991M 9.5M 981M 1% /run tmpfs tmpfs 991M 0 991M 0% /sys/fs/cgroup /dev/mapper/centos-root xfs 17G 5.7G 12G 34% / /dev/sda1 xfs 1014M 137M 878M 14% /boot tmpfs tmpfs 199M 0 199M 0% /run/user/0 192.168.225.130:/opt/mysql_data nfs4 17G 1.6G 16G 10% /opt/mysql_data/data
- vm4
[root@vm4 opt]# cat >> /etc/fstab <<EOF
> 192.168.225.130:/opt/mysql_data /opt/mysql_data/data nfs defaults,_netdev 0 0
> EOF
[root@vm4 opt]# mount -a
[root@vm4 opt]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 963M 0 963M 0% /dev
tmpfs tmpfs 981M 0 981M 0% /dev/shm
tmpfs tmpfs 981M 8.7M 972M 1% /run
tmpfs tmpfs 981M 0 981M 0% /sys/fs/cgroup
/dev/mapper/cl-root xfs 17G 5.9G 12G 35% /
/dev/sda1 ext4 976M 109M 800M 12% /boot
tmpfs tmpfs 197M 0 197M 0% /run/user/0
192.168.225.130:/opt/mysql_data nfs4 17G 1.6G 16G 10% /opt/mysql_data/data
部署資料庫
初始化資料庫
- 應為vm2,vm4共享mysql_data目錄,所以只用初始化一此
[root@vm2 share]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/mysql_data/data --explicit_defaults_for_timestamp
2020-11-09T06:34:22.191406Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-11-09T06:34:22.470740Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-11-09T06:34:22.560196Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 9a8fa408-2255-11eb-bfc3-000c29461984.
2020-11-09T06:34:22.570801Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-11-09T06:34:22.585675Z 1 [Note] A temporary password is generated for root@localhost: MOu-X-84/h*B
[root@vm2 data]# ll
total 110628
-rw-r----- 1 mysql mysql 56 Nov 11 2020 auto.cnf
-rw-r----- 1 mysql mysql 417 Nov 11 2020 ib_buffer_pool
-rw-r----- 1 mysql mysql 12582912 Nov 11 2020 ibdata1
-rw-r----- 1 mysql mysql 50331648 Nov 11 2020 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 Nov 11 2020 ib_logfile1
drwxr-x--- 2 mysql mysql 4096 Nov 11 2020 mysql
drwxr-x--- 2 mysql mysql 8192 Nov 11 2020 performance_schema
drwxr-x--- 2 mysql mysql 8192 Nov 11 2020 sys
[root@vm4 mysql_data]# ll data/
total 110628
-rw-r----- 1 mysql mysql 56 Nov 11 17:00 auto.cnf
-rw-r----- 1 mysql mysql 417 Nov 11 17:00 ib_buffer_pool
-rw-r----- 1 mysql mysql 12582912 Nov 11 17:00 ibdata1
-rw-r----- 1 mysql mysql 50331648 Nov 11 17:00 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 Nov 11 17:00 ib_logfile1
drwxr-x--- 2 mysql mysql 4096 Nov 11 17:00 mysql
drwxr-x--- 2 mysql mysql 8192 Nov 11 17:00 performance_schema
drwxr-x--- 2 mysql mysql 8192 Nov 11 17:00 sys
配置資料庫
- vm2,vm4
[myqld]
basedir=/usr/local/mysql
datadir=/opt/mysql_data/data
socket=/tmp/mysql.sock
port=3306
pid-file=/tmp/mysql.pid
user=mysql
skip-name-resolve
兩臺資料不能同時開啟mysql服務
[root@vm2 data]# service mysqld start
Starting MySQL.. SUCCESS!
[root@vm2 data]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:9000 *:*
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 80 [::]:3306 [::]:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
[root@vm2 data]#
[root@vm4 mysql_data]# service mysqld start
Starting MySQL..................................................................................................... ERROR! The server quit without updating PID file (/opt/mysql_data/data/vm4.pid).
2020-11-11T12:09:32.397689Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2020-11-11T12:09:33.400072Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2020-11-11T12:09:33.400137Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2020-11-11T12:09:33.400151Z 0 [Note] InnoDB: Unable to open the first data file
2020-11-11T12:09:33.401669Z 0 [ERROR] InnoDB: Operating system error number 11 in a file operation.
2020-11-11T12:09:33.401716Z 0 [ERROR] InnoDB: Error number 11 means 'Resource temporarily unavailable'
2020-11-11T12:09:33.401732Z 0 [Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html
授權測試機登入資料庫
mysql> grant all privileges on *.* to 'root'@'192.168.43.166' identified by '123456';
Query OK, 0 rows affected, 1 warning (2 min 50.81 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
LVS-DR實現mysql負載均衡
vm5安裝LVPS
[root@vm5 ~]# yum -y install ipvsadm
.............
Installed:
ipvsadm-1.31-1.el8.x86_64
Complete!
配置排程器IP地址
- 配置DIP,VIP
[root@vm5 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32
TYPE=Ethernet
BOOTPROTO=static
NAME=ens32
DEVICE=ens32
ONBOOT=yes
IPADDR0=192.168.225.134
NETMASK0=255.255.255.0
GATEWAY0=192.168.225.2
DNS1=192.168.225.2
IPADDR1=192.168.225.200
NETMASK1=255.255.255.0
[root@vm5 ~]# ifdown ens32;ifup ens32
Connection 'ens32' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[root@vm5 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:81:38:b9 brd ff:ff:ff:ff:ff:ff
inet 192.168.225.134/24 brd 192.168.225.255 scope global noprefixroute ens32
valid_lft forever preferred_lft forever
inet 192.168.225.200/24 brd 192.168.225.255 scope global secondary noprefixroute ens32
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe81:38b9/64 scope link
valid_lft forever preferred_lft forever
vm4配置RS的IP地址
- 配置VM4:RIP
[root@vm4 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR0=192.168.225.131
NETMASK0=255.255.225.0
GATEWAY0=192.168.225.2
DNS1=192.168.225.2
NAME=ens32
DEVICE=ens32
ONBOOT=yes
- 先修改arp配置
[root@vm4 ~]# vim /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.all.arp_announce=2
- 再配置VIP
[root@vm4 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR0=192.168.225.131
NETMASK0=255.255.225.0
GATEWAY0=192.168.225.2
DNS1=192.168.225.2
NAME=ens32
DEVICE=ens32
ONBOOT=yes
IPADDR1=192.168.225.200
NETMASK1=255.255.255.0
[root@vm4 ~]# ifdown ens33;ifup ens33
Connection 'ens33' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
[root@vm4 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:da:ad:a2 brd ff:ff:ff:ff:ff:ff
inet 192.168.225.131/24 brd 192.168.225.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.225.200/24 brd 192.168.225.255 scope global secondary noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::3d23:8838:5393:f99/64 scope link noprefixroute
valid_lft forever preferred_lft forever
- 配置路由資訊(由於VIP,RIP,DIP都是在用一網路,就不用配置)
vm2配置RS地址
- 修改arp配置
[root@vm2 ~]# vim /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.all.arp_announce=2
- 配置VIP,RIP
[root@vm2 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR0=192.168.225.128
NETMASK0=255.255.225.0
GATEWAY0=192.168.225.2
DNS1=192.168.225.2
NAME=ens32
DEVICE=ens32
ONBOOT=yes
IPADDR1=192.168.225.200
NETMASK1=255.255.255.0
[root@vm2 ~]# ifdown ens33;ifup ens33
Device 'ens33' successfully disconnected.
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
[root@vm2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:46:19:84 brd ff:ff:ff:ff:ff:ff
inet 192.168.225.128/24 brd 192.168.225.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.225.200/24 brd 192.168.225.255 scope global secondary noprefixroute ens33
valid_lft forever preferred_lft forever
在排程器上新增規則
[root@vm5 ~]# ipvsadm -A -t 192.168.225.200:3306 -s rr
[root@vm5 ~]# ipvsadm -a -t 192.168.225.200:3306 -r 192.168.225.128:3306 -g
[root@vm5 ~]# ipvsadm -a -t 192.168.225.200:3306 -r 192.168.225.131:3306 -g
[root@vm5 ~]# 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.225.200:3306 rr
-> 192.168.225.128:3306 Route 1 0 0
-> 192.168.225.131:3306 Route 1 0 0
[root@vm5 ~]# ipvsadm -Sn > /etc/sysconfig/ipvsadm
[root@vm5 ~]# cat /etc/sysconfig/ipvsadm
-A -t 192.168.225.200:3306 -s rr
-a -t 192.168.225.200:3306 -r 192.168.225.128:3306 -g -w 1
-a -t 192.168.225.200:3306 -r 192.168.225.131:3306 -g -w 1
[root@vm5 ~]#
LVS-NAT實現apache負載均衡
環境描述
- 關閉所有防火牆和selinux
主機 | 服務 | LVS角色 |
---|---|---|
vm5(192.168.225.134) | Load balancer | |
vm2(192.168.225.128) | httpd | real server |
vm4(192.168.225.131) | httpd | real server |
- VIP:192.168.225.200
搭建環境
vm2,vm4
[root@vm2 ~]# yum -y install httpd
[root@vm2 ssl]# yum -y install mod_ssl
[root@vm2 ~]# systemctl start httpd
[root@vm2 ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 [::]:80 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
[root@vm2 wisan]# pwd
/var/www/html/wisan
[root@vm2 wisan]# cat index.html
rs1
[root@vm2 wisan]# vi /etc/httpd/conf.d/vhost.conf
<VirtualHost *:80>
ServerName www.wisan.com
DocumentRoot "/var/www/html/wisan"
ErrorLog "/var/log/httpd/error_log"
CustomLog "/var/log/httpd/access_log" common
</VirtualHost>
~
- 生成證書
過程略
[root@vm2 ssl]# pwd
/etc/httpd/ssl
[root@vm2 ssl]# ls
httpd.crt httpd.csr httpd.key
- vm4過程與上面相似,vm2,vm4共用證書和金鑰
排程器vm5安裝ipvsadm
[root@vm5 ~]# yum -y install ipvsadm
配置ip地址
load balancer(vm5)
[root@vm5 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32
TYPE=Ethernet
BOOTPROTO=static
IPADDR0=192.168.225.134 ##DIP
NETMASK0=255.255.225.0
GATEWAY0=192.168.225.2
NAME=ens32
DEVICE=ens32
ONBOOT=yes
IPADDR1=192.168.225.200 ##VIP
NETMASK1=255.255.255.0
[root@vm5 ~]# ifdown ens32;ifup ens32
Connection 'ens32' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)
[root@vm5 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:81:38:b9 brd ff:ff:ff:ff:ff:ff
inet 192.168.225.134/24 brd 192.168.225.255 scope global noprefixroute ens32
valid_lft forever preferred_lft forever
inet 192.168.225.200/24 brd 192.168.225.255 scope global secondary noprefixroute ens32
valid_lft forever preferred_lft forever
real server(vm2,vm4)
- vm2
[root@vm2 ssl]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.225.128
NETMASK=255.255.255.0
GATEWAY=192.168.225.134
[root@vm2 ssl]# ifdown ens33;ifup ens33
Device 'ens33' successfully disconnected.
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[root@vm2 ssl]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:46:19:84 brd ff:ff:ff:ff:ff:ff
inet 192.168.225.128/24 brd 192.168.225.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
[root@vm2 ssl]# route -nv
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.225.134 0.0.0.0 UG 100 0 0 ens33
192.168.225.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
- vm4
[root@vm4 ssl]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.225.131
NETMASK=255.255.255.0
GATEWAY=192.168.225.134
[root@vm4 ssl]# ifdown ens33;ifup ens33
Connection 'ens33' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[root@vm4 ssl]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:da:ad:a2 brd ff:ff:ff:ff:ff:ff
inet 192.168.225.131/24 brd 192.168.225.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
[root@vm4 ssl]# route -nv
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.225.134 0.0.0.0 UG 100 0 0 ens33
192.168.225.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
開啟排程器ip轉發功能
[root@vm5 ~]# vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
[root@vm5 ~]# sysctl -p /etc/sysctl.conf
net.ipv4.ip_forward = 1
在排程器上新增規則
[root@vm5 ~]# ipvsadm -A -t 192.168.225.200:80 -s rr
[root@vm5 ~]# ipvsadm -a -t 192.168.225.200:80 -r 192.168.225.128:80 -m
[root@vm5 ~]# ipvsadm -a -t 192.168.225.200:80 -r 192.168.225.131:80 -m
[root@vm5 ~]# 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.225.200:80 rr
-> 192.168.225.128:80 Masq 1 0 0
-> 192.168.225.131:80 Masq 1 0 0
[root@vm5 ~]# ipvsadm -Sn > /etc/sysconfig/ipvsadm
[root@vm5 ~]# cat /etc/sysconfig/ipvsadm
-A -t 192.168.225.200:80 -s rr
-a -t 192.168.225.200:80 -r 192.168.225.128:80 -m -w 1
-a -t 192.168.225.200:80 -r 192.168.225.131:80 -m -w 1
[root@vm5 ~]# ipvsadm -A -t 192.168.225.200:443 -s rr
[root@vm5 ~]# ipvsadm -a -t 192.168.225.200:443 -r 192.168.225.131:443 -m
[root@vm5 ~]# ipvsadm -a -t 192.168.225.200:443 -r 192.168.225.128:443 -m
[root@vm5 ~]# 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.225.200:80 rr
-> 192.168.225.128:80 Masq 1 0 0
-> 192.168.225.131:80 Masq 1 0 0
TCP 192.168.225.200:443 rr
-> 192.168.225.128:443 Masq 1 0 0
-> 192.168.225.131:443 Masq 1 0 0
[root@vm5 ~]# ipvsadm -Sn > /etc/sysconfig/ipvsadm
[root@vm5 ~]# cat /etc/sysconfig/ipvsadm
-A -t 192.168.225.200:80 -s rr
-a -t 192.168.225.200:80 -r 192.168.225.128:80 -m -w 1
-a -t 192.168.225.200:80 -r 192.168.225.131:80 -m -w 1
-A -t 192.168.225.200:443 -s rr
-a -t 192.168.225.200:443 -r 192.168.225.128:443 -m -w 1
-a -t 192.168.225.200:443 -r 192.168.225.131:443 -m -w 1
總結
- 上述配置基本沒什麼問題,但是沒有達到預期的效果
- 原因是:
- 1.兩臺mysql伺服器通過NFS共享資料庫檔案時,不能同時開啟兩臺mysql服務,若要解決這個問題,需要對其作高可用功能
- 2.經過測試,LVS-nat模式中的VIP與各伺服器真實的IP地址最好屬於不同的網段,這樣才能得到預期的效果
- 3.NAT網路地址轉換,真實伺服器處理完資料包需要傳送給閘道器,如果客戶端與真實伺服器在相同網段,那麼資料包不會經過閘道器而是直接返回給客戶端