Use of load balancing
Task 1: Configure the back-end web server (ECS server)
Task 2: Create a load balancing instance
Task 3: Configure a load balancing instance
Task 4: Configure session persistence
First, select two ECSs when purchasing two ECSs North China 1 Zhangjiakou, Availability Zone A.
Task 1: Configure the backend web server
Log in to two ECS servers remotely
安装httpd,提供默认主页,启动服务。(两台服务器都要安装
[root@iZ2ze7mgcamczda1x1plejZ ~]# yum install httpd -y
[root@iZ2ze7mgcamczda1x1plejZ ~]# echo "This is web1 test page." > /var/www/html/index.html
[root@iZ2ze7mgcamczda1x1plejZ ~]# systemctl start httpd
The security group allows port 80 inbound, and the two ECS servers use the same security group, which can be configured only once
Website Access Test
Task 2: Create a load balancing instance
Steps
- Log in to the load balancing management console.
- In the left navigation bar, click Instances > Instance Management.
- On the instance management page, click Create Load Balancer.
- On the load balancing SLB purchase page, configure the load balancing instance as needed
Task 3: Configure the load balancing instance
Steps
- Log in to the load balancing management console.
- On the instance management page, click Listener Configuration Wizard in the Operation column of the instance to configure listener.
- On the Protocol & Monitoring tab, configure monitoring rules according to the following information, and keep the default options for other configurations.
Select the load balancing protocol: This tutorial selects the TCP protocol.
Listening port: the front-end protocol and port of the load balancing system used to receive requests and forward requests to back-end servers.
The port is set to 80 for this tutorial.
Advanced configuration:
Enable monitoring bandwidth speed limit: Set different bandwidth peaks to limit the service capabilities that different applications of the backend ECS instance can provide to the outside world.
The public network load balancing instance created in this tutorial is billed by traffic and is not limited by peak bandwidth, so no configuration is required.
Scheduling algorithm: Load Balancer supports the following three scheduling algorithms. In this tutorial, round robin is selected. - Click Next, select the default server group under the Backend Servers tab, click Continue to add, add backend servers
On the My Servers page, check the ECS01 and ECS02 instances created before, and click Next.
Configure the weight, the greater the weight, the more requests forwarded, the default is 100, just keep the default value.
Click Add. Under the default server tab, configure the backend protocol port. The backend port opened on the ECS instance to receive requests
can be repeated in the same load balancing instance. This tutorial port is set to 80 - Click Next to configure the health check. This tutorial uses the default values.
After the health check function is enabled, when there is a problem with the health check of an ECS at the backend, the load balancing service will forward the request to other ECSs with normal
health checks, and when the ECS returns to normal operation, the load balancing service will automatically restore it. request forwarding. - Click Next to enter the Configuration Review tab, and click Submit.
Enter the service address of the load balancing instance in the browser to test the load balancing service
Task 4: Configure session persistence
Test again
After the experiment is completed, release resources to avoid continued billing.