用nfs实现两台web服务器共享web服务

环境搭建:

共使用3台服务器

                服务器A   主机名称web1.magedu.com   ip172.16.23.1

                bind httpd nfs php web网页

                服务器B     主机名称web2.magedu.com ip172.16.23.2

                httpd  php  web网页

                服务器C       mysql.magedu.com    ip172.16.23.3

       

首先修改三个服务器的hostname配置文件并使配置各台主机的ip地址,并把dns指向172.16.10.10

# vim /etc/sysconfig/network //修改下面一行

HOSTNAME=hostname web1.magedu.com

HOSTNAME=hostname web2.magedu.com

HOSTNAME=hostname mysql.magedu.com

[root@web1 ~]#

[root@web1 ~]#

[root@web1 ~]#

 

一:配置nfs服务器 dns服务器 httpd服务器 php服务器,并且安装php和数据库mysql交互的程序:

 

 

安装dns服务器

rpm -e bind-libs bind-utils

yum -y install bind97 bind97-libs bind-utils

mv /etc/named.conf  /etc/rndc.key ~

vim /etc/named.conf

options {

             directory "/var/named

};

zone "." IN {

             type hint;

             file "named.ca";

};

zone "localhost" IN {

                         type master;

                          file "localhost.zone";

};

zone "0.0.127.in-addr.arpa" IN {

                       type master;

                       file "127.0.0.zone";

};

zone "magedu.com" IN  {

             type master;

             file "magedu.com.zone";

zone "16.172.in-addr.arpa" IN  {

                    type master;

                    file "172.16.zone";

chown :named /etc/named.conf

chmod 640 /etc/named.conf

cd  /var/named

vim localhost.zone

$TTL 600

@                   IN              SOA          localhost.              admin.localhost. (

                                                            2012071501

                                                             1H

                                                              10M  

                                                               7D

                                                                6H )

                            IN                NS          localhost.

                            IN                  A           127.0.0.1

vim 127.0.0.1.zone

$TTL 600              IN                 SOA       localhost                admin.localhost. (

                                               2012071501

                                                    1H

                                                     10M

                                                      7D

                                                       6H )

                                     IN                    NS                localhost.

     1                               IN                    PTR              localhost.      

 

chown :named 127.0.0.zone localhost.zone

chmod 640 127.0.0.zone localhost.zone

 

vim magedu.com.zone

$TTL      600

$ORIGIN magedu.com.

@                 IN                 SOA                 ns.magedu.com.               admin.magedu.com.   (

                                                                    2010071501

                                                                     1H

                                                                     10M

                                                                      7D

                                                                       6H )

                        IN                    NS                   ns

                         IN                     A                    172.16.23.1

web1                IN                     A                     172.16.23.1

web2                 IN                     A                      172.16.23.2

                                                            

chown :named maedu.com.zone

chmod 640 magedu.com.zone

 

vim 172.16.zone

$TTL 600

@                        IN                   SOA                   ns.magedu.com. admin.magedu.com. (

                                                                              2010071501

                                                                               1H

                                                                               10M

                                                                                7D

                                                                                 6H )

1.23                           IN            PTR                        ns.magedu.com

1.23                          IN             PTR                        web1.magedu.com

 2.23                          IN             PTR                        web2.magedu.com

chown :named 172.16.zone

chmod 640 172.16.zone

注销DocumentRoot

启用Namevirtulhost

 

Setenforce=0

提供网页文件Discuss,目的是验证php是否工作正常

把论坛解压到正确的位置/web/vhosts/www

Chkconfig  httpd on

在那一台MYSQL的数据库服务器上安装mysql 和MYSQL-SERVER包

 

Chkconfig mysql on

注销DocumentRoot

启用Namevirtulhost

定义虚拟主机

Setenforce=0

提供网页文件Discuss,目的是验证php是否工作正常

把论坛解压到正确的位置/web/vhosts/www

Chkconfig  httpd on

在那一台MYSQL的数据库服务器上安装mysql 和MYSQL-SERVER包

Chkconfig mysql on

在第一台主机上装上nfs 

 

挂载nfs共享文件系统

 

mkdir /wangye mount –t nfs 172.16.1.100:/web/vhosts/www

2)在服务器B上安装httpd,mysql,还有和mysql通信的程序

 

 

 

 

>3) 在服务器C上安装mysql数据库

 

 

4)配置开启nfs服务

# service portmap status

portmap  is running... //应该是running一般是开启的

# vim /etc/exports

/web/vhosts/www 172.16.0.0/16(rw,async)

# service nfs start

# showmount –a 察看能否看到共享的目录 

mount –t nfs 172.16.1.100:/www/htdoc /web

3)开启httpd服务,测试php和mysql是否工作正常

service httpd start

 

五、安装discuss网页

你可能感兴趣的:(linux,nfs共享web)