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












  • 相关阅读:
    一本通1269 有限背包
    python3 threading.Lock() 多线程锁的使用
    Sqlite3错误:Recursive use of cursors not allowed 的解决方案
    linux 常用命令
    90%的人说Python程序慢,5大神招让你的代码像赛车一样跑起来
    python3 使用flask连接数据库出现“ModuleNotFoundError: No module named 'MySQLdb'”
    Navicat Premium12远程连接MySQL数据库
    pymysql pymysql.err.OperationalError 1045 Access denied最简单解决办法
    CentOS7 安装MySQL8修改密码
    CentOS7 升级Openssl的办法
  • 原文地址:https://www.cnblogs.com/TendToBigData/p/10501469.html
Copyright © 2011-2022 走看看