码迷,mamicode.com
首页 > Web开发 > 详细

web服务器(LAMP)通过DNS轮询功能和nfs共享实现负载均衡

时间:2018-08-15 10:37:35      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:网页   web   hosts   php-fpm   nfs共享   har   lamp   nfs-utils   zone   

web服务器(LAMP)通过DNS轮询功能和nfs共享实现负载均衡,部署discuz论坛

拓扑思路:

服务器1:mariadb+nfs;172.20.120.40

服务器2:apache+php-fpm;172.20.120.41

服务器3:apache+bind;172.20.120.42

服务器1:mariadb+nfs;172.20.120.40

yum install mariadb-server nfs-utils

部署nfs共享;分别使用lvm当做数据库目录/mydata、网页文件目录/vhosts;

yum install mariadb-server nfs-utils -y

fdisk -l /dev/sda

partx -a /dev/sda

pvcreate /dev/sda3

vgcreate vg01 /dev/sda3

lvcreate -L 8G -n mydata vg01

lvcreate -L 8G -n myhtdoc vg01

mkfs -t xfs /dev/vg01/mydata

mkfs -t xfs/dev/vg01/myhtdoc

mkdir /mydata

mkdir /vhosts

vim /etc/fstab 添加如下

/dev/vg01/mydata /mydata xfs defaults 0 0
/dev/vg01/myhtdoc /vhosts xfs defaults 0 0

mount -a

vim /etc/exports

/vhosts 172.20.120.41(rw,no_root_squash) 172.20.120.42(rw,no_root_squash)

cp /usr/share/mysql/my-large.cnf /etc/my.cnf

vim /etc/my.cnf

innodb_file_per_table = on
skip_name_resolv = on
datadir = /mydata/data

mkdir -pv /mydata/data

chown mysql:mysql /mydata/data

systemctl enable nfs mariadb

systemctl start nfs mariadb

mysql_secure_installation

下载discuz并上传网页文件到/vhosts/web1目录下

服务器2:apache+php-fpm;172.20.120.41

yum install httpd php-fpm php-mysql nfs-utils -y

vim /etc/fstab

172.20.120.40:/vhosts /vhosts nfs defaults,_netdev 0 0

mount -a

vim /etc/httpd/conf/htttpd.conf

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

DirectoryIndex index.php index.html

<VirtualHost :80>
ServerName bbs.lewis.com
DocumentRoot /vhosts/web1
ProxyRequests off
ProxyPassMatch ^/(.
.php(/.*)?)$ fcgi://172.20.120.41:9000/vhosts/web1/$1
<Directory "/vhosts">
Require all granted
Options none
AllowOverride none
</Directory>
</VirtualHost>

vim /etc/php-fpm.d/www.conf

listen = 172.20.120.41:9000

listen.allowed_clients = 172.20.120.41,172.20.120.42

systemctl enable httpd php-fpm

systemctl start httpd php-fpm

服务器3:apache+bind;172.20.120.42

yum install httpd bind nfs-utils -y

vim /etc/fstab

172.20.120.40:/vhosts /vhosts nfs defaults,_netdev 0 0

mount -a

vim /etc/httpd/conf/htttpd.conf

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

DirectoryIndex index.php index.html

<VirtualHost :80>
ServerName bbs.lewis.com
DocumentRoot /vhosts/web1
ProxyRequests off
ProxyPassMatch ^/(.
.php(/.*)?)$ fcgi://172.20.120.41:9000/vhosts/web1/$1
<Directory "/vhosts">
Require all granted
Options none
AllowOverride none
</Directory>
</VirtualHost>

vim /etc/named.conf

options {
listen-on port 53 { 172.20.120.42; };
// listen-on-v6 port 53 { ::1; };
allow-query { 172.20.120.0/16; };

vim /etc/named.rfc1912.zones

zone "lewis.com" IN {
type master;
file "lewis.com.zone";
allow-update { none; };
};

vim /var/named/lewis.com.zone

$TTL 1D
@ IN SOA ns.lewis.com. root@localhost (
2018060501
2H
20M
1W
1D
)
IN NS ns.lewis.com.
ns IN A 172.20.120.42
bbs IN A 172.20.120.41
bbs IN A 172.20.120.42
lewis.com. IN A 172.20.120.42
lewis.com. IN A 172.20.120.41

systemctl enable httpd named

systemctl start httpd named

web服务器(LAMP)通过DNS轮询功能和nfs共享实现负载均衡

标签:网页   web   hosts   php-fpm   nfs共享   har   lamp   nfs-utils   zone   

原文地址:http://blog.51cto.com/11476314/2159913

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!