zoukankan      html  css  js  c++  java
  • keepalived ,egnix ,tomcat 高可用,高并发 应用架构的搭建

    keepalived ,egnix ,tomcat 高可用,高并发 应用架构的搭建


    keepalived 中需要构建Virtual IP 地址 ,并创建一个nginx  check 文件 检测  nginx Server 运行状态 ,如果ngnix  进程不可访问,则kill掉killall keepalived 进程,实现VIP 漂移

    ngnix 托管tocmat 服务器地址,因此在tomcat web 服务器上不再需要LVS 功能 即 去掉 lo:A  设备的绑定


    本架构共四台机器 :


    服务器 A ,IP   192.168.168.101  安装 keepalived ,ngnix  ,配置 keepalived(MASTER) ,ngnix(A,B ngnxi 配置要完全相同),不需要lvs

    服务器 B ,IP   192.168.168.102  安装 keepalived ,ngnix  ,配置 keepalived(BACKUP) ,ngnix(A,B ngnxi 配置要完全相同),不需要lvs

    服务器 C,IP   192.168.168.103   安装tomcat ,不需要lvs

    服务器 D,IP   192.168.168.104   安装tomcat,不需要lvs


    示例 keepalived 配置:


    ! Configuration File for keepalived

    global_defs {
       notification_email {
         root@localhost
       }
       notification_email_from hello@localhost
       smtp_server 127.0.0.1
       smtp_connect_timeout 30
       router_id LVS_DEVEL
    }

    vrrp_script check_nginx {
       script "/home/check_nginx.sh"
       interval 2
       weight 2
    }
     
    vrrp_instance VI_1 {
        state MASTER
        interface eth0
        virtual_router_id 51
        priority 199
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass 1111
        }
        virtual_ipaddress {
        192.168.239.100/24 dev eth0 label eth0:1
        }
        track_script {
           check_nginx
        }
    }


    ====

    check_nginx,sh

    #!/bin/bash
    #
    URL="http://192.168.239.30/"
    code=`curl -I -m 5 -o /dev/null -s -w %{http_code} $URL`
    if [ $code -ne 200 ];then
      sleep 2
      code=`curl -I -m 5 -o /dev/null -s -w %{http_code} $URL`
      if [ $code -ne 200 ];then
         killall keepalived
      fi
    fi



    ====

    示例 ngnix  配置:


     upstream yxh {
           server 192.168.184.188:8080 weight=1;
           server 192.168.184.168:8080 weight=1;
          # check interval=3000 rise=2 fall=5 timeout=1000 type=http;
          # check_http_send "HEAD / HTTP/1.0 ";
          # check_http_expect_alive http_2xx http_3xx;
         }
         server {
            listen       80;
            server_name  www.host1.com;
            location / {
                #root   html;
                #index  index.html index.htm;
                #-----------
                #auth_basic "hi who are you ?";
                #auth_basic_user_file /var/users;
                #index index.html index.htm;
                #------------------
                #proxy_pass http://192.168.184.168:8080/;
                 proxy_pass http://yuxh/;
                #index index.html index.htm;
            }












  • 相关阅读:
    查看进程的pid和ppid
    多进程《二》开启进程的两种方式
    多进程《一》进程理论
    并发编程《二》操作系统介绍2
    并发编程《一》操作系统介绍1
    Google浏览器历史版和下载地址
    python爬取淘宝排名
    字符编码
    hashlib
    离散数学
  • 原文地址:https://www.cnblogs.com/TendToBigData/p/10501469.html
Copyright © 2011-2022 走看看