Using DNS polling +nginx+php+nfs+mysql for cluster high availability

Source: Internet
Author: User
Tags fpm

The experiment uses four virtual machines to build, originally the database as the core of the site, can not be placed on the DNS server, here due to the limit of the number of virtual machines, can only be temporarily placed on the DNS server to demonstrate the experiment, the real environment in the database can not be placed on the DNS server.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/38/wKiom1V2jkLRhMG_AAF-VOdYG84760.jpg "title=" cluster. png "alt=" Wkiom1v2jklrhmg_aaf-vodyg84760.jpg "/>

As shown

Dns+mysql Server ip:10.6.0.180

WEB1 Server ip:10.6.0.186

WEB2 Server ip:10.6.0.187

Php+nfs Server ip:10.6.0.181


First, install the DNS server

Yum-y Install bind


Configure the DNS server


Enter the following in vim/etc/named.conf

options {    directory        "/var/named";     dump-file        "/var/named/data/cache_dump.db";     statistics-file  "/var/named/data/named_stats.txt";     allow-query      { any; };  #  allow any client to query     recursion  yes;    rrset-order { order random; };   #  DNS polling parsing};logging {    channel default_debug {             file  "Data/named.run";             severity dynamic;    };}; zone  "."  IN {        type hint;         file  "NAMED.CA ";}; include  "/etc/named.rfc1912.zones";

Enter the following in Vim/etc/named.rfc1912.zones

Zone "huxianglin.com" in {type Master;   File "Huxianglin.com.zone";        #正向解析配置文件};zone "0.6.10.in-addr.arpa" in {type Master;  File "10.6.0.zone"; #反向解析配置文件};

Enter the following in Vim/var/named/huxianglin.com.zone (forward parsing)

$TTL  600@       IN      SOA      dns.huxianglin.com.   admin.huxianglin.com.  (                          2015060801                         1H                         5M                          3D                         12H )          IN      NS      dnsdns     IN       A       10.6.0.180www      IN      A       10.6.0.186www      IN      A        10.6.0.187


Enter the following in Vim/var/named/10.6.0.zone (reverse parse)

$TTL  600@       IN      SOA      dns.huxianglin.com.   admin.huxianglin.com.  (                          2015060801                         1H                         5M                          3D                         12H ) @        in      ns      dns.huxianglin.com.1        IN      PTR     dns.huxianglin.com.2        IN      PTR      www.huxianglin.com.3       in      ptr      www.huxianglin.com.

(PS but I experiment reverse parsing seemingly does not take effect, may be configured with a problem)


Write the root name server to the named.ca file.

Dig-t NS. >/var/named/named.ca



Detect configuration problems: named-checkconf

Detection positive resolution: Named-checkzone "localhost"/var/named/localhost.zone

Detect reverse Resolution: Named-checkzone "0.6.10.in-addr.arpa"/var/named/10.6.0.zone (This step seems unsuccessful)

Rndc-confgen-r/dev/urandom-a//This step is to generate Rndc.key, if not the key namd is not bootable.

Chown Named:named/etc/rndc.key

/etc/init.d/named start

NETSTAT-LNP |grep named//See if the named process is listening on port 53

First Test forward parsing: Dig www.huxianglin.com

Then test back parse: Dig 10.6.0.186 (unsuccessful)


Then, build WEB1 and WEB2 servers

Yum install Nginx service on server

Yum-y Install Nginx

Start the service, modify the default page

echo "10.6.0.186" >/usr/share/nginx/html/

Service Nginx Start

Then test whether you can implement load balancing through DNS polling


After load balancing, NFS services and PHP services need to be installed on 10.6.0.181.

First, install the NFS service using Yum-y install Nfs-utils

Then modify the configuration file

Vim/etc/exports additions include the following:

/DATA/WWW/10.6.0.0/24 (rw,sync,all_squash,anonuid=1000,anongid=1000) (note that this UID and GID are all php-fpm user IDs)

Create a directory and give permissions

Mkdir-p/data/www/;chmod 777/data/www/

Start service: Systemctl start Rpcbind;systemctl start NFS

Mount the NFS system on the client

The client also installs the Yum install-y nfs-utils

See which directories are shared on the server side

SHOWMOUNT-E 10.6.0.181

Mount NFS on the client side of the server

Mount-t nfs-o nolock,nfsvers=3 10.6.0.181:/home//mnt///If you do not add-o nolock,nfsvers=3 the file owner and group in the Mount directory are nobody, if you specify Nfsver S=3 Displays the root

The next step is to install the PHP service, after using the source installation, modify the PHP-FPM configuration as follows:

Cat/usr/local/php/etc/php-fpm.conf[global]pid =/usr/local/php/var/run/php-fpm.piderror_log =/usr/local/php/var/ Log/php-fpm.log[www]listen = 10.6.0.181:9000user = Php-fpmgroup = Php-fpmlisten.owner = Nobodylisten.group = nobodypm = Dy Namicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024

and start the PHP-FPM process.

To see if the port is listening: Netstat-ant|grep 9000

Then configure the Nginx configuration file on both Web servers

Vi/etc/nginx/nginx.conf Modify the configuration as follows.

server {        listen        80 default_server;        server_name   www.huxianglin.com;        root          /data/www/discuz;        include /etc/nginx/ default.d/*.conf;        location / {         }location ~ \.php$ {         include fastcgi_params;        fastcgi_pass  10.6.0.181:9000;        fastcgi_index index.php;         fastcgi_param script_filename /data/www/discuz$fastcgi_script_ name;    }

Then create a PHP probe in the NFS Mount directory to detect if PHP can parse correctly

vi/data/www/discuz/test.php

<?php echo phpinfo ();? >

Open in browser found to parse PHP normally.


The next step is to install the MySQL database, MySQL database installation can refer to the following link

http://xianglinhu.blog.51cto.com/5787032/1659415

After installing the database to create a remote access to the account, here should be the experiment, give more permissions, the production environment should be limited to the database access rights.

Grant all on * * to ' root ' @ ' 10.6.0.% ' identified by ' 123456 ';

Flush privileges;

You can then import the Discuz installation package into NFS, install it via web page prompts, and then query the database for the creation of the appropriate database.

At this point, the environment is set up, testing the high availability of DNS polling, the two Web servers to arbitrarily stop a Web server Nginx service, the Web page will still be able to access the normal.



This article is from the "Lemon" blog, be sure to keep this source http://xianglinhu.blog.51cto.com/5787032/1660071

Using DNS polling +nginx+php+nfs+mysql for cluster high availability

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.