Lvs-nat Load Balancing Experiment

Source: Internet
Author: User

Build network environment:

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

RS1 Network card: 192.168.1.11

RS2 Network card: 192.168.1.12

A dispatcher, Nic 1 is set to Network Bridge, Nic 2 is set to host mode only;

Nic 1:vip:172.18.11.111

Nic 2:dip:192.168.1.1


Install the Web service and provide a test page:

Set the RS1 and RS2 hosts separately

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

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


Point the gateway to the dip on both RS:

]# route add default GW 192.168.1.1


To operate on Director:

Turn on the network card core forwarding function, permanently valid:

]# vim/etc/sysctl.conf

Net.ipv4.ip_forward = 1


]# Sysctl-p Reread the configuration file to make the settings effective


At this time, in the director of separate stand-alone test, Access RS1, RS2;

]# Curl http://192.168.10.11

]# Curl http://192.168.10.12


Set up 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


To test the cluster schedule in a virtual machine: Access VIP:

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M01/80/2C/wKiom1c5xxzS_RTtAABNhqlQuyw496.png "title=" image 1. PNG "alt=" Wkiom1c5xxzs_rttaabnhqlquyw496.png "/>

The above completed a scheduler, can be scheduled for the back end of the 2 real servers;


Next, build PHP services, deploy a forum program Discuz_x3.1_sc_utf8.zip, and do shared storage to build a database:

MYSQ database Nic 2 is set to host only

Nic 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 [e-mail protected] identified by ' discuz ';

> GRANT All on * * to [e-mail protected] identified by ' discuz ';

> CREATE DATABASE discuzdb;


On both RS:

Install PHP package PHP as HTTP module work, and then install the Php-mysql package so that PHP call MySQL interface to communicate with the MySQL database;

]# yum-y Install PHP php-mysql


Use NFS services on RS2 to provide shared storage, install Nfs-utils, and start NFS services

]# 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 for the RS2 export:

]# mkdir/php

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


Change the HTTP configuration file on both RS:

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

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M01/80/29/wKioL1c5zJ3AlJaHAAArFGxQNI0176.png "title=" Image 4. PNG "alt=" Wkiol1c5zj3aljahaaarfgxqni0176.png "/>


At this time, the/php directory on the two RS has been successfully shared directory;

Under this directory, create a PHP test page:

]# vim/php/index.php

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/80/2C/wKiom1c5zX6Q6PF4AAAFiO58fBs211.png "title=" image 5. PNG "alt=" Wkiom1c5zx6q6pf4aaafio58fbs211.png "/>

Can be entered in Test browser: 172.18.11.111

Show:

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/80/2C/wKiom1c5znnDkd6kAACBfI_U2x0739.png "title=" image 6. PNG "width=" 748 "height=" 489 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:748PX;HEIGHT:489PX; "alt=" Wkiom1c5znndkd6kaacbfi_u2x0739.png "/>

Then test the PHP connection to MySQL's test page:

]# vim/php/index.php

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/80/29/wKioL1c5z-6xywROAAAidKHrqRM149.png "title=" Image 8. PNG "alt=" Wkiol1c5z-6xywroaaaidkhrqrm149.png "/>

Can be entered in Test browser: 172.18.11.111

Show:

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/80/2C/wKiom1c5z0CwMOjOAAAspZribyc350.png "title=" Image 9. PNG "alt=" Wkiom1c5z0cwmojoaaaspzribyc350.png "/>


Installation 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


Can be entered in Test browser: 172.18.11.111/upload

Show:

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/80/2C/wKiom1c50CXxfCKSAAF_86juAbs984.png "title=" image 10. PNG "width=" 775 "height=" 507 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:775PX;HEIGHT:507PX; "alt=" Wkiom1c50cxxfcksaaf_86juabs984.png "/>

Click, "I Agree"

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M02/80/2C/wKiom1c50HWxTbECAAEIBJ_VIRw686.png "title=" image 11. PNG "width=" 767 "height=" 585 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:767px;height:585px; "alt=" Wkiom1c50hwxtbecaaeibj_virw686.png "/>





650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M02/80/29/wKioL1c50d6DDETqAAECCsHI-y8789.png "title=" image 12. PNG "width=" 712 "height=" 659 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:712PX;HEIGHT:659PX; "alt=" Wkiol1c50d6ddetqaaeccshi-y8789.png "/>

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

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/29/wKioL1c5026QR2iBAADKfT86ddM472.png "style=" width : 780px;height:433px; "title=" Image 13.png "width=" 780 "height=" 433 "border=" 0 "hspace=" 0 "vspace=" 0 "alt=" Wkiol1c5026qr2ibaadkft86ddm472.png "/>


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

Administrator information, you can fill in freely;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/2C/wKiom1c50orQA7mAAAEN85IGA2A535.png "style=" width : 755px;height:662px; "title=" Image 14.png "width=" 755 "height=" 662 "border=" 0 "hspace=" 0 "vspace=" 0 "alt=" Wkiom1c50orqa7maaaen85iga2a535.png "/>

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/80/2C/wKiom1c50pLAVbauAAEro9_KkBU955.png "style=" width : 767px;height:590px; "title=" Image 15.png "width=" 767 "height=" 590 "border=" 0 "hspace=" 0 "vspace=" 0 "alt=" Wkiom1c50plavbauaaero9_kkbu955.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/80/29/wKioL1c505qSybHJAARTMIzQ024905.png "style=" width : 759px;height:643px; "title=" Image 16.png "width=" 759 "height=" 643 "border=" 0 "hspace=" 0 "vspace=" 0 "alt=" Wkiol1c505qsybhjaartmizq024905.png "/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/29/wKioL1c506CA8Qs_AAEQgWPZNlg425.png "style=" width : 724px;height:434px; "title=" Image 17.png "width=" 724 "height=" 434 "border=" 0 "hspace=" 0 "vspace=" 0 "alt=" Wkiol1c506ca8qs _aaeqgwpznlg425.png "/>

At this point, complete the deployment;





Lvs-nat Load Balancing Experiment

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.