In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I. Overview
Introduction to UCARP
UCARP allows multiple hosts to share a virtual ip address to provide automatic fault recovery. When one of the hosts goes down, the other hosts automatically take over the service. UCARP is the linux implementation version of the CARP protocol (Universal address redundancy Protocol, first implemented on OpenBSD). At the same time, it can also be ported to many other unix platforms, the official website of UCARP: http://www.ucarp.org/project/ucarp.
The CARP protocol is characterized by its very low overhead, using encrypted data to transmit information between hosts, and does not require any additional network links between redundant hosts (there is a simple deployment example of ucarp in README).
two。 Configuration requirement
Two or more hosts to form redundant host groups
A shared virtual ip address is used to provide reliable services to the outside world. A host in the redundant host group will respond to the service on this ip.
For each host, you need to configure a real ip address
A shared identifier between 1 and 255
A shared password (so that messages transmitted between networks are all ciphertext)
A script that executes when a host in a redundancy group becomes a MASTER
When a host in a redundancy group is no longer a MASTER, it is a script that executes
3 detailed explanation of specific parameters of Ucap
-- inter (- I: bind interface (network interface binds network interface)
-- srcip= (- s: source (real) IP address of that host (source address real ip)
-- vhid= (- v: virtual IP identifier (1-255) (virtual ip ID (1-255))
-- pass= (- p: password)
-- preempt (- P): becomes a master as soon as possible (becomes the role of the master server as quickly as possible)
-- neutral (- n): don't run downscript at start if backup (if it is a backup host, do not run downscript.)
-- addr= (- a: virtual shared IP address (shared virtual ip address)
-help (- h): summary of command-line options (help)
-- advbase= (- b: advertisement frequency (frequency of broadcast in seconds)
-- advskew= (- k: advertisement skew (0255) (do not broadcast) is used to set the announcement interval, and the formula (in seconds) is advskew/256+advbase. Advbase can reduce network traffic or set a longer mainframe "round-robin" time (until the backup machine replaces it); advskew sets which hot backup computer will give priority to the mainframe in case of failover (this is required)
-- upscript= (- u: run to become a master (run a script file to make this server the master server)
-- downscript= (- d: run to become a backup (run a script file to make this server a slave server)
-- deadratio= (- r: ratio to consider a host as dead (ratio that the host is determined to be dead (threshold))
-- shutdown (- z): call shutdown script at exit (execute the shutdown script on exit)
-- daemonize (- B): run in background (running in the background)
-- facility= (- f): set syslog facility (default=daemon) (set syslog tool, default is in the background)
Brief description of Ucarp parameters:
-v vip ID-p password-a vip address-u script run when the machine is upgraded to master-d script run when the machine is downgraded to slave-s heartbeat ip address-the smallest combination of P and-k is the master machine-B runs in daemon mode
4. Experimental environment
Role hostname real_ip vip gateway OS
Master node2 192.168.32.32/24 192.168.32.22/24 192.168.32.254 rhel5.5
Slave node3 192.168.32.33/24 192.168.32.22/24 192.168.32.254 rhel5.5
II. Installation and configuration
1. Installation
[root@node2 ~] # tar-zxf ucarp-1.5.tar.gz # ucarp is best selected above version 1.2, which contains bug below
[root@node2 ~] # cd ucarp-1.5
[root@node2 ucarp-1.5] # which gcc # confirm gcc
/ usr/bin/gcc
[root@node2 ucarp-1.5] #. / configure CC=/usr/bin/gcc-prefix=/usr/local/ucarp
[root@node2 ucarp-1.5] # make & & make install
2. Configure the master server (node2)
2.1 script to run when the machine is upgraded to master
[root@node2 ~] # vim / etc/master-up.sh
#! / bin/bash
GATEWAY=192.168.32.254
/ sbin/ip addr add 192.168.32.22/24 dev eth0
/ bin/hostname nodevir2
/ sbin/route add default gw $GATEWAY
Service httpd start
2.2 script to run when the machine is reduced to slave
[root@node2 ~] # vim / etc/master-down.sh
#! / bin/bash
GATEWAY=192.168.32.254
/ sbin/ip addr del 192.168.32.22/24 dev eth0
/ bin/hostname node2
/ sbin/route add default gw $GATEWAY
Service httpd stop
2.3 write ucarp run scripts
[root@node2 ~] # vim / etc/master.sh
#! / bin/bash
/ usr/local/ucarp/sbin/ucarp-I eth0-v 40-p gw22-a 192.168.32.22-u / etc/master-up.sh-d / etc/master-down.sh-s 192.168.32.32-P-B
2.4 start the service
[root@node2] #. / etc/master.sh
[root@node2 ~] # ps-ef | grep ucarp
Root 11695 10 11:33? 00:00:00 / usr/local/ucarp/sbin/ucarp-I eth0-v 40-p gw22-a 192.168.32.22-u / root/master-up.sh-d / root/master-down.sh-s 192.168.32.32-P-B
[root@node2 ~] # hostname # hostname switched successfully
Nodevir2
[root@node2 ~] # ip addr show | grep 22 # master-up.sh script takes effect
Inet 192.168.32.22/24 scope global secondary eth0
[root@nodevir2 ~] # ps-ef | grep httpd # httpd service starts
Root 11726 1 0 11:33? 00:00:00 / usr/sbin/httpd
Apache 11727 11726 0 11:33? 00:00:00 / usr/sbin/httpd
Apache 11729 11726 0 11:33? 00:00:00 / usr/sbin/httpd
Apache 11730 11726 0 11:33? 00:00:00 / usr/sbin/httpd
Apache 11731 11726 0 11:33? 00:00:00 / usr/sbin/httpd
Apache 11732 11726 0 11:33? 00:00:00 / usr/sbin/httpd
Apache 11733 11726 0 11:33? 00:00:00 / usr/sbin/httpd
Apache 11734 11726 0 11:33? 00:00:00 / usr/sbin/httpd
Apache 11735 11726 0 11:33? 00:00:00 / usr/sbin/httpd
Root 11897 6167 0 11:44 pts/1 00:00:00 grep httpd
3. Configure standby server (node3)
3.1 script to run when the machine is upgraded to master
[root@node3 ~] # vim / etc/master-up.sh
#! / bin/bash
GATEWAY=192.168.32.254
/ sbin/ip addr add 192.168.32.22/24 dev eth0
/ bin/hostname nodevir2
/ sbin/route add default gw $GATEWAY
Service httpd start
3.2Writing scripts that run when the machine is reduced to slave
[root@node2 ~] # vim / etc/master-down.sh
#! / bin/bash
GATEWAY=192.168.32.254
/ sbin/ip addr del 192.168.32.22/24 dev eth0
/ bin/hostname node3
/ sbin/route add default gw $GATEWAY
Service httpd stop
3.3.Writing ucarp run scripts
[root@node2 ~] # vim / etc/master.sh
#! / bin/bash
/ usr/local/ucarp/sbin/ucarp-I eth0-v 40-p gw22-a 192.168.32.22-u / etc/master-up.sh-d / etc/master-down.sh-s 192.168.32.33-P-k 15-B
3.4 start the service
[root@node2] #. / etc/master.sh
Root 5678 10 11:40? 00:00:00 / usr/local/ucarp/sbin/ucarp-v 40-I eth0-p gw22-a 192.168.32.22-u / root/master-up.sh-d / root/master-down.sh-s 192.168.32.33-k 15-B
[root@node3 ~] # ps-ef | grep httpd # httpd service is started
Root 5788 32767 0 11:46 pts/1 00:00:00 grep httpd
three。 Fail-over
Main fault
[root@nodevir2 ~] # kill 5678 # down drop the ucarp service, or restart the server
[root@node3 ~] # hostname # hostname switched successfully
Nodevir2
[root@node3 ~] # ip addr show | grep 22 # Virtual IP switched successfully
Inet 192.168.32.22/24 scope global secondary eth0
[root@node3 ~] # ps-ef | grep httpd # service switched successfully
Root 5824 1 0 11:47? 00:00:00 / usr/sbin/httpd
Apache 5826 5824 0 11:47? 00:00:00 / usr/sbin/httpd
Apache 5827 5824 0 11:47? 00:00:00 / usr/sbin/httpd
Apache 5828 5824 0 11:47? 00:00:00 / usr/sbin/httpd
Apache 5829 5824 0 11:47? 00:00:00 / usr/sbin/httpd
Apache 5830 5824 0 11:47? 00:00:00 / usr/sbin/httpd
Apache 5831 5824 0 11:47? 00:00:00 / usr/sbin/httpd
Apache 5832 5824 0 11:47? 00:00:00 / usr/sbin/httpd
Apache 5833 5824 0 11:47? 00:00:00 /
two。 Master recovery
[root@node2] #. / etc/master.sh
[root@nodevir2 ~] # hostname
Nodevir2
[root@node2 ~] # ps-ef | grep httpd
Root 11969 1 0 11:46? 00:00:00 / usr/sbin/httpd
Apache 11970 11969 0 11:46? 00:00:00 / usr/sbin/httpd
Apache 11972 11969 0 11:46? 00:00:00 / usr/sbin/httpd
Apache 11973 11969 0 11:46? 00:00:00 / usr/sbin/httpd
Apache 11974 11969 0 11:46? 00:00:00 / usr/sbin/httpd
Apache 11975 11969 0 11:46? 00:00:00 / usr/sbin/httpd
Apache 11976 11969 0 11:46? 00:00:00 / usr/sbin/httpd
Apache 11977 11969 0 11:46? 00:00:00 / usr/sbin/httpd
Apache 11978 11969 0 11:46? 00:00:00 / usr/sbin/httpd
[root@node2 ~] # ip addr show | grep 22
Inet 192.168.32.22/24 scope global secondary eth0
[root@node3 ~] # hostname
Node3
[root@node3 ~] # ps-ef | grep httpd
Root 6148 32767 0 12:02 pts/1 00:00:00 grep httpd
[root@node3 ~] # ip addr show | grep 22 # switched successfully
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.