Entorno de combate real (CentOS7) VIP 10.211.55.180 (IP virtual) LVS1 10.211.55.151 (LVS principal) LVS2 10.211.55.152 (LVS en espera) RS1 10.211.55.171 (servidor real 1) RS2 10.211.55.172 (servidor real 2) entorno de inicialización todos Node iptalbes -F #Borrar el sistema de firewallctl detener firewalld #Apagar el sistema de firewallctl deshabilitar firewalld #Detener que el firewall se inicie setenforce 0 #Apagar temporalmente selinux sed -i's / ^ SELINUX =. * $ / SELINUX = disabled / g '/ etc / selinux / config #Cerrar selinux date #Time yum -y install epel-release #Install epel source LVS1, 2 operation 1, install keepalived ipvsadm yum -y install keepalived ipvsadm [root @ localhost ~] # lsmod | grep ip_vs #check ipvs module ip_vs_rr 12600 1 ip_vs 145497 3 ip_vs_rr nf_conntrack 139264 9 ip_vs, nf_nat, nf_nat_ipv4, nf_nat_ipv6, xt_conntrack, nf_nat_masquerade_ipv4, nf_conntrack_netlink, nf_conntrack_ipv4, nf_conntrack_ipv6 libcrc32c 12644 4 XFS, ip_vs, nf_nat, nf_conntrack 2,配置keepalived (LVS1,2) 2,1修改keepalived的配置文件 [ root @ localhost ~] # cd / etc / keepalived / [root @ localhost keepalived] # cat keepalived.conf ! Archivo de configuración para keepalived global_defs { notification_email { [email protected] } notification_email_from [email protected] smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_DEVEL vrrp_skip_chevalck_adv_addr # vrrp_strict # vrrp 0_garp vrrp_gna_interval 0 } vrrp_instance VI_1 { state MASTER # LVS1 es el MASTER, luego LVS2 se cambia a BACKUP interface eth0 # CENTOS7 ens33 virtual_router_id 51 # Si la prioridad principal y de respaldo son consistentes 100 # LVS1 es 100, entonces LVS2 es 100 , Como 90, mayor es el peso, qué lado VIP flotará en 99 89 advert_int 1 autenticación { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.211.55.180 #VIP } } virtual_server 10.211.55.180 80 {#VIP delay_loop 6 lb_algo rr lb_kind DR persistence_timeout 50 El protocolo TCP real_server 10.211.55.171 {# 80 detecta el extremo posterior de RS1 peso. 1 TCP_CHECK { connect_timeout El. 3 nb_get_retry. 3 delay_before_retry. 3 connect_port 80 } } real_server 10.211.55.172 {# 80 detecta la RS2 extremo trasero de peso. 1 TCP_CHECK { connect_timeout El. 3 nb_get_retry. 3 delay_before_retry. 3 connect_port 80 } } } 2.2 Configurar el arranque (LVS1, 2) 3. Configurar LVS, ejecutar el siguiente script (LVS1, 2) y configurar el script para arrancar systemctl enable keepalived systemctl start keepalived vi /opt/lvs_dr.sh #! / bin / sh # descripción: Iniciar LVS del servidor Director VIP = 10.211.55.180 RIP1 = 10.211.55.171 RIP2 = 10.211.55.172 caso "$ 1" en inicio) echo "iniciar LVS of Director Server " # establezca la dirección IP virtual y el parámetro sysctl # / sbin / ifconfig eth0: 0 $ VIP broadcast $ VIP netmask 255.255.255.255 up # route add -host $ VIP dev eth0: 0 echo" 1 "> / proc / sys / net / ipv4 / ip_forward # Borrar tabla IPVS / sbin / ipvsadm -C #set LVS / sbin / ipvsadm -A -t $ VIP: 80 -s rr # -p 600 # 需要 会话 持久 化 则把 此处 的 - p 600 取消 注释 / sbin / ipvsadm -a -t $ VIP: 80 -r $ RIP1: 80 -g / sbin / ipvsadm -a -t $ VIP: 80 -r $ RIP2: 80 -g #Run LVS / sbin / ipvsadm ;; stop) echo "cerrar LVS Directorserver" echo "0"> / proc / sys / net / ipv4 / ip_forward / sbin / ipvsadm -C # / sbin / ifconfig eth0: 0 abajo ;; *) echo " Uso: $ 0 {start | stop} " exit 1 esac chmod + x /opt/lvs_dr.sh #Añadir autoridad de ejecución echo" /opt/lvs_dr.sh start ">> / etc / profile #Startup automáticamente 4. Configurar la operación RS , Realice las siguientes operaciones (RS1, 2) para instalar nginx yum -y install nginx # RS1 y 2 ambos instalan echo 10.211.55.171> /usr/share/nginx/html/index.html # RS1 en la operación echo 10.211.55.172> / usr / compartir / nginx / html / index.html # Operación RS2 en RS2 Configure el script RS y configure vi /opt/lvs_rs.sh #! / bin / bash VIP = 10.211.55.180 / sbin / ifconfig lo: 0 $ VIP broadcast $ VIP netmask 255.255.255.255 up / sbin / route add -host $ VIP dev lo: 0 echo “1 ″> / proc / sys / net / ipv4 / conf / lo / arp_ignore echo "2 ″> / proc / sys / net / ipv4 / conf / lo / arp_announce echo" 1 ″> / proc / sys / net / ipv4 / conf / all / arp_ignore echo " 2 ″> / proc / sys / net / ipv4 / conf / all / arp_announce sysctl -p #end Esta operación consiste en vincular una dirección IP virtual en el dispositivo de bucle invertido y establecer su máscara de subred en 255.255.255.255, Mantiene la intercomunicación con la IP virtual en el servidor Director y luego prohíbe la solicitud ARP local. Dado que la dirección IP virtual, que es la dirección VIP anterior, es compartida por Director Server y todos los servidores Real, si hay una solicitud ARP para la dirección VIP, si el Director Server responde a todos los servidores Real, habrá un problema. Por lo tanto, debe prohibirse. El servidor real responde a la solicitud de ARP. La función del script lvsrs es hacer que Real Server no responda a las solicitudes de arp. chmod + /opt/lvs_rs.sh #Añadir permisos de ejecución echo "/opt/lvs_rs.sh" #Inicio después del arranque 5. Prueba Encuentra un cliente y ejecuta el siguiente comando -> $ for i in `20` ss; hago rizo 10.211.55.180; hecho 10.211.55.171 10.211.55.172 10.211.55.171 10.211.55.172 10.211.55.171 10.211.55.172 10.211.55.171 10.211.55.172 10.211.55.171 10.211.55.172 10.211. 55.171 10.211.55.172 10.211.55.171 10.211.55.172 10.211.55.171 10.211.55.172 10.211.55.171 10.211.55.172 10.211.55.171 10.211.55.172
Instalación y configuración de DNS de CentOS 7
Supongo que te gusta
Origin blog.51cto.com/slapping/2551547
Recomendado
Clasificación