In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Article directory 1, keepalived (1) what is keepalived (2) keepalived working principle 2, configuration steps: first step: configure two DR second step: configure the first node server web1 step 3: configure the second node server web2 step 4: client test step 5: deploy keepalived step 6: experimental results verify 1, keepalived: (1) what is keepalived keepalived is a service software to ensure the high availability of the cluster in cluster management Its function is similar to heartbeat and is used to prevent single point of failure. 1. Three core modules of keepalived: core core module chech health monitoring vrrp virtual routing redundancy protocol 2, three important functions of Keepalived service: managing LVS checking LVS cluster nodes as a highly available function of the system network service (2) keepalived working principle 1, keepalived is based on VRRP protocol, VRRP is Virtual Router Redundancy Protocol, that is, virtual routing redundancy protocol. 2. Virtual routing redundancy protocol can be considered as a protocol to achieve high availability of routers, that is, N routers with the same function form a router group, in which there is a master and multiple backup,master with a vip providing external services (the default route of other machines in the local area network of the router is the vip). Master sends multicast, and when the backup does not receive the vrrp packet, it is considered that the master is down. At this point, you need to choose a backup as master according to the priority of VRRP. In this way, the high availability of the router can be ensured. 3. Keepalived has three main modules, which are core, check and vrrp. Core module is the core of keepalived, which is responsible for the startup and maintenance of the main process as well as the loading and parsing of global configuration files. Check is responsible for health check-ups, including common check-ups. The vrrp module is used to implement the VRRP protocol. Second, configuration steps: experimental environment description: (1) prepare four virtual machines, two as scheduling servers and two as node servers; (2) the scheduling server deploys LVS and keepalived to achieve load balancing and dual-computer hot backup; (3) the client host can access the web pages of the background Web server through the virtual ip address. (4) the experimental results verify that one of the DR is down, the access is normal, and all services are running as usual. Role IP address scheduling server DR1 (master) 192.168.100.201 scheduling server DR2 (standby) 192.168.100.202 node server web1 192.168.100.221 node server web2 192.168.100.222 virtual IP 192.168.100.10 client test machine win7 192.168.100.50 first step: configure two DR (1) install ipvsadm and keepalived package yum install ipvsadm keepalived-y (2) modify / etc/sysctl.conf file Add the following code: net.ipv4.ip_forward=1//proc response to turn off the redirection function net.ipv4.conf.all.send_redirects = 0net.ipv4.conf.default.send_redirects = 0net.ipv4.conf.ens33.send_redirects = 0sysctl-p this command is to make the above configuration effective (3) configure the virtual network card (ens33:0): 1, pay attention to the path: / etc/sysconfig/network-scripts/2, directly copy the existing network card information Just modify it: cp ifcfg-ens33 ifcfg-ens33:0vim ifcfg-ens33:0 deletes all the original information and adds the following code: DEVICE=ens33:0ONBOOT=yesIPADDR=192.168.100.10NETMASK=255.255.255.03, enable virtual network card: ifup ens33:0
(4) write service startup script Path: / etc/init.d1, The vim dr.sh script is as follows: #! / bin/bashGW=192.168.100.1VIP=192.168.100.10RIP1=192.168.100.221RIP2=192.168.100.222case "$1" instart) / sbin/ipvsadm-- save > / etc/sysconfig/ipvsadm systemctl start ipvsadm / sbin/ifconfig ens33:0$ VIP broadcast $VIP netmask 255.255.255.255 broadcast $VIP up / sbin/route add-host $VIP dev ens33:0 / sbin/ipvsadm- A-t $VIP:80-s rr / sbin/ipvsadm-a-t $VIP:80-r $RIP1:80-g / sbin/ipvsadm-a-t $VIP:80-r $RIP2:80-g echo "ipvsadm starting- [ok]" ; stop) / sbin/ipvsadm-C systemctl stop ipvsadm ifconfig ens33:0 down route del $VIP echo "ipvsamd stoped- [ok]" Stop) / sbin/ipvsadm-C systemctl stop ipvsadm ifconfig ens33:0 down route del $VIP echo "ipvsamd stoped- [ok]";; status) if [!-e ar/lock/subsys/ipvsadm] Then echo "ipvsadm stoped-" exit 1 else echo "ipvsamd Runing- [ok]" fi *) echo "Usage: $0 {start | stop | status}" exit 1 esac exit 02, add permissions, start the script chmod + x dr.shservice dr.sh start
(5) the configuration of the second DR is exactly the same as that of the first. The second step is to configure the first node server web1 (1) install httpdyum install httpd-ysystemctl start httpd.service / / start the service (2) write a test web page on the site Later, it is convenient to verify the test result path: / var/www/htmlecho "this is accp web" > index.html (3) create a virtual network card 1, path: / etc/sysconfig/network-scripts/2, copy the network card information to modify cp ifcfg-lo ifcfg-lo:03, vim ifcfg-lo:0 delete all the original information, add the following: DEVICE=lo:0IPADDR=192.168.100.10NETMASK=255.255.255.0ONBOOT=yes (4) write a service startup script Path: / etc/init.d1, The vim web.sh script is as follows: #! / bin/bashVIP=192.168.100.10 case "$1" in start) ifconfig lo:0$ VIP netmask 255.255.255.255 broadcast $VIP / 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/lo/arp_ignore echo "2" > / proc/sys/net/ipv4/conf/lo/arp_announce sysctl-p > / dev/null 2 > & 1 echo "RealServer Start OK" Stop) ifconfig lo:0 down route del $VIP / dev/null 2 > & 1 echo "0" > / proc/sys/net/ipv4/conf/lo/arp_ignore echo "0" > / proc/sys/net/ipv4/conf/lo/arp_announce echo "0" > / proc/sys/net/ipv4/conf/all/arp_ignore Echo "0" > / proc/sys/net/ipv4/conf/all/arp_announce echo "RealServer Stoped" ; *) echo "Usage: $0 {start | stop}" exit 1 esac exit 02, add permissions, and execute chmod + x web.sh / / add permissions service web.sh start / / start the service (5) start the virtual network card ifup lo:0 (6) Test whether the web page is normal
Step 3: configure the second node server web2 the second web is exactly the same as the first one, except that in order to distinguish the experimental effect, the content of the second test page has been changed: path: / var/www/htmlecho "this is benet web" > index.html to test whether the page is normal:
Step 4: client test (1) configure the IP address of the client
(2) Test 1. Whether it can be interconnected with 192.168.100.10:
2. Whether it is normal to visit the web page
Step 5: deploy keepalived 1. Deploy on the first DR: (1) modify the keepalived.conf file and the path / etc/keepalived/ to modify the following:
(2) start the service systemctl start keepalived.service 2. Deploy on the second DR: (1) modify the keepalived.conf file
(2) start the service systemctl start keepalived.service step 6: the experimental results verify that due to the deployment of LVS and keepalived, the purpose is to achieve load balancing and dual-server hot backup. At this point, we simulate the failure and shut down one of the DR1. If the client can still communicate with the virtual IP address and visit the website normally, it means that DR2 will work instead of DR1, and the effect of preventing single point of failure has been achieved. (1) Fault simulation: disable DR1ifdown ens33:0 (2) verify the result. 1. Ping the virtual ip on the client side.
2. The website is still accessible.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.