In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Deployment of keepalived
Keepalived is used in many high-availability clusters. Generally, nginx, ipvs and haproxy are placed at the front end.
For example, if we have built such a cluster when using rabbitmq, we will definitely need such a highly available load balancer to distribute traffic. If we use haproxy, for example, a rebbitmq node goes down suddenly or the network card fails, then although there is no failure in the RabbitMQ cluster, all connections will be disconnected to external clients, and the result will be catastrophic. It is also very important to ensure the reliability of load balancing service. Here is the introduction of Keepalived tool, it can be through its own health check, resource takeover function to make high availability (dual hot backup), to achieve failover.
Keepalived uses VRRP (Virtual Router Redundancy Protocol, Virtual routing redundancy Protocol) to realize the hot standby function of the server in the form of software. Usually, two Linux servers are formed into a hot backup group (Master and Backup). There is only one master server Master in the hot backup group at the same time, and Master will virtualize a common virtual IP address, referred to as VIP. This VIP exists only on Master and provides services to the outside world. If Keepalived detects a Master outage or service failure, the backup server Backup automatically takes over VIP called Master,Keepalived and removes the original Master from the hot standby group. When the original Master is restored, it is automatically added to the hot backup group. By default, preemption is called Master, which functions as a failover.
Keepalived works at layers 3, 4, and 7 of the OSI model.
Working at layer 3 means that Keepalived will periodically send an ICMP packet to the server in the hot backup group to determine whether a server has failed, and if it fails, remove the server from the hot backup group.
Working at layer 4 means that Keepalived determines whether the server is faulty by the status of the TCP port, such as detecting port 5672 of RabbitMQ, and removes the server from the hot backup group if it fails.
Working at layer 7 means that Keepalived determines whether the program on the server is running properly according to the policy set by the user (usually a custom detection script), and removes the server from the hot backup group if it fails.
First of all, you need to go to Keepalived's official website to download the installation file of Keepalived. The latest version is keepalived-2.0.20.tar.gz and the download address is http://www.keepalived.org/download.html.
You can find the latest version.
[root@VM_0_8_centos ~] # mkdir keepalive [root @ VM_0_8_centos ~] # cd keepalived/ [root @ VM_0_8_centos keepalived] # wget https://www.keepalived.org/software/keepalived-2.0.20.tar.gz--2020-02-27 10 root@VM_0_8_centos 4637 https://www.keepalived.org/software/keepalived-2.0.20.tar.gzResolving www.keepalived.org (www.keepalived.org). 37.59.63.157, 2001:41d0:8:7a9d::1Connecting to www.keepalived.org (www.keepalived.org) | 37.59.63.157 |: 443. Connected.HTTP request sent, awaiting response... 200 OKLength: 1036063 (1012K) [application/x-gzip] Saving to: 'keepalived-2.0.20.tar.gz'100% [= >] 1036063 13.7KB/s in 1m 43s 2020-02-27 10:48:37 (9.80 KB/s) -' keepalived-2.0.20.tar.gz' saved [1036063 KB/s]
Decompression
[root@VM_0_8_centos keepalived] # lskeepalived-2.0.20.tar.gz [root@VM_0_8_centos keepalived] # tar xf keepalived-2.0.20.tar.gz [root@VM_0_8_centos keepalived] # cd keepalived-2.0.20/ [root@VM_0_8_centos keepalived-2.0.20] # lsaclocal.m4 AUTHOR build_setup compile configure.ac COPYING doc INSTALL keepalived lib Makefile.in README.md TODOar-lib bin_install ChangeLog configure CONTRIBUTORS depcomp genhash install-sh keepalived.spec.in Makefile.am missing [root @ VM_0_8_centos keepalived-2.0.20] #. / configure-- prefix=/opt/keepalived-- with-init=SYSV checking for a BSD-compatible install... / usr/bin/install-cchecking whether build environment is sane... Yeschecking for a thread-safe mkdir-p. / usr/bin/mkdir-pchecking for gawk... Gawkchecking whether make sets $(MAKE)... Yeschecking whether make supports nested variables... Yeschecking whether make supports nested variables... (cached) yeschecking for pkg-config... / usr/bin/pkg-configchecking pkg-config is at least version 0.9.0... Yeschecking for gcc... Gccchecking whether the C compiler works... Yeschecking for C compiler default output file name... A.out
Error reported: missing openssl-devel
Configure: error:! OpenSSL is not properly installed on your system. ! Can not include OpenSSL headers files. !! [root@VM_0_8_centos keepalived-2.0.20] # yum-y install openssl-develLoaded plugins: fastestmirror, langpacksDetermining fastest mirrorsResolving Dependencies-- > Running transaction check--- > Package openssl-devel.x86_64 1:1.0.2k-19.el7 will be installed
Re-execute after installation
[root@VM_0_8_centos keepalived-2.0.20] # / configure-- prefix=/opt/keepalived-- with-init=SYSV
Report an error again, saying that this version does not support ipv6 and needs to install a dependency package
* WARNING-this build will not support IPVS with IPv6. Please install libnl/libnl-3 dev libraries to support IPv6 with IPVS.
[root@VM_0_8_centos keepalived-2.0.20] # yum-y install libnl libnl-develLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfilePackage libnl-1.1.4-3.el7.x86_64 already installed and latest version
Execute the dependency package again after installation
[root@VM_0_8_centos keepalived-2.0.20] # / configure-- prefix=/opt/keepalived-- with-init=SYSV
Compile
[root@VM_0_8_centos keepalived-2.0.20] # make & & make install
Put the startup file under / etc/init.d, and you can use service to start keepalived
[root@VM_0_8_centos keepalived-2.0.20] # cp / opt/keepalived/etc/rc.d/init.d/keepalived / etc/init.d/ [root @ VM_0_8_centos keepalived-2.0.20] # cp / opt/keepalived/etc/sysconfig/keepalived / etc/sysconfig [root@VM_0_8_centos keepalived-2.0.20] # cp / opt/keepalived/sbin/keepalived / usr/ sbin [root @ VM_0_8_centos keepalived -2.0.20] # chmod + x / etc/init.d/keepalived [root@VM_0_8_centos keepalived-2.0.20] # chkconfig-- add keepalived [root @ VM_0_8_centos keepalived-2.0.20] # chkconfig keepalived on [root @ VM_0_8_centos keepalived-2.0.20] # cp / opt/keepalived/etc/keepalived/keepalived.conf / etc/keepalived.conf
Failed to start, check the error report, prompt Unable to find configuration file / etc/keepalived/keepalived.conf here, did not find the address of our configuration file, this is because we specified our own installation path during installation
[root@VM_0_8_centos keepalived-2.0.20] # service keepalived startStarting keepalived (via systemctl): Job for keepalived.service failed because the control process exited with error code. See "systemctl status keepalived.service" and "journalctl-xe" for details. [FAILED] [root@VM_0_8_centos keepalived-2.0.20] # journalctl-xe
Find out where to put our configuration file and change the file address
[root@VM_0_8_centos ~] # find /-name keepalived.conf/opt/keepalived/etc/keepalived/keepalived.conf/etc/keepalived.conf/root/keepalived/keepalived-2.0.20/keepalived/etc/keepalived/keepalived.conf
Add the address of our profile on the last line
[root@VM_0_8_centos ~] # vim / etc/sysconfig/keepalived [root@VM_0_8_centos ~] # tail-1 / etc/sysconfig/keepalived KEEPALIVED_OPTIONS= "- f / etc/keepalived.conf-D-S 0"
Started successfully with systemctl
[root@VM_0_8_centos ~] # systemctl restart keepalived [root @ VM_0_8_centos ~] # systemctl status keepalived ● keepalived.service-SYSV: Start and stop Keepalived Loaded: loaded (/ etc/rc.d/init.d/keepalived; bad; vendor preset: disabled) Active: active (running) since Thu 2020-02-27 11:02:22 CST 10s ago Docs: man:systemd-sysv-generator (8) Process: 30129 ExecStart=/etc/rc.d/init.d/keepalived start (code=exited Status=0/SUCCESS) Main PID: 30136 (keepalived) CGroup: / system.slice/keepalived.service ├─ 30136 keepalived-f / etc/keepalived.conf-D-S 0 ├─ 30138 keepalived-f / etc/keepalived.conf-D-S 0 └─ 30139 keepalived-f / etc/keepalived.conf-D-S 0Feb 27 11:02:31 VM_0_8_centos Keepalived_vrrp [30139]: Sending gratuitous ARP on eth0 for 192.168.200 .18Feb 27 11:02:31 VM_0_8_centos Keepalived_vrrp [30139]: Sending gratuitous ARP on eth0 for 192.168.200.16Feb 27 11:02:31 VM_0_8_centos Keepalived_vrrp [30139]: Sending gratuitous ARP on eth0 for 192.168.200.17Feb 27 11:02:31 VM_0_8_centos Keepalived_vrrp [30139]: Sending gratuitous ARP on eth0 for 192.168.200.18Feb 27 11:02:31 VM_0_8_centos Keepalived_healthcheckers [30138] : HTTP_CHECK on service [192.168.200.3]: tcp:1358 failed after 3 retry.Feb 27 11:02:31 VM_0_8_centos Keepalived_healthcheckers [30138]: Removing service [192.168.200.3]: tcp:1358 to VS [10.10.10.2]: tcp:1358Feb 27 11:02:31 VM_0_8_centos Keepalived_healthcheckers [30138]: Lost quorum 1-031 > 0 for VS [10.10.10.2]: tcp:1358Feb 27 11: 02:31 VM_0_8_centos Keepalived_healthcheckers [30138]: Adding sorry server [192.168.200.200]: tcp:1358 to VS [10.10.10.2]: tcp:1358Feb 27 11:02:31 VM_0_8_centos Keepalived_healthcheckers [30138]: Removing alive servers from the pool for VS [10.10.10.2]: tcp:1358Feb 27 11:02:31 VM_0_8_centos Keepalived_healthcheckers [30138]: Remote SMTP server [192.168.200.1]: 25 connected.
Use service to start and stop
[root@VM_0_8_centos ~] # service keepalived stopStopping keepalived (via systemctl): [OK] [root@VM_0_8_centos ~] # service keepalived startStarting keepalived (via systemctl): [OK] [root@VM_0_8_centos ~] # service keepalived status ● keepalived.service-SYSV: Start and stop Keepalived Loaded: loaded (/ etc/rc.d/init.d/keepalived; bad Vendor preset: disabled) Active: active (running) since Thu 2020-02-27 11:03:27 CST 10s ago Docs: man:systemd-sysv-generator (8) Process: 30394 ExecStop=/etc/rc.d/init.d/keepalived stop (code=exited, status=0/SUCCESS) Process: 30469 ExecStart=/etc/rc.d/init.d/keepalived start (code=exited Status=0/SUCCESS) Main PID: 30476 (keepalived) CGroup: / system.slice/keepalived.service ├─ 30476 keepalived-f / etc/keepalived.conf-D-S 0 ├─ 30478 keepalived-f / etc/keepalived.conf-D-S 0 └─ 30479 keepalived-f / etc/keepalived.conf-D-S 0Feb 27 11:03:36 VM_0_8_centos Keepalived_vrrp [30479]: Sending gratuitous ARP on eth0 for 192.168.200 .18Feb 27 11:03:36 VM_0_8_centos Keepalived_vrrp [30479]: Sending gratuitous ARP on eth0 for 192.168.200.16Feb 27 11:03:36 VM_0_8_centos Keepalived_vrrp [30479]: Sending gratuitous ARP on eth0 for 192.168.200.17Feb 27 11:03:36 VM_0_8_centos Keepalived_vrrp [30479]: Sending gratuitous ARP on eth0 for 192.168.200.18Feb 27 11:03:37 VM_0_8_centos Keepalived_healthcheckers [30478] : HTTP_CHECK on service [192.168.200.3]: tcp:1358 failed after 3 retry.Feb 27 11:03:37 VM_0_8_centos Keepalived_healthcheckers [30478]: Removing service [192.168.200.3]: tcp:1358 to VS [10.10.10.2]: tcp:1358Feb 27 11:03:37 VM_0_8_centos Keepalived_healthcheckers [30478]: Lost quorum 1-031 > 0 for VS [10.10.10.2]: tcp:1358Feb 27 11: 03:37 VM_0_8_centos Keepalived_healthcheckers [30478]: Adding sorry server [192.168.200.200]: tcp:1358 to VS [10.10.10.2]: tcp:1358Feb 27 11:03:37 VM_0_8_centos Keepalived_healthcheckers [30478]: Removing alive servers from the pool for VS [10.10.10.2]: tcp:1358Feb 27 11:03:37 VM_0_8_centos Keepalived_healthcheckers [30478]: Remote SMTP server [192.168.200.1]: 25 connected.
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
5G Next Generation of Communication
© 2024 shulou.com SLNews company. All rights reserved.