mysql 双活 双vip,keepalived+nginx+apache双活搭建(双网卡模式)

keepalived+nginx+apache主备及双活搭建测试》,该测试环境只有一张网卡,双活的ip都在该网卡上。

本文背景:自动化运维平台的前置机部署在云平台,服务器有两张网卡,分别对应带外ip和业务ip;云平台的被管服务器访问带外虚ip,非云平台的物理服务器访问业务的虚ip。

架构图:

bfed636ba4c2bfcdf9d9036bdbb32955.png

配置:主机ip操作系统软件vip

nginx01172.27.9.91

172.27.18.127Centos7.3.1611nginx 端口82

keepalived172.27.9.200

nginx02172.27.9.92

172.27.18.128Centos7.3.1611nginx 端口82

keepalived172.27.18.120

web01172.27.9.125Centos7.3.1611apache 端口1180/

web02172.27.9.126Centos7.3.1611apache 端口1180/

vmware版本:12.5.2 build-4638234

1.vmware新增网卡

打开‘虚拟网络编辑器’:

4016ac9ddda6f14dbf96676489d98873.png

‘VMnet0’和‘VMnet2’分别对应pc机物理网卡和无线网卡:

0d80c3a513f8fc2eaf0274e0b4bc3633.png

新增网卡及配置:

de7e4d5c26097684187086e12db3e5e8.png

2.keepalived配置

nginx01上keepalived配置:[[email protected] keepalived]# more /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {

notification_email {

[email protected]

[email protected]

[email protected]

}

notification_email_from [email protected]

#smtp_server 192.168.200.1

#smtp_connect_timeout 30

router_id proxy1

}

vrrp_script chk_nginx {

script "/etc/keepalived/check_nginx.sh"

interval 2

weight 20

fall 1

rise 10

}

vrrp_instance VI_1 {

state MASTER

interface ens33

virtual_router_id 51

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

172.27.9.200

}

track_script {

chk_nginx

}

}

vrrp_instance VI_2 {

state BACKUP

interface ens37

virtual_router_id 52

priority 90

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

172.27.18.120

}

track_script {

chk_nginx

}

}

nginx02上keepalived配置:[[email protected] keepalived]# more /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {

notification_email {

[email protected]

[email protected]

[email protected]

}

notification_email_from [email protected]

#smtp_server 192.168.200.1

#smtp_connect_timeout 30

router_id proxy2

}

vrrp_script chk_nginx {

script "/etc/keepalived/check_nginx.sh"

interval 2

weight 20

fall 2

rise 1

}

vrrp_instance VI_1 {

state BACKUP

interface ens33

virtual_router_id 51

priority 90

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

172.27.9.200

}

track_script {

chk_nginx

}

}

vrrp_instance VI_2 {

state MASTER

interface ens37

virtual_router_id 52

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

172.27.18.120

}

track_script {

chk_nginx

}

}

check_nginx.sh脚本配置同之前文章

3.nginx配置

两台nginx服务器配置相同如下:[[email protected] keepalived]# more /usr/local/nginx/conf/nginx.conf

#user  nobody;

worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

worker_connections  1024;

}

http {

include       mime.types;

default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

#                  '$status $body_bytes_sent "$http_referer" '

#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;

#tcp_nopush     on;

#keepalive_timeout  0;

keepalive_timeout  65;

#gzip  on;

upstream webser{

server 172.27.9.125:1180;

server 172.27.9.126:1180;

server 172.27.18.127:1180;

server 172.27.18.128:1180;

}

server {

listen       82;

server_name  localhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {

proxy_pass http://webser;

#root   html;

#index  index.html index.htm;

}

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

}

}

4.启动服务

启动两台服务器nginx和keepalived服务:

7.高可用测试

同之前文章,不再赘述。

测试完成,云平台生产环境也可以按本次测试实施。

原文:http://blog.51cto.com/3241766/2129948

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值