Load balancing for multiple Web servers with NFS sharing (reproduced, not implemented)

Source: Internet
Author: User

First, the purpose of the experiment

This experiment mainly solves the problem of load balancing and data synchronization of multiple Web servers through NFS.

Second, the experimental environment:

As shown in the topology diagram above, the MySQL database is installed on the Server1, and Server2 and Server3 share the MySQL database on the Server1 through NFS, while the source of the Discuz site is stacked on the Server1, That is: Server1 only runs MySQL, while Server2 and Server3 only run PHP and Apache. This ensures that users can get the same results regardless of access to server2 or Server3.

Third, the experimental steps

1, the Server1 configuration

(1) First installed on the Server1 MySQL (in this case, the green version for example, please refer to the installation of the Post lamp), this is not detailed here.

(2) Use NFS to share the extracted files of MySQL with Discuz.

Click ( here ) to collapse or open

    1. #yum-y Install Nfs-utils

    2. #service portmap start #vim/etc/exports (add the following in this file)

    3. /usr/local/mysql 172.16.66.1 (rw)

    4. /usr/local/mysql 172.16.77.1 (rw) #exportfs-arv to share the discuz, so you need to edit the/etc/exports file #vim/etc/exports Add the following in this file:

    5. /web 172.16.66.1 (rw)/web 172.16.77.1 (rw)/Note to place discuz files in the/web directory beforehand.

    6. #exportfs-arv

2, the Server2 configuration

(1) To install apache-2.4.2, please refer to the compilation and installation of the post lamp.
(2) Attach the Server1 shared file to this machine.

Click ( here ) to collapse or open

    1. #mkdir/mysql (Mount the Server1 MySQL file in this directory)

    2. #mkdir/web (Mount the Discuz in Server1 to this directory)

    3. #vim/etc/fstab Add the following in this file: 172.16.58.1:/usr/local/mysql/mysql NFS default 0 0 172.16.58.1:/web/web NFS default 0 0

    4. #mount-A

(3) Compile and install PHP. Note the path to the--with-mysql and--with-mysqli specified by PHP.

Click ( here ) to collapse or open

    1. # Tar XF php-5.4.4.tar.bz2

    2. # CD php-5.3.14

    3. #./configure--prefix=/usr/local/php--with-mysql=/mysql--with-openssl--with-mysqli=/mysql/bin/mysql_config-- Enable-mbstring--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml-- With-apxs2=/usr/local/apache/bin/apxs--with-mcrypt--with-config-file-path=/etc--with-config-file-scan-dir=/etc /PHP.D--with-bz2

    4. # make

    5. # Make Test

    6. # Make Intall

3. Server3 Configuration

The configuration of the Server3 is the same as the Server2 configuration, not to repeat here.

Iv. Experimental Results and validation

1, enter the 172.16.66.1/install in the browser (note the first time must be input), the following page appears:

2, go to the next step to enter the following page:

Note that the above page is the result of executing the following command, do the following on Server1:

Click ( here ) to collapse or open

    1. #setfacl-M u:daemon:rw./config.inc.php #setfacl-M u:daemon:rwx./attachments//forumdata/./forumdata/cache/./ forumdata/templates/./forumdata/threadcaches/./forumdata/logs/./uc_client/data/cache/

3. Click Next to enter the following page:

If the following interface appears, the following steps are required to create the database and user in Server1 MySQL data:

If this happens, do the following on the server:

Click ( here ) to collapse or open

    1. mysql> CREATE DATABASE Discuz;

    2. mysql> create user ' discuz ' @172.16.77.1 identified by ' Redhat ';

    3. mysql> create user ' discuz ' @172.16.66.1 identified by ' Redhat ';

    4. Mysql> Grant all on discuz.* to ' Discuz ' @172.16.66.1;

    5. Mysql> Grant all on discuz.* to ' Discuz ' @172.16.77.1;

    6. mysql> flush Privileges;

4, after the click on it, the end will be the following interface:

5, register a user and post on it, this is the operation in Server3 as follows:

In the user login Server2 this host can see the following effect:

This concludes the experiment!!!


Load balancing for multiple Web servers with NFS sharing (reproduced, not implemented)

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.