In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
* Keepalived+lvs *
Server IP assignment:
Server:
Ip address
Load Balancer:
172.25.7.1
Backup:
172.25.7.4
Real Server 1:
172.25.7.2
Real Server 2:
172.25.7.3
Installation and configuration of software packages on the master and standby:
# tar zxf keepalived-1.3.5.tar.gz
# cd keepalived-1.3.5
#. / configure-prefix=/usr/local/keepalived-with-init=SYSV
# make & & make install
# ln-s / usr/local/keepalived/sbin/keepalived / sbin/
# ln-s / usr/local/keepalived/etc/keepalived/ / etc/
# ln-s / usr/local/keepalived/etc/sysconfig/keepalived / etc/sysconfig/
# ln-s / usr/local/keepalived/etc/rc.d/init.d/keepalived / etc/init.d/
# chmod + x / usr/local/keepalived/etc/rc.d/init.d/keepalived
# vim / etc/keepalived/keepalived.conf
! Configuration File for keepalived
Global_defs {
Notification_email {
Root@localhost # email address to receive alerts, you can add more than one
}
Notification_email_from keepalived@server1 # sets the sending address of the mail
Smtp_server 172.25.7.1 # set smtp server address
Smtp_connect_timeout 30 # sets the timeout for connecting to the smtp server
Identity ID of router_id LVS_DEVEL # load balancer for email alerts
Vrrp_skip_check_adv_addr
Vrrp_strict
Vrrp_garp_interval 0
Vrrp_gna_interval 0
}
Vrrp_instance VI_1 {
State MASTER # standby is changed to BACKUP. This status is determined by the value of priority. If the current priority value is less than the standby value, the MASTER status will be lost.
Interface eth0 # HA Monitoring Network Interface
The virtual_router_id of virtual_router_id 70 # master and standby must be the same
Priority of priority 100 # host, backup machine changed to 50
The number of seconds between advert_int 1 # active and standby advertisements
Verification of authentication {# when switching between master and slave
Auth_type PASS # sets the verification type, mainly including PASS and AH
Auth_pass 1111 # sets the authentication password. Under a vrrp_instance, MASTER and BACKUP must use the same password to communicate normally.
}
Virtual_ipaddress {# HA virtual ip, which can be added with one per line
172.25.7.100
}
}
Virtual_server 172.25.7.100 80 {# define a virtual server
Delay_loop 6 # query realserver status every 6 seconds
Lb_algo rr # lvs scheduling algorithm, which uses round robin
Lb_kind DR # LVS uses DR mode
# persistence_timeout 50 # session persistence time (in seconds). This option is very useful for dynamic web pages and provides a good solution for session sharing in cluster systems. With this session persistence feature, the user's request is distributed to a service node until the session persistence time is exceeded. It should be noted that this session duration is the maximum unresponsive timeout, that is, if the user does not perform any action within 50 seconds when operating a dynamic page, then the next operation will be distributed to another node. However, if you have been operating a dynamic page, it is not subject to a 50-second time limit.
Protocol TCP # specifies the forwarding protocol type to check realserver status, including tcp and udp
Real_server 172.25.7.2 80 {# configure the service node
Weight 1 # configures the weight of the service node. The weight is represented by a number. The larger the number, the weight.
The higher the value, the size of the weight can distribute different loads for servers with different performance, higher weights for servers with high performance, and relatively lower weights for servers with lower performance. in this way, the system resources are used and allocated reasonably.
Status detection setting section of TCP_CHECK {# realserve (in seconds)
Connect_timeout 3 # 3 seconds No response timeout
Seconds of nb_get_retry 3 # failure retry
Delay_before_retry 3 # retry delay
}
}
Real_server 172.25.7.3 80 {
Weight 1
TCP_CHECK {
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
} # ipvsadm-ln
}
}
Note: the keepalived configuration file of the standby only changes the red font part!
# / etc/init.d/keepalived start # # launch keepalived
# iptables-F # # refresh the firewall configuration at startup (the current keepalived version needs to be refreshed)
Test:
# on the master / slave machine
# ip addr View Virtual ip addition
# ipvsadm-ln to view lvs connections
# arp-an | grep 100 # # check which host is in service
1. High availability test: stop the keepalived service on master and see if backup takes over.
two。 Load balancer test: visiting http://192.168.0.163, and seeing the page switching between two realserver indicates success! You can also check the details of the connection through ipvsadm-Lnc!
3. Failover testing: if the httpd service on the realserver is turned off at will, the Keepalived monitoring module can detect it in time, then shield the fault node, and transfer the service to the normal node for execution.
When the httpd of server2 stops, only server3 is detected by Keepalived.
Transfer to the local machine when both the httpd of server2 and 3 are stopped.
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.