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;
            }












  • 相关阅读:
    eclipse中的项目的JRE换成JDK
    Eclipse中maven项目的创建和运行
    git 发布命令
    vbox中虚拟ubuntu增加新的虚拟硬盘
    MyServer
    java常用的中间件
    高并发解决方案
    浅谈SpringMVC
    浅谈HIbernate
    javaweb笔记七
  • 原文地址:https://www.cnblogs.com/TendToBigData/p/10501469.html
Copyright © 2011-2022 走看看