Deploy web01, web02, nfs, db01, backup, build wordpress, WeCenter, share, hot standby, real-time backup

Keywords: Linux PHP Nginx rsync vim

Summary

Deploy web01, web02, nfs, db01, backup, build wordpress, WeCenter, share, hot standby, real-time backup

1) Install nginx and php on web01 and web02

2) Create www users

[root@web01 php]# groupadd www -g 666
[root@web01 php]# useradd www -u 666 -g 666 -s /sbin/nologin -M

[root@web02 php]# groupadd www -g 666
[root@web02 php]# useradd www -u 666 -g 666 -s /sbin/nologin -M

[root@nfs ~]# groupadd www -g 666
[root@nfs ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M

[root@db01 ~]# groupadd www -g 666
[root@db01 ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M

[root@backup ~]# groupadd www -g 666
[root@backup ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M

3) Modify nginx and PHP startup users

[root@web01 php]# vim /etc/nginx/nginx.conf 
user  www;
[root@web01 php]# vim /etc/php-fpm.d/www.conf 
user = www
group = www


[root@web02 php]# vim /etc/nginx/nginx.conf 
user  www;
[root@web02 php]#  vim /etc/php-fpm.d/www.conf
user = www
group = www

4) Edit nginx configuration file

[root@web01 php]# vim /etc/nginx/conf.d/blog.drz.com.conf
server {
        listen 80;
        server_name blog.drz.com;
        root /code/wordpress;
        index index.php index.html;
        access_log /var/log/nginx/blog.drz.com_access.log main;

        location ~\.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

}

[root@web01 php]# vim /etc/nginx/conf.d/zh.drz.com.conf
server {
        listen 80;
        server_name zh.drz.com;
        root /code/zh;
        index index.php index.html;
        access_log /var/log/nginx/zh.drz.com_access.log main;

        location ~\.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

}

5) Create site directory and authorize

[root@web01 php]# mkdir -p /code/{wordpress,zh}

6) Code on-line

[root@web01 code]# tar xf wordpress-5.0.3-zh_CN.tar.gz
[root@web01 code]# unzip WeCenter_3-3-3.zip 

7) Create user upload directories

[root@web01 code]# mkdir /code/wordpress/wp-content/uploads
[root@web01 php]# chown -R www.www /code/

8) Start nginx and php and add boot-up self-start

[root@web01 code]# systemctl start nginx php-fpm
[root@web01 code]# systemctl enable nginx php-fpm

Operation under db01

9) Installation of databases

[root@db01 ~]# yum install -y mariadb-server

10) Start the database

[root@db01 ~]# systemctl start mariadb

11) Setting the password of the database root user

[root@db01 ~]# mysqladmin -uroot password '123'

12) Creating a database without interaction

#Create a database
[root@db01 ~]# mysqladmin -uroot -p123 create wordpress
[root@db01 ~]# mysql -uroot -p123 -e 'create database zh'
#view the database
[root@db01 ~]# mysql -uroot -p123 -e 'show databases'

13) Interactive-free Creator Connecting MySQL Users

[root@db01 ~]# mysql -uroot -p123 -e "grant all on wordpress.* to wp@'172.16.1.%' identified by '1'"
[root@db01 ~]# mysql -uroot -p123 -e "grant all on zh.* to zh@'172.16.1.%' identified by '1'"

14) Deploy a second web

#Push code
[root@web01 code]# scp -r /code 172.16.1.8:/
#Push profile
[root@web01 ~]# scp /etc/nginx/conf.d/* 172.16.1.8:/etc/nginx/conf.d/
#To grant authorization
[root@web02 php]# chown -R www.www /code/
#Delete the default virtual host configuration file
[root@web01 ~]# rm -f /etc/nginx/conf.d/default.conf 
[root@web02 php]# rm -f /etc/nginx/conf.d/default.conf
#Start nginx and php and add boot-up self-start
[root@web02 php]# systemctl start nginx php-fpm
[root@web02 php]# systemctl enable nginx php-fpm

15) Sharing static resources

  • Install nfs server
[root@nfs ~]# yum install -y nfs-utils
[root@backup ~]# yum install -y nfs-utils
  • Modify configuration files
[root@nfs ~]# vim /etc/exports
/data/wordpress 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)
/data/zh 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

[root@backup ~]# vim /etc/exports
/data/wordpress 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)
/data/zh 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)
  • Create shared directories
[root@nfs ~]# mkdir -p /data/{wordpress,zh}
[root@nfs ~]# chown -R www.www /data

[root@backup ~]# mkdir -p /data/{wordpress,zh}
[root@backup ~]# chown -R www.www /data
  • Start nfs and rpcbind
[root@nfs ~]# systemctl start nfs-server
[root@nfs ~]# systemctl enable nfs-server

[root@backup ~]# systemctl start nfs-server
[root@backup ~]# systemctl enable nfs-server
  • Install nfs client
[root@web01 code]#  yum install -y nfs-utils
[root@web02 php]#  yum install -y nfs-utils
  • View mountpoint
[root@web01 code]# showmount -e 172.16.1.31
Export list for 172.16.1.31:
/data/zh        172.16.1.0/24
/data/wordpress 172.16.1.0/24
[root@web01 code]# showmount -e 172.16.1.41
Export list for 172.16.1.41:
/data/zh        172.16.1.0/24
/data/wordpress 172.16.1.0/24


[root@web02 php]#  showmount -e 172.16.1.31
Export list for 172.16.1.31:
/data/zh        172.16.1.0/24
/data/wordpress 172.16.1.0/24
[root@web02 php]#  showmount -e 172.16.1.41
Export list for 172.16.1.41:
/data/zh        172.16.1.0/24
/data/wordpress 172.16.1.0/24
  • mount
mkdir /code/wordpress/wp-content/uploads/
mkdir /code/zh/uploads/ Create your own directory before you upload a picture

[root@web01 code]# mount -t nfs 172.16.1.31:/data/wordpress /code/wordpress/wp-content/uploads/
[root@web01 code]# mount -t nfs 172.16.1.31:/data/zh /code/zh/uploads/


[root@web02 php]#  mount -t nfs 172.16.1.31:/data/wordpress /code/wordpress/wp-content/uploads/
[root@web02 php]# mount -t nfs 172.16.1.31:/data/zh /code/zh/uploads/

16) Deployment of rsync and sersync

  • Install rsync server
[root@backup ~]# yum install -y rsync
  • Modify configuration files
[root@backup ~]# vim /etc/rsyncd.conf
uid = www
gid = www
port = 873
fake super = yes
use chroot = no
max connections = 200
timeout = 600
ignore errors
read only = false
list = false
auth users = rc
secrets file = /etc/rsync.passwd
log file = /var/log/rsyncd.log
#####################################
[nfs]
comment = welcome to oldboyedu backup!
path = /data
  • Create password file and authorize
[root@backup ~]# echo 'rc:123' > /etc/rsync.passwd
[root@backup ~]# chmod 600 /etc/rsync.passwd
  • Start rsyncd
[root@backup ~]# systemctl start rsyncd

17) client deployment of sersync

  • Install rsync and inotify-tools
[root@nfs ~]# yum install -y rsync inotify-tools
  • Install sersync
[root@nfs ~]# tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz 
[root@nfs ~]# mv GNU-Linux-x86/ /usr/local/sersync
  • Modify configuration files
[root@nfs ~]# vim /usr/local/sersync/confxml.xml
    <sersync>
        <localpath watch="/data">
            <remote ip="172.16.1.41" name="nfs"/>
            <!--<remote ip="192.168.8.39" name="tongbu"/>-->
            <!--<remote ip="192.168.8.40" name="tongbu"/>-->
        </localpath>
        <rsync>
            <commonParams params="-az"/>
            <auth start="true" users="rc" passwordfile="/etc/rsync.pass"/>
            <userDefinedPort start="false" port="874"/><!-- port=874 -->
            <timeout start="true" time="100"/><!-- timeout=100 -->
            <ssh start="false"/>
        </rsync>
        <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
        <crontab start="false" schedule="600"><!--600mins-->
            <crontabfilter start="false">
                <exclude expression="*.php"></exclude>
                <exclude expression="info/*"></exclude>
            </crontabfilter>
        </crontab>
        <plugin start="false" name="command"/>
    </sersync>
  • Create password file and authorize
[root@nfs ~]# echo 123 > /etc/rsync.pass
[root@nfs ~]# chmod 600 /etc/rsync.pass
  • Start sersync
[root@nfs ~]# /usr/local/sersync/sersync2 -rdo /usr/local/sersync/confxml.xml

Posted by Fusioned on Sat, 05 Oct 2019 22:57:48 -0700