【Haproxy】

这里写自定义目录标题

haproxy 服务器部署
关闭防火墙,yum安装

[root@wang188888 ~]# systemctl stop firewalld
[root@wang188888 ~]# systemctl disable firewalld
[root@wang188888 ~]# setenforce 0

[root@wang188888 ~]# cd /etc/yum.repos.d/
[root@wang188888 yum.repos.d]# ls
local.repo  repos.bak
[root@wang188888 yum.repos.d]# mv repos.bak/* ./
[root@wang188888 yum.repos.d]# ls
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo          repos.bak
CentOS-CR.repo         CentOS-Media.repo      CentOS-x86_64-kernel.repo
CentOS-Debuginfo.repo  CentOS-Sources.repo    local.repo
[root@wang188888 yum.repos.d]# yum install -y haproxy

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

    log         127.0.0.1 local0 info
    log         127.0.0.1 local1 warning

    #chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     40000
    user        haproxy
    group       haproxy
    daemon
    spread-checks 2
    #nbproc 2

    # turn on stats unix socket
    #stats socket /var/lib/haproxy/stats

在这里插入图片描述

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-keep-alive
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 30000

在这里插入图片描述

frontend  http-in
    #监听任意地址的80端口
    bind *:80
    #通过acl过滤符合条件的静态页面请求
    acl url_static       path_beg       -i /static /images /javascript /stylesheets
    acl url_static       path_end       -i .jpg .gif .png .css .js
    #将符合acl条件的静态页面请求转发到static_backend后端域,将其它所以请求转发到dynamic_backend后端域中
    use_backend static_backend          if url_static
    default_backend     dynamic_backend

backend static_backend
    balance     roundrobin
    option  httpchk GET /test.html
    server  inst1 192.168.223.73:80 check inter 2000 rise 2 fall 3
    server  inst2 192.168.223.74:80 check inter 2000 rise 2 fall 3

backend dynamic_backend
    balance     roundrobin
    option  http-server-close
   #cookie  HA_STICKY_dy insert indirect nocache
    server  app1 192.168.223.73:8080 cookie appser1 check
    server  app2 192.168.223.74:8080 cookie appser2 check



vim /etc/rsyslog.conf

在这里插入图片描述

vim /etc/rsyslog.d/haproxy.conf

$ModLoad imudp
$UDPServerRun 514
$FileCreateMode 0644
$FileOwner haproxy

local1.*  /var/log/haproxy/haproxy_warning.log
local0.*  /var/log/haproxy/haproxy_info.log

在这里插入图片描述

在这里插入图片描述

listen stats
   bind *:1080
   stats enable
   stats refresh 30s
   stats uri /stats
   stats realm HAProxy\ stats
   stats auth admin:admin123

在这里插入图片描述

节点服务器部署
1.

[root@wang19999 ~]# systemctl stop firewalld
[root@wang19999 ~]# systemctl disable firewalld
[root@wang19999 ~]# setenforce 0
[root@wang19999 ~]# yum install -y httpd

在这里插入图片描述

[root@wang19999 ~]# cd /var/www/html/
[root@wang19999 html]# ls
[root@wang19999 html]# echo '<h1>wanghw 77777</h1>' > index.html
[root@wang19999 html]# systemctl start httpd
[root@wang19999 html]# echo 123 > test.html
[root@wang19999 html]# ls
index.html  test.html

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
2.
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
尝试用
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Wanghwei17/article/details/131175227