Lamp platform for Web server load Balancing based on NFS

Source: Internet
Author: User
Tags mysql host php server wordpress database

Objective

As the amount of traffic increases, a Web server may not be able to meet the demand, which requires increasing the number of Web servers, so the problem is: how to ensure that the two server data synchronization? This article explains how to implement load balancing and data synchronization for Web servers based on NFS.

NFS Service Introduction

The NFS Network File system, which allows a system to share directories and files over a network, by using NFS, users and programs can access files on the remote system as if they were accessing local files. NFS itself does not provide the ability to transmit data, and it must be transmitted using a remote procedure call (RPC) protocol.

Configuration file

NFS configuration files and service providers on CentOS6

Package: Nfs-utils script:/ETC/RC.D/INIT.D/NFS/ETC/RC.D/INIT.D/NFSLOCK/ETC/RC.D/INIT.D/RPCGSSD/ETC/RC. D/INIT.D/RPCIDMAPD/ETC/RC.D/INIT.D/RPCSVCGSSD configuration file:/etc/exports/etc/sysconfig/nfs #提供额外功能

Detailed configuration file

/etc/exports file format and options File system   Client (options)   Client (option) client: IP, FQDN or domain, network option: Secure: Default option, it uses a tcp/of less than 1024 IP Port for NFS connectivity. Specify insecure to disable this option RW: This option allows the  NFS  client to read/write access. The default option is read-only (RO). Async: Can improve performance, but if you restart the NFS server without shutting down the NFS daemon completely, it can also result in data loss, which defaults to Syncno_wdelay: Turn off write delay, if async is set, Then NFS ignores this option. Nohide: If a directory is attached to another directory, then the original directory is usually hidden or looks like empty, to disable this behavior, you need to enable the  hide  option No_subtree_ Check: Turn off subtree checking, subtree check performs some security checks that you do not want to ignore, the default option is to enable subtree check NO_AUTH_NLM: can be specified as Insecure_locks, which tells the  NFS  daemon not to authenticate locking requests. If you are concerned about security, you should avoid using this option, the default option is  auth_nlm  or  secure_locksmp  (Mountpoint=path):  by explicitly declaring this option, nfs  requires mounting the exported directory Fsid=num: It is usually used in the case of  NFS  recovery. If you want to implement  NFS  recovery, refer to the  NFS  documentation. User-Mapped options: Root_squash: Do not allow root users to access mounted  NFS  volumes No_root_squash: Allow  root  users to access mounted  NFS  Volume All_squash: Restrict all  UID  and  gid, use only anonymous users, the default setting is  no_all_squashanonuid  and  anongid: Will Anonymous  UID  and  GID  change to specific user and group accounts

Related commands

Viewing file systems for NFS server-side sharing: SHOWMOUNT-E NFSSERVER_IP mount NFS File system: MOUNT-T NFS Server:/path/to/sharedfs/path/to/mount_ POINTEXPORTFS: Special tools for maintaining exports file Export file system tables Export-ar: Re-export all file systems Export-au: Turn off all file systems exported Export-u FS: Turn off the specified exported file system boot automatically mount Nfsvim/etc/fstabserver:/path/to/exported_fs/mount_point NFS Defaults,_netdev 0 0

NFS for Web server load Balancing

Working principle

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6B/C0/wKiom1U18TaCuxmVAAJzmgP0_Tc375.jpg "title=" NFS implements Web server load balancing principle. jpg "alt=" wkiom1u18tacuxmvaajzmgp0_tc375.jpg "/>

Configuration process

Case Requirements:

DNS server: 172.168.10.10(CentOS6.6)

Web server 1:172.16.10.100(CentOS6.6)

Web server 2:172.16.10.212(CentOS6.6)

PHP Server: 172.16.10.110(CentOS6.6)

Server for NFS: 172.16.10.110(CentOS6.6)

Database server: 172.16.10.211 (CentOS6.6) MariaDB

requires that the same site be available on both Web servers (blog.scholar.com WordPress Site ), the site directory is located on the NFS server/web/blog, and the two Web server data needs to be consistent

Please make sure that the server, service software is installed, I have installed here (in fact, borrowed from the previous), compiled installation of the god horse See blog

DNS server Configuration

To modify a positive and Negative zone file

Forward parsing

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/C0/wKiom1U19S3BuH7kAACuy_9EQp8374.jpg "title=" 1.jpg " alt= "Wkiom1u19s3buh7kaacuy_9eqp8374.jpg"/>

Reverse parsing

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/C0/wKiom1U19ejAtIY5AACl_TmlIpE078.jpg "title=" 2.jpg " alt= "Wkiom1u19ejatiy5aacl_tmlipe078.jpg"/>

Check syntax, start service

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/C0/wKiom1U19gyTs30eAAG1ed50P90734.jpg "title=" 3.jpg " alt= "Wkiom1u19gyts30eaag1ed50p90734.jpg"/>

Server for NFS Configuration

Create a shared directory and set permissions

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/BD/wKioL1U2A87zJwUtAAB6-dMIE9k905.jpg "title=" 4.jpg " alt= "Wkiol1u2a87zjwutaab6-dmie9k905.jpg"/>

Editing profiles, setting up shared directories and clients

[Email protected] ~]# vim/etc/exports/web/blog 172.16.10.100 (rw,sync) 172.16.10.212 (Rw,async)

Site File Preparation

[[email protected] ~]# unzip Wordpress-3.2.1-zh_cn.zip[[email protected] ~]# CD Wordpress[[email protected] wordpress]# m V */web/blog[[email protected] wordpress]# Cd/web/blog[[email protected] blog]# cp wp-config-sample.php wp-config.php [[ Email protected] blog]# vim wp-config.php/** WordPress database name */define (' db_name ', ' wpdb '); /** MySQL Database user name */define (' Db_user ', ' wpuser '); /** MySQL Database Password */define (' Db_password ', ' wppass '); /** MySQL host */define (' Db_host ', ' 172.16.10.211 ');

Start the service, view the listening port

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/C1/wKiom1U2BofRd_E6AAD4AalWP0E784.jpg "title=" 5.jpg " alt= "Wkiom1u2bofrd_e6aad4aalwp0e784.jpg"/>

Database Server Configuration

Providing a database for WordPress programs

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/BD/wKioL1U2CFXTz9v3AAHz4kgA7MQ036.jpg "title=" 6.jpg " alt= "Wkiol1u2cfxtz9v3aahz4kga7mq036.jpg"/>

Web server Configuration

Enable related modules

[Email protected] ~]# vim/etc/httpd24/httpd.conf LoadModule proxy_module modules/mod_proxy.soloadmodule proxy_fcgi_ Module modules/mod_proxy_fcgi.so

Enable Virtual Host

#DocumentRoot "/usr/local/apache/htdocs" #关闭中心主机 include/etc/httpd24/extra/httpd-vhosts.conf #启用虚拟主机

Make IT support PHP

<ifmodule dir_module> directoryindex index.html index.php</ifmodule> AddType application/x-httpd-php. php AddType Application/x-httpd-php-source. Phps

Configuring a virtual Host

[Email protected] ~]# vim/etc/httpd24/extra/httpd-vhosts.conf <virtualhost *:80> documentroot "/web/blog" S Ervername blog.scholar.com proxyrequests Off #关闭正向代理 proxypassmatch ^/(. *\.php) $ fcgi://172.16.10.110:900 0/web/blog/$1 #代理至php服务器 <directory "/web/blog" > Options none allowoverride none Require all GRA Nted</directory></virtualhost>

Mount a shared directory

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/BE/wKioL1U2CxuwTz8sAAHIqwRhOfw245.jpg "title=" 7.jpg " alt= "Wkiol1u2cxuwtz8saahiqwrhofw245.jpg"/>

#可设置开机自动挂载 [[email protected] ~]# Vim/etc/fstab 172.16.10.110:/web/blog/web/blog NFS Defaults,_netdev 0 0

Check syntax, start service

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/BE/wKioL1U2DAvTYlcoAABULjWMB9Q278.jpg "title=" 8.jpg " alt= "Wkiol1u2davtylcoaabuljwmb9q278.jpg"/>

Test Site access is normal

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/BE/wKioL1U2EHeyRGurAAKSWgZC4-I461.jpg "title=" 9.jpg " alt= "Wkiol1u2eheyrguraakswgzc4-i461.jpg"/>

can be accessed, next we'll see if the data can be synchronized

Specify IP access for a single server

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/BE/wKioL1U2EO2DeTy0AAKFCYnW8iw159.jpg "title=" 10.jpg "alt=" Wkiol1u2eo2dety0aakfcynw8iw159.jpg "/>

We landed on this server and posted a blog post

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/C2/wKiom1U2D-awufj-AAKXtItNL9s754.jpg "title=" 11.jpg "alt=" Wkiom1u2d-awufj-aakxtitnl9s754.jpg "/>

Now let's take a look at another server and see if we can read the post we just posted.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/BE/wKioL1U2EYmCjgZIAAOxBYCXG14582.jpg "title=" 12.jpg "alt=" Wkiol1u2eymcjgziaaoxbycxg14582.jpg "/>

OK, you can see that the purpose of data synchronization is also achieved

The end

"The world is so big, I want to see ..." I hope someday I can be so free and easy ... Okay, load balancing for Web servers based on NFS that's it, I'm going to go to the feeling of life when I have a message. The above is only for individual learning to organize, if there are mistakes, big God do not spray ~ ~

This article is from the "North Scholar" blog, please make sure to keep this source http://scholar.blog.51cto.com/9985645/1636605

Lamp platform for Web server load Balancing based on NFS

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.