Keeplived+Haproxy+VIP

image.png

一、 Keeplived搭建配置

1、在ceph1和ceph2和ceph3节点上安装keeplived

yum install -y keepalived
mv /etc/keepalived/keepalived.conf{,.bak_2023-02-15}

2、ceph1和ceph2和ceph3配置文件。

cat >/etc/keepalived/keepalived.conf<<EOF
! Configuration File for keepalived
global_defs {
   notification_email {
     [email protected]
     [email protected]
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 193.168.44.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}
vrrp_script chk_haproxy {
    script "killall -0 haproxy"
    interval 2
    weight -2
}
vrrp_instance VI_1 {
    state MASTER
    interface ens160 # 网卡名
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        20.1.2.113 # VIP
    }
    track_script {
    chk_haproxy
    }
}
EOF

3、 启动服务


#开机自启
systemctl enable keepalived

systemctl restart keepalived
systemctl status keepalived


# 测试 

ping 20.1.2.113

二、 Haproxy代理RGW

1、接下来安装haproxy,在ceph1和ceph2和ceph3上执行

yum install -y haproxy

2、覆盖ceph1和ceph2和ceph3配置,

具体配置参数根据需求修改,需要修改ip和hostname

cat >/etc/haproxy/haproxy.cfg<<EOF
global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    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                 3000
frontend  http_web *:8080
    mode http
    default_backend          rgw
backend rgw
    balance     roundrobin
    mode http
    server  ceph1 20.1.2.116:80
    server  ceph2 20.1.2.117:80
    server  ceph3 20.1.2.118:80
EOF

3、重启ceph-01和ceph-02和ceph-03上的haproxy

systemctl enable haproxy


systemctl restart haproxy

systemctl status haproxy
 
curl 20.1.2.113:8080

参考文献https://blog.csdn.net/aa18855953229/article/details/127399785

猜你喜欢

转载自blog.csdn.net/qq_35583325/article/details/129048651