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
本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/100304