In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Cluster and storage
Brief introduction (what is a cluster)
A group of computer groups interconnected through a high-speed network and managed in a single system mode
Bring many servers together to provide a service that looks like there is only one server on the client
Relatively high benefits in terms of performance, reliability and flexibility can be achieved at a lower cost.
Task scheduling is the core technology in cluster system.
Cluster purpose:
Improve performance: compute-intensive applications such as weather forecasting, nuclear test simulation
Reduce costs: cheaper than million-dollar supercomputers
Improve scalability: as long as you add cluster nodes
Enhanced reliability: multiple nodes perform the same function to avoid single point of failure
Cluster classification:
High availability Computing Cluster HPC
Solve complex scientific problems through parallel applications developed in clusters
Application: scientific calculation in weather, aviation, navigation and other scientific fields
Load balancing (LB) cluster
The client load is distributed as evenly as possible in the computer cluster.
High availability (HA) cluster
Avoid a single point of failure. When a system fails, it can migrate quickly.
Implementation of LB: LVS software Haproxy software Nginx
Implementation of HA: keepalived software
Introduction to the LVS project:
Linux Virtual Server (LVS) was created by Zhang Wensong during his PhD at National University of Defense Science and Technology.
LVS can implement highly available and scalable network services such as web, Mail, Cache and Media.
The ultimate goal is to realize a server application cluster with high availability, high performance and low cost by using Linux operating system, LVS cluster and LVS cluster software.
LVS cluster composition
Front end: load balancing layer, consisting of one or more sets
Middle: server group layer, consisting of a set of servers that actually run application services
Ground side: a data sharing storage layer that provides a storage area for shared storage space
LVS terminology
Director Server: degree server
Distribute the load to Real server's server
Real server: real server
A server that really provides application services
VIP: virtual IP address
The delicate IP address published for users to visit
RIP: real IP address
Use IP addresses on cluster nodes
DIP: the IP address of the node server to which the scheduler connects
LVS working mode
VS/NAT
Virtual server realized by network address translation
VS/DR
Directly use routing technology to realize virtual server
Node server needs to be configured with VIP, note MAC address broadcast
VS/TUN
Usually realize the virtual server through the tunnel
When different computer rooms in different locations need to provide services, you need to set LVS to VS/TUN mode.
LVS load balancing scheduling algorithm. Currently, 10 scheduling algorithms have been implemented.
Polling (Round Robin)
Weighted polling (Weighted Round Robin)
Minimum connection (Least Connections)
Weighted least connection (Weighted Least Connections)
LVS experiment (polling):
1. Configure LVS/NAT cluster
Host role:
Real server: hosts 52 and 53
Dispenser: host 54
Client: host 50
Storage services: host 51
Preparation for the experiment:
Dispenser: host 54
Eth0: private network IP address 192.168.4.54
Eth0: public network Ip address: 192.168.2.54
Enable the routing and forwarding function of the kernel
Real server
Host 52 eth0 192.168.4.52
Host Gateway: 192.168.4.54
Host: 53 eth0 192.168.4.53
Gateway: 192.168.4.54
Turn on host 54 kernel routing forwarding function
Sysctl-a | grep ip_forward / / check whether route forwarding is enabled. It is enabled by default.
Vim / etc/sysctl.conf
Net.ipv4.ip_forward = 1 / / newly added
Real server:
The route command is used to display and set the network routing table in the Linux kernel, and the routes set by the route command are mainly static routes.
Host 52ax 53: add Gateway
Route add default gw 192.168.4.54
Host 50: add gateway
Route add default gw 192.168.2.54
Note: route del default gw 192.168.4.54 / / misconfigured to delete with this command
Route-n / / View the routing table
Configure dispenser host 54
Ipvsadm usage:
A
Add a virtual server
-t
Set the cluster address (VIP,Virtual IP)
S
Specify load scheduling algorithm
-a
Add a real server
-d
Delete a real server
-r
Specify real server (real server)
-m
Use NAT mode;-g and-I correspond to DR and TUN mode, respectively
-w
Set the weight for the node server. Default is 1.
-C
Clear all ipvsadm configurations
-S
Permanently save the configuration
-E
Change scheduling algorithm
-e
-Z
Clear (ipvsadm-Ln-- stats) counter
VIP address: the address at which services are provided.
Vip: 192.168.2.54
Rip: 192.168.4.52
192.168.4.53
1. Install the ipvsadm package
Yum-y install ipvsadm.x86_64
two。 Rr scheduling algorithm and polling algorithm are used to create virtual service; wrr
] # ipvsadm-A-t 192.168.2.54 80-s rr
3. Add server node (real server) with-m in NAT mode
] # ipvsadm-a-t 192.168.2.54 VRV 80-r 192.168.4.52 Rd 80-m
] # ipvsadm-a-t 192.168.2.54 virtual 80-r 192.168.4.53 virtual 80-m
4. Save ipvs configuration
Ipvsadm- S > / etc/sysconfig/ipvsadm-config
5. View IPVS
] # ipvsadm-Ln
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.4.54:80 rr
-> 192.168.4.52 Masq 80 1 0
-> 192.168.4.53 Masq 80 1 0
Forward: distribution mode
ActiveConn: the number of active connections
Weight: weight. In load balancing, the higher the value is, the more times the distribution will be.
InActConn:
Verify:
Ipvsadm-Ln-- stats
Prot LocalAddress:Port Conns InPkts OutPkts InBytes OutBytes
TCP 192.168.2.54:80 5 30 20 1980 2495
-> 192.168.4.52 purl 80 2 12 8 792 998
-> 192.168.4.53 purl 80 3 18 12 1188 1497
Conns: number of requested connections
InPkts: incoming packets
OutPkts: outgoing packet
InBytes: number of bytes of data coming in
OutBytes: the number of bytes of data coming in and out
Watch-n 1 ipvsadm-Ln-- stats / / watch-n 1 command refresh subsequent commands in 1 second
Manage the cluster
Delete the configuration of nat mode
] # ipvsadm-d-t 192.168.2.54 80-r 192.168.4.53
Add realserver (NAT)
] # ipvsadm-a-t 192.168.2.54 80-r 192.168.4.53-m
Modify scheduling algorithm
] # ipvsadm-E-t 192.168.2.54 80-s wrr
Modify the weight of real server
] # ipvsadm-e-t 192.168.2.54 80-r 192.168.4.53-w 2-m
Empty counter (ipvsadm-Ln-count of stats)
] # ipvsadm-Z
Clear all configurations
] # ipvsadm-C
Save all configurations
] # ipvsadm- S > / etc/sysconfig/ipvsadm-config
Restart the ipvsadm service
] # ipvsadm-S > / etc/sysconfig/ipvsadm
] # systemctl restart ipvsadm.service
Configure LVS/DR mode cluster
Principle: the request traffic is sent to the realserver by the dispatcher, and the response traffic is sent directly to the client by the server
Prepare:
Requirements: client access VIP address: 192.168.4.253 access website cluster
Configure dispenser 54
1. Bind the vip address 192.168.4.253 to the eth0 interface of this machine. Here, the command line is set to expire after a valid restart, and it will be sandwiched into the / etc/rc.load file to run automatically every time you boot.
] # ifconfig eth0:1 192.168.4.254/32
] # echo 'ifconfig eth0:1 192.168.4.254 echo 32' > / etc/rc.local
two。 Create a virtual service and use 192.168.4.253 as the VIP algorithm to use rr polling algorithm
] # ipvsadm-A-t 192.168.4.253 80-s rr
3. Add real server node,-g in DR mode
] # ipvsadm-a-t 192.168.4.253 virtual 80-r 192.168.4.52 virtual 80-g
] # ipvsadm-a-t 192.168.4.253 virtual 80-r 192.168.4.53 virtual 80-g
4. Save ipvs configuration
] # ipvsadm- S > / etc/sysconfig/ipvsadm-config
5. View IPVS
] # ipvsadm-Ln
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.4.253:80 rr
-> 192.168.4.52 Route 80 1 0
-> 192.168.4.53 Route 80 1 0
Configure readlserver 52 and 53
1. Modify the kernel parameters of the network interface, hosts 52 and 53, to ensure that each boot will take effect later, append the following names to / etc/rc.load
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
two。 Bind the vip address 192.168.4.253 to 32 on the local lo interface, and add hosts 52 and 53.
Ifconfig lo:1 192.168.4.253/32
Echo 'ifconfig lo:1 192.168.4.253ax 32' > / etc/rc.local
3. Run the web service
Host 52:yum-y install httpd
Echo xiao > / var/www/html/index.html
Host 53:yum-y install httpd
Echo 123 > / var/www/html/index.html
4. Verify:
On the client
Curl http://192.168.4.253
Extended LVS:
When LVS service does LB cluster, it cannot do health line check on realserver service.
The solution is to periodically execute monitoring scripts on the dispenser
Vim / root/checklvs.sh
#! / bin/bash
How to know if realserver 80 is open can be checked with nmap
Nmap-sS-n-p 80 192.168.4.53 in this command to filter open if it is open, either open or close, give its value to a variable
Nmap-sS-n-p 80 192.168.4.53 | grep open
Execute the command to delete realserver locally when realserver 80 is not open
Ipvsadm-d-t 192.168.4.253 80-r 192.168.4.x
Add the command to delete realserver to the virtual service when realserver 80 is open
Ipvsadm-a-t 192.168.4.253 ipvsadm 80-r 192.168.4.x:80
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.