• ⑥.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后缀非.开头的配置文件

  • 相关阅读:
    4.方向-世界坐标系
    3.Unity3d物体操作常用按键
    2.Unity3d常用按键
    1.Unity3d的新建场景和保存场景
    MySQL CodeFirst的配置与注意事项
    HNU暑假训练第一场C.Ninja Map
    牛客暑假多校第二场J-farm
    牛客暑假多校第一场J-Different Integers
    主席树设计与实现
    博弈论的一些理解
  • 原文地址:https://www.cnblogs.com/yangtao416/p/16518242.html
Copyright © 2020-2023  润新知