LAMP Based on polling resolution + shared storage (NFS) in CentOS

Source: Internet
Author: User

Use five virtual machines to simulate a relatively simple production environment. Direct (poor painting, please forgive me)

I. Prerequisites:

1. Have a deep understanding of how DNS works.

2. Compile and install the software package

3. apache service workflow

4. Distinction between static and dynamic websites

5. Basic Database knowledge

6. Network Sharing

7. lvm

If you have the above knowledge, it will be clear at a glance (I just painted too bad)

Ii. Briefly describe the functions that can be implemented

1. If a large number of requests can pass DNS smart traffic configuration, reducing the separate pressure on the front-end APACHE1 and APACH2, the service will not be shut down when a front-end server fails.

2. mount a storage device on the PHP server. As a shared storage between PHP and APACHE, the NFS service can store static or dynamic resources for centralized management.

3. Use the mysql database to store business data.

Iii. Local Environment and the software version used

System: centos6.5.x86 _ 64

DNS: BIND 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6

HTTPD: Compile and install httpd-2.4.9.tar.bz2

PHP: Compile and install php-5.4.26.tar.bz2

Mysql: mysql is a two-step Installation tool. mysql-5.5.33.tar.bz2

Iv. configuration process

1. Configure the DNS server (only forward resolution)

Prerequisites:

Set IP address, host name, and DNS for DNS.

In this experiment, DNS configuration is as follows:

Host Name: www.dns.essun.com

IP Address: eth0: 192.168.1.50/24, eth0: 0 10.01.10.10/8

DNS: 192.168.1.50

Function: Resolves hosts in other domains.

① Use yum to install bind and modify the configuration file

#vim /etc/named.conf options { directory "/var/named" ; rrset-order { order random; }; }; # Rrset-order supports three parameters: fixed, random, and cyclic. # The fix will fix multiple A records in the order of configuration files # Random will randomly give # Cyclic will be given cyclically. zone "." IN { type hint; file "named.ca" ; }; zone "essun.com" IN { type master; file "essun.com.zone" ; }; zone "localhost." IN { type master; file "named.localhost" ; }; #include "/etc/named.rfc1912.zones"; #include "/etc/named.root.key";

② Configure the data region file (# vim/var/named/essun.com. zone)

③ Check the syntax after writing it.

Check syntax #named-checkconf Check data files #named-checkzone "essun.com" "/var/named/essun.com.zone"

④ If there is no error, you can start the DNS service and resolve it to other servers.

Test:

Note:

If you have any questions about the knowledge involved, see (DNS configuration)

⑤ Add DNS to the startup service list so that the service can be automatically started upon startup.

========================================================= Here DNS installation completed ====================================

2. Compile and install HTTPD

Prerequisites:

Configure Network Properties

First HTTPD server

Host Name: www.apache.essun.com

IP Address: eth0: 192.168.1.10/24

DNS: 192.168.1.50

Second HTTPD server

Host Name: www.apache.essun.com

IP Address: eth0: 192.168.1.20/24

DNS: 192.168.1.50

Install two APACH servers first. For details about the configuration process, refer to the APACHE compilation and installation section in the previous blog. The procedure is the same. Skipped here.

The content of the httpd-vhost file is as follows: (the two configuration files are identical)

Note:

When writing a VM to process php requests through fcgi, the address points to the IP address of the PHP server in this experiment.

② Add a common user to each server for access and sharing. The UID must be the same as the user UID created on the NFS server.

12 #useradd u 1000 http # echo "http" | passwd --stdin http

========================================================== ========================================================== ==========

3. Compile and install PHP

Prerequisites:

Configure Network Properties

Host Name: www.php.essun.com

IP Address: eth0: 192.168.1.30/24

DNS: 192.168.1.50

① For detailed installation and installation process, see (install PHP)

② Modify the IP address of the listener.

③ Install nfs.

1 #yum install nfs -y

④ Mount a new hard disk or partition to the directory of the PHP server site

⑤ Share this directory

⑥ Add a user

#useradd u 1000 http # echo "http" | passwd --stdin http

7. Authorize the shared directory

#chown -R root:http /www/web #chmod -R 775 /www/web

⑧ Start the NFS service

#service nfs start

=========================================================To this PHP and NFS after installation is complete ==================================

4. Install Mysql

Prerequisites

Configure Network Properties

Host Name: www.mysql.essun.com

IP Address: eth0: 192.168.1.40/24

DNS: 192.168.1.50

① For the installation process, see (mysql installation)

② Create a database

mysql>create database test ;

③ Authorized user

mysql>GRANT ALL PRIVILEGES ON test .* TO 'root' @ '192.168.1.30' IDENTIFIED BY 'mysql' ;

========================================================== ======= Mysql-related configuration completed ==============================

5. Test

1. Install discuz

Download the latest discuz version and decompress it to the PHP shared site directory.

Note:

Modify configuration file

#cd /www/web/upload/config #cp config_global_default.php config_global.php #vim config.global.php

Grant permissions to the upload directory (required for installation)

# Chmod 777 upload/

2. Mount the shared directory on PHP to the front-end

Note: The Mount method of APACHE1 is the same.

3. Install discuz

Access ghost through a browser.

4. Network Testing

Note:

My test environment

Physical Machine:

Use VMnet1 to connect to the DNS in the VM.

Other servers in the VM are connected through VMnet8

(After multi-party testing, we still use VMnet8, so that the 10-segment network does not take effect ...)

Server testing for physical machines and virtual machines

5. Forum Testing

APACHE1

APACHE2

FQDN

Note:

Because the FQDN of the two hosts is the same, the access to the host cannot be determined. Then I will use dig to test how the service responds.

Dig-t A www.apache.essun.com @ 192.168.1.50

Second

Third time

As you can see, DNS random resolution does not mean that intelligent resolution can be achieved. We know that DNS resolved domain names are cached, so this method is still inappropriate, this is only an experiment. If we use the previous knowledge together, there is no problem.

====================================================== Test in this experiment end ======================================

This article from the "and the rain" blog, please be sure to keep this source http://essun.blog.51cto.com/721033/1384682

Related Article

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.