Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Construction and setup of lvs-nat load balance

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following brings you lvs-nat Load Balancer construction and setting, hoping to bring you some help in practical application. Load Balancer involves many things, but there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to make an answer.

Building a network environment:

Two RS hosts, virtual machine NIC set to host-only mode:

RS1 NIC: 192.168.1.11

RS2 NIC: 192.168.1.12

A scheduler, NIC 1 set to network bridge, NIC 2 set to host-only mode;

Network card 1: VIP: 172.18.11.111

Network card 2: DIP: 192.168.1.1

Install web services and provide test pages:

Set the RS1 and RS2 hosts separately

]# vim /var/www/html/index.html

RS1-192.168.1.11

]# vim /var/www/html/index.html

RS2-192.168.1.12

Point gateway to DIP on both RS:

]# route add default gw 192.168.1.1

On Director:

Turn on the core forwarding function of the NIC; it is permanently valid:

]# vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

]# sysctl -p Reread configuration file to make settings effective

At this time, in the Director stand-alone test, access RS1, RS2;

]# curl http://192.168.10.11

]# curl http://192.168.10.12

Set cluster rules in Director:

]# ipvsadm -A -t 172.18.11.111:80 -s rr

]# ipvsadm -a -t 172.18.11.111:80 -r 192.168.1.11 -m

]# ipvsadm -a -t 172.18.11.111:80 -r 192.168.1.12 -m

Testing Cluster Scheduling in Virtual Machines: Access VIP:

The above completes a scheduler, which can schedule two real Cloud Virtual Machine on the backend respectively;

Below, set up php service, deploy a forum program Discuz_X3.1_SC_UTF8.zip, and do shared storage, set up database:

mysq database NIC 2 set to host only

Network card 2: 192.168.1.14

Database Host:

Install mariadb, create discuz user, password discuz and authorize to two RS:

]# yum -y install mairadb-server

]# systemctl start mairad.servic

]# mysql

> GRANT ALL ON *.* TO discuz@192.168.11.11 IDENTIFIED BY 'discuz';

> GRANT ALL ON *.* TO discuz@192.168.11.12 IDENTIFIED BY 'discuz';

> CREATE DATABASE discuzdb;

On both RS:

Install php package that php works as http module, then install php-mysql package so php can call mysql interface to communicate with mysql database;

]# yum -y install php php-mysql

Use nfs service to provide shared storage on RS2, install nfs-utils and start nfs service

]# yum -y install nfs-utils

]# systemctl start nfs.service

Create a shared directory on RS2 and export:

]# mkdir /php

]# vim /etc/exports

/php 192.168.1.0/24(rw,no_root_squash)

]# exportfs -r

On RS1, mount the shared directory exported by RS2:

]# mkdir /php

]# mount -t nfs 192.168.1.12:/php /php

Change http profile on both RS:

]# vim /etc/httpd/conf/httpd.conf

At this point, the/php directory on both RS has successfully shared the directory;

In this directory, create a php test page:

]# vim /php/index.php

Available in test browser: 172.18.11.111

Display:

Test PHP connection mysql test page again:

]# vim /php/index.php

Available in test browser: 172.18.11.111

Display:

Install forum program Discuz_X3.1_SC_UTF8.zip;

]# cd /php

]# unzip Discuz_X3.1_SC_UTF8.zip

]# chmod -R o+w config data uc_client uc_server

Available in test browser input: 172.18.11.111/upload

Display:

Click,"I agree"

Click "Next", you can click all the way down;

Enter the IP address of the database and the login user and password set;

Administrator information, can be filled in freely;

At this point, deployment is complete;

After reading the above about lvs-nat Load Balancer setup and settings, if you still have anything to know, you can find something you are interested in the industry information or find our professional technical engineers to answer. Technical engineers have more than ten years of experience in the industry.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report