• 数据库迁移+扩展web节点+静态资源共享+备份


    1)在web01和web02上安装nginx和php

    2)创建www用户

    [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)修改nginx和PHP启动用户

    [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)编辑nginx配置文件

    [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;cd
          }

    }

    [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)创建站点目录并授权

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

    6)代码上线

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

    7)创建出用户上传目录

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

    8)启动nginx和php并加入开机自启

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

    9)安装数据库

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

    10)启动数据库

    [root@db01 ~]# systemctl start mariadb

    11)设置数据库root用户的密码

    [root@db01 ~]#  mysql -uroot -pZls123.com

    12)免交互创建数据库

    #创建数据库
    [root@db01 ~]# mysqladmin -uroot -pZls123 create wordpress
    [root@db01 ~]# mysql -uroot -pZls123 -e 'create database zh'
    #查看数据库
    [root@db01 ~]# mysql -uroot -pZls123 -e 'show databases'

    13)免交互创建程序连接MySQL用户

    [root@db01 ~]# mysql -uroot -pZls123 -e "grant all on wordpress.* to wp@'172.16.1.%' identified by '1'"
    [root@db01 ~]# mysql -uroot -pZls123 -e "grant all on zh.* to zh@'172.16.1.%' identified by '1'"
    [root@db01 ~]#  mysql -uroot -pZls123.com
    Welcome to the MariaDB monitor. Commands end with ; or g.
    Your MariaDB connection id is 3
    Server version: 5.5.60-MariaDB MariaDB Server

    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

    MariaDB [(none)]> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql             |
    | performance_schema |
    | test               |
    +--------------------+
    4 rows in set (0.00 sec)

    MariaDB [(none)]> create database wordpress;
    Query OK, 1 row affected (0.00 sec)

    MariaDB [(none)]> create database zh;
    Query OK, 1 row affected (0.00 sec)

    MariaDB [(none)]> grant all on wordpress.* to wp@'172.16.1.%' identified by 'Zls123.com';
    Query OK, 0 rows affected (0.00 sec)

    MariaDB [(none)]> grant all on zh.* to zh@'172.16.1.%' identified by 'Zls123.com';
    Query OK, 0 rows affected (0.00 sec)

    MariaDB [(none)]> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql             |
    | performance_schema |
    | test               |
    | wordpress         |
    | zh                 |
    +--------------------+
    6 rows in set (0.00 sec)

    MariaDB [(none)]>

    密码是123

    14)部署第二台web

    #推送代码
    [root@web01 code]# scp -r /code 172.16.1.8:/
    #推送配置文件
    [root@web01 ~]# scp /etc/nginx/conf.d/* 172.16.1.8:/etc/nginx/conf.d/
    #授权
    [root@web02 php]# chown -R www.www /code/
    #删除默认虚拟主机配置文件
    [root@web01 ~]# rm -f /etc/nginx/conf.d/default.conf
    [root@web02 php]# rm -f /etc/nginx/conf.d/default.conf
    #启动nginx和php并加入开机自启
    [root@web02 php]# systemctl start nginx php-fpm
    [root@web02 php]# systemctl enable nginx php-fpm

    15)共享静态资源

    • 安装nfs服务端

    [root@nfs ~]# yum install -y nfs-utils
    [root@backup ~]# yum install -y nfs-utils
    • 修改配置文件

    [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)
    • 创建共享目录

    [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
    • 启动nfs和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
    • 安装nfs客户端

    [root@web01 code]#  yum install -y nfs-utils
    [root@web02 php]# yum install -y nfs-utils
    • 查看挂载点

    [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
    • 挂载

    [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)部署rsync和sersync

    • 安装rsync服务端

    [root@backup ~]# yum install -y rsync
    • 修改配置文件

    [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
    • 创建密码文件并授权

    [root@backup ~]# echo 'rc:123' > /etc/rsync.passwd
    [root@backup ~]# chmod 600 /etc/rsync.passwd
    • 启动rsyncd

    [root@backup ~]# systemctl start rsyncd

     

    17)客户端部署sersync

    • 安装rsync和inotify-tools

    [root@nfs ~]# yum install -y rsync inotify-tools
    • 安装sersync

    [root@nfs ~]# tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz 
    [root@nfs ~]# mv GNU-Linux-x86/ /usr/local/sersync
    • 修改配置文件

    [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>
    • 创建密码文件并授权

    [root@nfs ~]# echo 123 > /etc/rsync.pass
    [root@nfs ~]# chmod 600 /etc/rsync.pass
    • 启动sersync

    [root@nfs ~]# /usr/local/sersync/sersync2 -rdo /usr/local/sersync/confxml.xml

     

  • 相关阅读:
    linux中anaconda环境下pytorch的安装(conda安装本地包)
    multi-label image classification:多标签图像分类总结
    TensorFlow,Keras限制GPU显存
    Linux常用文件操作命令
    卷积神经网络 CNN
    pycharm配置tensorflow环境 适用于Python3.6 CPU
    tensorflow模型ckpt转pb以及其遇到的问题
    使用delimiter //,解决mysql end报错问题
    C#死亡延迟队列DelayQueue
    如何发出人传人的裂变朋友圈?
  • 原文地址:https://www.cnblogs.com/223zhp/p/11412519.html
Copyright © 2020-2023  润新知