Linux clusters and LVs

Source: Internet
Author: User
Tags gpg node server

Clusters and LVs

Cluster:
A group of computers interconnected by high-speed networks and managed in a single-system mode
Price many servers are centralized to provide the same service, and the client looks like there is only one server
A relatively high return on performance, reliability, and flexibility at a lower cost
The core technology of task control room cluster system

Cluster Purpose:
Improve performance: such as compute-intensive applications, such as: Weather forecasts, nuclear test simulations
Lower costs: Less expensive than the million-dollar supercomputer
Increased scalability: Simply increase the cluster nodes to
Enhanced reliability: Multiple nodes perform the same function to avoid a single point of failure

Cluster classification:
High-performance Compute cluster HPC: Solve complex scientific problems with parallel applications developed in clusters
Load Balancing (LB) cluster: Client load is distributed as evenly as possible in a computer cluster
High-availability (HA) clusters: Avoid single points of failure, which can be quickly migrated when a system fails

Example: Preparing the lamp separation structure
Environment: Prepare two Web servers and a single database server
mysql:192.168.4.1
web1:192.168.4.2
web2:192.168.4.3

MySQL side
[[email protected] ~]# yum-y install mysql-server
[[email protected] ~]#/etc/init.d/ Mysqld start; Chkconfig mysqld on
mysql> grant all on * * to ' admin ' @ ' 192.168.4.2 ' identified by ' 123456 ';
mysq L> Grant All on * * to ' admin ' @ ' 192.168.4.3 ' identified by ' 123456 ';


Web-side
[[email protected] ~]# yum-y install httpd php php-mysql
[[email protected] ~]#/etc/init.d/httpd start; Chkconfig httpd on
[[email protected] ~]# yum-y install httpd php php-mysql
[[email protected] ~]#/etc/init.d/httpd start; Chkconfig httpd on
Installing Discuz in Web1
[Email protected] ~]# Unzip Discuz_x3.2_sc_utf8.zip
[Email protected] ~]# MV upload//var/www/html/bbs
[Email protected] ~]# chown-r Apache config/data/uc_*
[email protected] ~]# Firefox Http://192.168.4.2/bbs
Database server: 192.168.4.1 (MySQL server IP)
Database name: Hydra (the function that comes with it automatically creates Zeku)
Database user name: admin (user authorized on MySQL server)
Database Password: 123456
View the database on the MySQL side
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| Hydra |
| MySQL |
| Test |
+--------------------+

In the Web-side test register a user named Hydra and post,
Posts subject to HYDRA content as Anonymous!!!!!!

View user data on MYSQ server, view post content
Mysql> select Uid,username,password,email from pre_common_member;
+-----+------- ---+----------------------------------+----------------+
| uid | username | password | email |
+-----+----------+----------------------------------+----------------+
| 1 | admin | eab19088f6ff65eb97530281c7d49f3e | [Email protected] |
| 2 | hydra | f0b02c4f4fe8adf540bf7ed8a7522d03 | [Email protected] |
+-----+----------+----------------------------------+----------------+
Mysql> Select Author,subject, Message from Pre_forum_post;
+--------+---------+-----------------------+
| author | subject | message |
+--------+---------+---------- -------------+
| hydra | hydra | ANONYMOUS!!!!!! |
+--------+---------+-----------------------+

On the second WEB2 server
The first WEB1 server's BBS project is packaged and copied to the second web1 server.
[Email protected] html]# TAR-CZF bbs.tar.gz bbs/
[Email protected] html]# SCP bbs.tar.gz 192.168.4.3:/var/www/html/
[Email protected] html]# TAR-XF bbs.tar.gz
[[email protected] html]# Firefox Http://192.168.4.3/bbs (test access on the second Web server and register for user testing)
View on MySQL server
Mysql> select Author,subject,message from Pre_forum_post;
+-----------+----------+-----------------------+
| Author | Subject | message |
+-----------+----------+-----------------------+
| Hydra | Hydra | ANONYMOUS!!!!!! |
| | | |
| Anonymous | Ha ha ha | Ha ha ha ha ha |
+-----------+----------+-----------------------+

——————————————————————————————————————————————————————————————————

Lvs

LVS Project
Linux Virtual Server (LVS) created by Dr. Zhangwensong
LVS enables highly available, scalable network services such as Web,mail,cache and media
The ultimate goal is to use Linux operating system and LVS cluster software to achieve a high-availability, high-performance, low-cost server application cluster

Load Balancer Cluster LB
Hardware: F5
Software: Lvs,haproxy

LVS Cluster composition
Front End: Load balancer layer consisting of one or more load schedulers
Middle: Server group layer, consisting of a group of actually running application servers
Bottom: Data shared storage tier, providing storage area for shared storage space

LVS Terminology
Director Server: Dispatch server, distributing load to the server of real server
Real server: True servers, servers that truly provide applications
VIP: Virtual IP address, the virtual IP address that is advertised to the user for access
RIP: Real IP address, IP address used on cluster nodes
DIP: The IP address of the Scheduler Connection node server

Load Balancing scheduling algorithm
LVS currently implements 10 scheduling algorithms
There are 4 types of scheduling algorithms commonly used
Polling
Weighted polling
Minimum connection
Weighted least connections


Example: Configuring LVS NAT Mode
Environment: Prepare a LVS server, modify the gateway for both Web servers, point to Dir
To turn on the routing forwarding function of the scheduler
eth0:192.168.4.4
eth2:201.1.1.4

Web-side
[Email protected] ~]# vim/etc/sysconfig/network
gateway=192.168.4.4
[Email protected] ~]# vim/etc/sysconfig/network
gateway=192.168.4.4
Scheduler side
[[email protected] ~]# echo 1 >/proc/sys/net/ipv4/ip_forward (Temporary effect)
[[email protected] ~]# vim/etc/sysctl.conf (permanent entry)
Net.ipv4.ip_forward = 1
[[email protected] ~]# sysctl-p (Effective)
Installing LVS
[[email protected] ~]# Vim/etc/yum.repos.d/rhel6.repo (need to add Yum source)
[Rhel]
Name=linux NSD
Baseurl=file:///root/myiso/loadbalancer (need to add this path, yum defaults to find the server this library)
Enabled=1
Gpgcheck=1
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-redhat-release
[[email protected] ~]# yum-y install ipvsadm (installing LVS)

Ipvsadm usage
IPVSADM-LN: Viewing scheduling rules
Create a virtual server
-A: Adding virtual servers
-T: Set cluster address (vip,virtual IP)
-S: Specifies the load scheduling algorithm
Add, remove server node
-A: Add a real server
-D: Remove the real server
-R: Specify the address of the real server
-M: Using NAT mode,-g,-i corresponds to Dr,tun mode respectively
-W: Sets the weight for the node server, which defaults to 1

[[email protected] ~]# ipvsadm-a-t 201.1.1.4:80-s WRR (WRR enhanced polling algorithm)
[[email protected] ~]# ipvsadm-a-T 201.1.1.4:80-r 192.168.4.2-m-W 2
[Email protected] ~]# ipvsadm-a-t 201.1.1.4:80-r 192.168.4.3-m
[[email protected] ~]# Firefox Http://201.1.1.4/bbs (test access)
[Email protected] ~]# IPVSADM-LN
IP Virtual Server version 1.2.1 (size=4096)
Prot Localaddress:port Scheduler Flags
Remoteaddress:port Forward Weight activeconn inactconn
TCP 201.1.1.4:80 WRR
-192.168.4.2:80 MASQ 2 0 0
-192.168.4.3:80 MASQ 1 0 0
[[email protected] jiaobeng]# vim web_start.sh (write a script, scan the server, if there is a problem with the server to kill the secondary server, no problem is added, the dead loop is executed every 5 seconds)
#!/bin/bash
Vip=201.1.1.4:80
rip1=192.168.4.2
rip2=192.168.4.3
While [1]
For IP in $RIP 1 $RIP 2
Do
web_stat=$ (nmap-n-st $ip-P 2>/DEV/UNLL | grep open)
ip_in_lvs=$ (Ipvsadm-ln | grep $ip)
If [-z] $web _stat "-a-n" $ip _in_lvs "];then
Ipvsadm-d-T $VIP-R $IP
elif [-N "$web _stat"-a-z "$ip _in_lvs"];then
Ipvsadm-a-T $VIP-R $IP-M
Fi
Done
Done
[[email protected] jiaobeng]# chmod +x web_start.sh (plus executive rights)
[[Email protected] ~]# Service Ipvsadm Save (save, no configuration after restart service)


Example: Configuring the LVS Dr Mode
Environment: First, the NAT environment of the LVS connected to the extranet IP removal, empty the LVS NAT configuration
Configure the VIP for the physical NIC on the LVS,
Configure the VIP for lo on both real servers
LVS End
[[email protected] ~]# vim/etc/sysconfig/network-scripts/ifcfg-eth2 (delete the ipaddr=201.1.1.4)
[[email protected] ~]#/etc/init.d/ipvsadm restart (empty rules)
[[email protected] ~]# ipvsadm-d-t 201.1.1.4:80 (empty after disk)
[[email protected] network-scripts]# CP ifcfg-eth0 ifcfg-eth0:0 (copy nic)
[Email protected] network-scripts]# vim ifcfg-eth0:0
device=eth0:0 (only modify these two lines, others unchanged)
ipaddr=192.168.4.100
[Email protected] ~]#/etc/init.d/network restart
[Email protected] ~]# ifconfig
eth0:0 Link encap:ethernet HWaddr 54:52:01:01:04:01
inet addr:192.168.4.100 bcast:192.168.4.255 mask:255.255.255.0
Real server side (two do the same operation)
[email protected] network-scripts]# CP Ifcfg-lo ifcfg-lo:0
[Email protected] network-scripts]# vim ifcfg-lo:0
device=lo:0
ipaddr=192.168.4.100
netmask=255.255.255.255
network=192.168.4.100
broadcast=192.168.4.100
Onboot=yes
[Email protected] network-scripts]#/etc/init.d/network restart
Configure Real server-side kernel parameters (two do the same)
[Email protected] ~]# Sysctl-a | grep arp_i
[[email protected] ~]# echo ' nat.ipv4.conf.all.arp_ignore = 1 ' >>/etc/sysctl.conf
[[email protected] ~]# echo ' nat.ipv4.conf.lo.arp_ignore = 1 ' >>/etc/sysctl.conf
[Email protected] ~]# Sysctl-a | grep arp_a
[[email protected] ~]# echo ' net.ipv4.conf.all.arp_announce = 2 ' >>/etc/sysctl.conf
[[email protected] ~]# echo ' net.ipv4.conf.lo.arp_announce = 2 ' >>/etc/sysctl.conf
[[email protected] ~]# sysctl-p (Effective)
LVS Terminal configuration
[[email protected] ~]# ipvsadm-a-T 192.168.4.100:80-s LC
[Email protected] ~]# ipvsadm-a-t 192.168.4.100:80-r 192.168.4.2
[[email protected] ~]# ipvsadm-a-T 192.168.4.100:80-r 192.168.4.3-g-W 2 (-G route mode W 2 weight 2)
[[email protected] ~]# ipvsadm-ln (view rules)
IP Virtual Server version 1.2.1 (size=4096)
Prot Localaddress:port Scheduler Flags
Remoteaddress:port Forward Weight activeconn inactconn
TCP 192.168.4.100:80 LC
-192.168.4.2:80 Route 1 0 0
-192.168.4.3:80 Route 2 0 0
[[email protected] ~]# Firefox Http://192.168.4.100/bbs (test access)

————————————————————————————————————————————————————————————————————————————————————————

Linux clusters and LVs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.