Objective:
The LVS-DR model is almost the same as the previous Lvs-nat model, except that the network topology is different.
Hostvs
Os:centos-7-x86_64
Hostname:ws1
ENO16777736:10.0.0.60/8 (DIP)
eno167777336:0: 10.0.0.61/32 (VIP)
gateway:10.0.0.254
HostRS1
OS:centos-7-x86_64
Hostname:ws2
ENO16777736:10.0.0.101/8 (RIP1)
lo:0 10.0.0.61/32 (VIP)
gateway:10.0.0.254
HostRS2
Os:centos-7-x86_64
Hostname:ws3
ENO16777736:10.0.0.102/8 (RIP2)
lo:0 10.0.0.61/32 (VIP)
gateway:10.0.0.254
Hostdb
Os:centos-7-x86_64
Hostname:ws4
Eno16777736:10.0.0.202/8
gateway:10.0.0.254
Time synchronization:
# ntpdate cn.pool.ntp.org# Hwclock--SYSOHC
Install the Software:
Hostdb
Installing binary mariadb-5.5.46
detailed configuration Please enter Portal:http://wscto.blog.51cto.com/11249394/1783131
Installing NFS
# yum Install-y nfs-utils
HostRS2
Install Nginx, note nginx belongs to Epel source
# yum install-y nginx php-fpm php-mbstring php-mysql nfs-utils mariadb
HostRS1
Install Nginx, note nginx belongs to Epel source
# yum install-y nginx php-fpm php-mbstring php-mysql nfs-utils mariadb
Hostvs
Installing the LVS CLI Interface program Ipvsadm
# yum Install-y Ipvsadm
Configuring the Cluster
Hostdb
Configure MARIADB
After the security initialization is complete, create the Discuz database and the Discuz user and authorize it to remotely manipulate the database
# mysql_secure_installation# mysql-u root-p> CREATE database discuz;> create user ' discuz ' @ ' lodalhost ' identified By ' 123456 ';> grant all privileges on discuz.* to ' discuz ' @ '% ' identified by ' 123456 ';> flush privileges;
Configuring NFS
# mkdir /nfshare/# ls -ld /nfshare/drwxr-xr-x 2 root root 6 may 9 17:01 /nfshare/# echo "/nfshare/ 10.0.0.101 (rw,no_root_squash,async) 10.0.0.102 (rw,no_root_squash,async) " > /etc/exports# /etc/init.d/rpcbind startstarting rpcbind: [ OK ]# /etc/init.d/nfs startstarting nfs services: [ ok ]starting nfs quotas: [ OK ]Starting NFS mountd: [ OK ]Starting NFS daemon: [ ok ]Starting RPC idmapd: [ ok ]# chkconfig rpcbind on# chkconfig nfs on# chkconfig rpcbind --listrpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off# chkconfig nfs --listnfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off# showmount -e 127.0.0.1export list for 127.0.0.1:/nfshare/ 10.0.0.101,10.0.0.102
Note: Rpcbind and NFS Two service boot order cannot be replaced, otherwise there will be a problem
Unpack the Discuz package to the/nfsshare/directory
# mkdir/nfshare/discuz# unzip/discuz_x3.2_sc_utf8.zip-d/nfshare/discuz/# ls/nfshare/discuz/readme upload Utility
HostRS1
Prevent RS from responding to VIP ARP requests before configuring VIP to RS
echo 1 >/proc/sys/net/ipv4/conf/all/arp_ignoreecho 1 >/proc/sys/net/ipv4/conf/lo/arp_ignoreecho 2 >/proc/ Sys/net/ipv4/conf/all/arp_announceecho 2 >/proc/sys/net/ipv4/conf/lo/arp_announce
Configure the VIP on the local loopback interface alias lo:0 and add routes
Ifconfig lo:0 10.0.0.61 broadcast 10.0.0.61 netmask 255.255.255.255 route add-host 10.0.0.61 Dev lo:0
Test the MARIADB on the link hostdb
# mysql-h 10.0.0.202-u discuz-p
Mount NFS Shared storage directory on Hostdb, the main group modified to Apache
# SHOWMOUNT-E 172.18.64.202Export list for 172.18.64.202:/nfshare/10.0.0.101,10.0.0.102# mkdir/htdocs# ls-ld/htdocs/d Rwxr-xr-x 2 root root 6 May 9 17:05/htdocs/# mount-t NFS 172.18.64.202:/nfshare/htdocs# ls/htdocs/discuz# chown-r APA che:apache/htdocs/discuz/
Start PHP-FPM
# systemctl start php-fpm.service# ss-tnl | grep 9000
Configure Nginx configuration file
# vim /etc/nginx/nginx.confserver { listen 80; server_name ws2 # Load configuration files for the default server block. include /etc/nginx/ default.d/*.conf; location / { root /htdocs/discuz/upload; index index.html index.htm index.php; } Location ~ \.php$ { root /htdocs/discuz/upload; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /etc/nginx/fastcgi.conf; } error_page 404 /404.html; location = / 40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }# nginx -tnginx: the configuration file /etc/ Nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful# nginx# ss -tnl | grep 80listen 0 128 *:80 *:*
Test Access Discuz Installation page host plus final/
# curl-i http://10.0.0.101/install/HTTP/1.1 Okserver:nginx/1.6.3date:mon, 10:23:50 Gmtcontent-type:tex t/htmlconnection:keep-alivex-powered-by:php/5.4.16
HostRS2
Configuration Ibid.
Hostvs
Implementation of Discuz load balancing based on LVS-DR model