Lvs-nat based on NFS storage deployment Discuz

Source: Internet
Author: User
Tags php mysql node server

LVS (Linux virtual Server): Linux virtualization server. It is mainly used for load balancing scenarios, to solve the pressure of single node server, and improve the disaster tolerant ability.

LVS according to the way of implementation is divided into: Lvs-nat, LVS-DR, Lvs-tun, Lvs-fullnat

Lvs-nat Features:

1. The dispatcher director configures the dual network card, one piece configures the external network IP as the VIP, the other one NIC is the dip, must and the back end server Rs's rip in the same network, and the Rip Gateway must point to the dip

2. Request messages and response messages are passed through the director, so the director may become a bottleneck if under high load conditions

3. The client does not know the backend host when requesting the resource, so it can hide the backend server and prevent the attack.

The scene of this experiment is to use the Lvs-nat model to build a discuz, a total of four hosts, a LVS host to provide load balancing, two lamp host provides access, an NFS provides remote Storage

Lvs-nat Server LAMP1 Server LAMP2 Server Server for NFS
dip: Rip1: rip2:

Host 4: As Server for NFS

1. Start the NFS service

Systemctl Start Nfs.service

2. Create a directory dedicated to remote sharing


3. Define a host that can access this NFS

vim/etc/exports/web/html (rw), (rw)

4. Re-export the file system


5. Create a user and specify the UID number

Useradd-u Web

6. Modify user permissions so that users can work with the directory

Setfacl-m u:web:rwx/web/html

Host 3: As an HTTP PHP MySQL server

1. Create a directory to mount NFS specifically


2. Create a user with the same ID as the NFS server

Useradd-u Web

3. Mount remote NFS to local

Mount-t NFS

4. Check that the mount status is normal


5 Installing HTTP PHP mysql

Yum-y Install http PHP php-mysql mariadb

6. Modify the configuration in the http.conf

ServerName "/hm/html"

7. Start the HTTPD service

Systemctl Start Httpd.service

8. Create a index.html in/hm/html and write some characters

echo "httpd test" >/hm/html

9. Start the database

Systemctl Start Mariadb.service mysql_secure_installation

9. Enter database with root user and password to create Discuz database, Telnet host

Mysql-uroot-p CREATE DATABASE Disdb; GRANT all on disdb.* to ' Disuser ' @192.18.%.% identified by ' dis '; FLUSH privileges;

10. Test if PHP can connect to mariadb. The Index.index in the/hm/html/directory is index.php

<?php $conn =mysql_connect (' ', ' disuser ', ' dis ');        if ($conn) echo "OK"; else echo "failure";? >

11. Login Browser Enter hostname to see if it is OK

12. Download Discuz to/hm/html/dis directory, unzip and create the connection


13. Enter/hm/html/dis/upload/config to modify config_global_default.php

Vim config_global_default.php

Modify one of the Dbhost dbuser DBPW diname

650) this.width=650; "src=" Http:// "title=" Lvs-nat experiment. PNG "alt=" Wkiom1c7kfgbtbfnaaahitwg2oe470.png "/>

14. Modify the data Uc_server under Config

chmod 777 Datachmod 777 Uc_server

15. Start the browser type step-by-step installation is complete.

16. Modify DocumentRoot

DocumentRoot "/hm/html/dis"

Host 2 configuration and host 3 are basically consistent

Host 1:lvs Server

1. Installing Ipvsadm

Yum-y Install Ipvsadm

2. Add a forwarding Rule

Ipvsadm-a-T rripvsadm-a-T 0-r

3. View the LVS rules table


4. Turn on the route forwarding function

Vim/etc/sysctlnet.ipv4.ip_forward = 1 Sysctl-p

5. See if the firewall and SELinux are turned off


6. Open the browser and type


1. In the process of testing LVS, you can put different contents in the index.php of two lamp documetroot to see if the load balancing is based on RR.

The director in 2.lvs-nat needs to turn on the route forwarding feature.

The 3.NFS server needs to grant the corresponding host to mount the corresponding directory, and the client must have an account with the same UID as the NFS service.

Lvs-nat based on NFS storage deployment Discuz

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: 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.