• ⑥.haproxy定义子配置并生效


    1.定义配置

    [root@proxy01 haproxy]#  cat /etc/haproxy/conf.d/app.oldxu.net.cfg 
    frontend app_web
        bind *:8899
        mode http
        use_backend app_servers
        
    backend app_servers
        balance roundrobin
        server web1 172.16.1.7:8888 check inter 3000 fall 2 rise 5
        server web2 172.16.1.8:8888 check inter 3000 fall 2 rise 5
    

    2.haproxy启动方式:

    [root@proxy01 haproxy]# cat  /usr/lib/systemd/system/haproxy.service
    [Unit]
    Description=HAProxy Load Balancer
    After=network-online.target
    Wants=network-online.target
    
    [Service]
    EnvironmentFile=-/etc/sysconfig/haproxy
    Environment="CONFIG=/etc/haproxy/haproxy.cfg" "PIDFILE=/run/haproxy.pid"
    Environment="CONFIG_D=/etc/haproxy/conf.d/"
    
    
    ExecStartPre=/usr/sbin/haproxy -f $CONFIG -f $CONFIG_D -c -q $OPTIONS
    ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -f $CONFIG_D -p $PIDFILE $OPTIONS
    ExecReload=/usr/sbin/haproxy -f $CONFIG -f $CONFIG_D -c -q $OPTIONS
    ExecReload=/bin/kill -USR2 $MAINPID
    KillMode=mixed
    SuccessExitStatus=143
    Type=notify
    
    [Install]
    WantedBy=multi-user.target
    
    
    [root@proxy01 haproxy]# systemctl daemon-reload
    [root@proxy01 haproxy]# systemctl restart haproxy
    [root@proxy01 haproxy]# netstat -lntp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 0.0.0.0:8899            0.0.0.0:*               LISTEN      112435/haproxy    
    

    PS: #创建子配置文件,注意:必须为cfg后缀非.开头的配置文件

  • 相关阅读:
    元素居中显示
    文本框 获取焦点 失去焦点 实时监听
    cookie/ localStorage /sessionStorage区别
    h5新增标签
    css3属性中的transform属性
    精简 闭包
    let const定义及用法
    关于arguments映射的问题
    Linux云自动化运维第二课
    下载模版的具体代码
  • 原文地址:https://www.cnblogs.com/yangtao416/p/16518242.html
Copyright © 2020-2023  润新知