zoukankan      html  css  js  c++  java
  • 第六章 NFS、rsync等统一用户相关操作

    一、统一用户

    1.httpd
    2.NFS挂载目录
    3.rsync

    1.所有服务器统一创建用户

    [root@web01 ~]# groupadd www -g 666
    [root@web01 ~]# useradd www -u 666 -g 666

    2.修改httpd用户

    [root@web01 ~]# vim /etc/httpd/conf/httpd.conf
    User www
    Group www

    #重启服务
    [root@web01 ~]# systemctl restart httpd
    [root@web01 ~]# ps -ef | grep httpd
    root      31537      1  1 21:57 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
    www       31538  31537  0 21:57 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
    www       31539  31537  0 21:57 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
    www       31540  31537  0 21:57 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
    www       31541  31537  0 21:57 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
    www       31542  31537  0 21:57 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
    root      31544  18601  0 21:57 pts/1    00:00:00 grep --color=auto httpd

    3.修改NFS服务端权限

    [root@NFS /data]# vim /etc/exports
    /data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

    #重启
    [root@NFS /data]# systemctl restart NFS

    4.修改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 = rsync_backup
    secrets file = /etc/rsync.passwd
    log file = /var/log/rsyncd.log
    #####################################
    [backup]
    comment = welcome to oldboyedu backup!
    path = /backup

    5.NFS服务端重新授权目录

    [root@NFS ~]# chown -R www.www /data/

    6.web端重新挂载

    [root@web01 /var/www/html]# umount /var/www/html/upload
    [root@web01 /var/www/html]# mount -t NFS 172.16.1.31:/data ./upload

    7.rsync服务端重新授权目录

    [root@backup ~]#chown -R www:www /backup

    二、NFS总结

    1.NFS储存优点
    1)简单易用,部署方便
    2)数据可查,服务稳定

    2.NFS的服务缺点
    1)存在单点故障, 如果构建高可用维护麻烦web->NFS()->backup
    2)NFS数据明文, 并不对数据做任何校验。
    3)客户端挂载NFS服务没有密码验证, 安全性一般(内网使用)

    3.NFS应用建议
    1)开机挂载
    如果希望NFS文件共享服务能一直有效,则需要将其写入到fstab文件中
    #编辑fstab文件
    [root@NFS-client ~]# vim /etc/fstab
    172.16.1.31:/data /NFSdir NFS defaults 0 0
    #验证fstab是否写正确
    [root@NFS-client ~]# mount -a

    2)生产场景应将静态数据尽可能往前端推,减少后端存储压力
    3)必须将存储里的静态资源通过CDN缓存,jpgpngmp4avicssjs
    4)如果没有缓存或架构本身历史遗留问题太大, 在多存储也无用

    三、rsync+NFS解决单点故障

    1.环境准备

    主机

    角色IP
    backup rsync服务端,NFS服务端 172.16.1.41
    NFS rsync客户端,NFS服务端 172.16.1.31
    web01 rsync客户端,NFS客户端 172.16.1.7,10.0.0.7

     

     

     

     

     

    2.web01搭载上传作业平台

    1.安装httpd和php
    [root@web01 ~]# yum install -y httpd php

    2.上传代码
    [root@web01 ~]# rz kaoshi.zip
    [root@web01 ~]# yum unzip
    [root@web01 ~]# unzip kaoshi.zip -d /var/www/html/

    3.创建httpd用户
    [root@web01 ~]# groupadd www -g 666
    [root@web01 ~]# useradd www -u 666 -g 666

    4.配置httpd服务
    [root@web01 ~]# vim /etc/httpd/conf/httpd.conf
    User www
    Group www

    #开启服务
    [root@web01 ~]# systemctl start httpd

    5.修改权限
    [root@web01 ~]# chown -R www.www /var/www/html/

    3.NFS服务器搭建NFS服务端

    1.安装NFS
    [root@NFS ~]# yum install -y NFS-utils rpcbind

    2.配置NFS
    [root@backup ~]# vim /etc/exports
    /data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

    3.查看配置生效
    [root@backup ~]# cat /var/lib/nfs/etab
    /data 172.16.1.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=666,anongid=666,sec=sys,rw,secure,root_squash,all_squash)

    4.创建用户
    [root@web01 ~]# groupadd www -g 666
    [root@web01 ~]# useradd www -u 666 -g 666

    5.创建目录
    [root@web01 ~]# mkdir /data
    [root@web01 ~]# chown -R www.www /data

    4.挂载web01数据目录

    [root@web01 ~]# showmount -e 172.16.1.31

    [root@web01 ~]# mount -t nfs 172.16.1.31:/data /var/www/html/upload

    5.backup搭建rsync服务端

    1.安装rsync
    [root@backup ~]# yum -y install rsyncd

    2.配置rsync
    [root@backup ~]# cat /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 = true
    auth users = rsync_backup
    secrets file = /etc/rsync.passwd
    log file = /var/log/rsyncd.log
    #####################################
    [backup]
    comment = "文件备份目录"
    path = /backup

    [data]
    comment = "数据备份目录"
    path = /data

    3.重启rsync
    [root@backup ~]# systemctl restart rsyncd

    6.NFS数据实时备份到backup服务器

    1.安装inotify
    [root@nfs ~]# yum -y install inotify-tools

    2.编写脚本实时备份data目录
    [root@nfs /data]# vim /scripts/backup_data.sh
    #!/bin/bash
    dir=/data
    export RSYNC_PASSWORD=123456
    /usr/bin/inotifywait  -mrq  --format '%w %f' -e create,delete,attrib,close_write  $dir | while read line;do
           cd  $dir && rsync -az -R  --delete . rsync_backup@172.16.1.41::data >/dev/null 2>&1
    done &

    3.启动脚本
    [root@nfs /data]# sh /scripts/backup_data.sh

    7.测试

    1.访问交作业页面,上传图片
    2.查看web服务器
    [root@web01 ~]# ll /var/www/html/upload
    3.查看nfs服务器data目录
    [root@nfs ~]# ll /data/
    4.查看backup服务器data目录
    [root@backup ~]# ll /data

    8.backup搭建NFS服务端

    1.安装NFS
    [root@backup ~]# yum install -y nfs-utils rpcbind

    2.配种NFS
    [root@backup ~]# vim /etc/exports
    /data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

    3.创建用户
    [root@backup ~]# groupadd www -g 666
    [root@backup ~]# useradd www -u 666 -g 666

    4.启动服务
    [root@backup ~]# systemctl start nfs

    9.测试

    1.NFS服务器出现故障
    [root@nfs ~]# systemctl stop nfs

    2.切换挂载机器
    [root@web01 ~]# umount -lf /var/www/html/upload
    [root@web01 ~]# mount -t nfs 172.16.1.41:/data /var/www/html/upload

    四、实时同步

    1.实时同步简单介绍

    1.概述
    实时同步是一种只要当前目录发生变化则会触发一个事件,事件触发后会将变化的目录同步至远程服务器

    2.为什么要实时同步
    保证数据的连续性, 减少人力维护成本,解决nfs单点故障

    3.实时同步数据选择
    sersync+RSYNC(√)、inotify+rsync
    Inotify是一个通知接口,用来监控文件系统的各种变化,如果文件存取,删除,移动。可以非常方便地实现文件异动告警,增量备份,并针对目录或文件的变化及时作出响应。rsync+inotify可以实触发式实时同步增量备份

    sersync是国人基于rsync+inotify-tools开发的工具,不仅保留了优点同时还强化了实时监控,文件过滤,简化配置等功能,帮助用户提高运行效率,节省时间和网络资源。

    2.安装sersync(NFS服务器)

    1.安装sersync和inotify
    [root@nfs01 ~]# yum install rsync inotify-tools -y

    2.下载serdync软件包
    [root@nfs01 ~]# wget https://raw.githubusercontent.com/wsgzao/sersync/master/sersync2.5.4_64bit_binary_stable_final.tar.gz

    3.解压安装包
    [root@nfs ~]# tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz

    4.移动并改名
    [root@nfs ~]# mv GNU-Linux-x86 /usr/local/sersync

    5.修改配置文件
    [root@nfs ~]# cat /usr/local/sersync/confxml.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <head version="2.5">
    #主机IP
      <host hostip="localhost" port="8008"></host>
       #调试模式
      <debug start="false"/>
      <fileSystem xfs="false"/>
       #文件过滤
      <filter start="false">
    <exclude expression="(.*).svn"></exclude>
    <exclude expression="(.*).gz"></exclude>
    <exclude expression="^info/*"></exclude>
    <exclude expression="^static/*"></exclude>
      </filter>
       #inotify监控配置
      <inotify>
       #inotify监控的行为
    <delete start="true"/>
    <createFolder start="true"/>
    <createFile start="true"/>
    <closeWrite start="true"/>
    <moveFrom start="true"/>
    <moveTo start="true"/>
    <attrib start="true"/>
    <modify start="true"/>
      </inotify>
    #推送部分
      <sersync>
       #本地监控的目录
    <localpath watch="/data">
    #远程IP及模块名字
      <remote ip="172.16.1.41" name="data"/>
    </localpath>
    <rsync>
    #rsync同步时的参数
      <commonParams params="-artuz"/>
       #开启认证
      <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
       #如果rsync服务不是873端口,需要开启
      <userDefinedPort start="false" port="874"/><!-- port=874 -->
       #超时时间
      <timeout start="false" time="100"/><!-- timeout=100 -->
      <ssh start="false"/>
    </rsync>
    #指定错误日志
    <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
    #定时任务,默认600分钟进行一次全备
    <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>

      <plugin name="command">
    <param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
    <filter start="false">
      <include expression="(.*).php"/>
      <include expression="(.*).sh"/>
    </filter>
      </plugin>

      <plugin name="socket">
    <localpath watch="/opt/tongbu">
      <deshost ip="192.168.138.20" port="8009"/>
    </localpath>
      </plugin>
      <plugin name="refreshCDN">
    <localpath watch="/data0/htdocs/cms.xoyo.com/site/">
      <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
      <sendurl base="http://pic.xoyo.com/cms"/>
      <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
    </localpath>
      </plugin>
    </head>
    [root@nfs ~]#

    6.创建密码文件
    [root@nfs ~]# echo 123456 > /etc/rsync.password
    [root@nfs ~]# chmod 600 /etc/rsync.password

    7.启动
    #查看参数
    [root@nfs ~]# /usr/local/sersync/sersync2 -h
    set the system param
    execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
    execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
    parse the command param
    _______________________________________________________
    参数-d:启用守护进程模式
    参数-r:在监控前,将监控目录与远程主机用rsync命令推送一遍
    c参数-n: 指定开启守护线程的数量,默认为10个
    参数-o:指定配置文件,默认使用confxml.xml文件
    参数-m:单独启用其他模块,使用 -m refreshCDN 开启刷新CDN模块
    参数-m:单独启用其他模块,使用 -m socket 开启socket模块
    参数-m:单独启用其他模块,使用 -m http 开启http模块
    不加-m参数,则默认执行同步程序

    [root@nfs ~]# /usr/local/sersync/sersync2 -dro /usr/local/sersync/confxml.xml
    set the system param
    execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
    execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
    parse the command param
    option: -d run as a daemon
    option: -r rsync all the local files to the remote servers before the sersync work
    option: -o config xml name: /usr/local/sersync/confxml.xml
    daemon thread num: 10
    parse xml config file
    host ip : localhost host port: 8008
    will ignore the inotify createFile event
    daemon start,sersync run behind the console
    use rsync password-file :
    user is rsync_backup
    passwordfile is /etc/rsync.password
    config xml parse success
    please set /etc/rsyncd.conf max connections=0 Manually
    sersync working thread 12  = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)
    Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)
    please according your cpu ,use -n param to adjust the cpu rate
    ------------------------------------------
    rsync the directory recursivly to the remote servers once
    working please wait...
    execute command: cd /data && rsync -artuz -R --delete ./ rsync_backup@172.16.1.41::data --password-file=/etc/rsync.password >/dev/null 2>&1
    run the sersync:
    watch path is: /data

    五、作业:sersync+NFS实战

    1.需求

    1.恢复快照
    2.搭建交作业系统
    3.配置挂载数据目录
    4.NFS的数据目录实时备份到backup服务器(要求使用sersync)
    
    

     

     

    2.环境准备

    主机角色IP
    backup rsync服务端,NFS服务端 172.16.1.41
    NFS rsync客户端,NFS服务端 172.16.1.31
    web01 rsync客户端,NFS客户端 172.16.1.7,10.0.0.7

     

    3.web01搭载上传作业平台

    1.关闭防火墙
    [root@web01 ~]# systemctl stop firewalld
    [root@web01 ~]# systemctl disable firewalld

    2.关闭selinux
    [root@web01 ~]# setenforce 0        
    [root@web01 ~]# vim /etc/selinux/config
    SELINUX=disabled

    3.安装httpd和php
    [root@web01 ~]# yum -y install httpd php

    4.上传作业平台代码并解压到指定目录
    [root@web01 ~]# rz -bye

    [root@web01 ~]# ll
    total 36
    -rw-------. 1 root root  1350 Jun  9 21:42 anaconda-ks.cfg
    -rw-r--r--. 1 root root   497 Aug  5 16:53 hostname_ip.sh
    -rw-r--r--  1 root root 26995 Aug 13 16:42 kaoshi.zip
    [root@web01 ~]# unzip kaoshi.zip -d /var/www/html/
    Archive: kaoshi.zip
    inflating: /var/www/html/info.php  
    inflating: /var/www/html/bg.jpg    
    inflating: /var/www/html/index.html  
    inflating: /var/www/html/upload_file.php  

    5.修改httpd配置
    [root@web01 ~]# vim /etc/httpd/conf/httpd.conf
    User www
    Group www

    6.创建统一用户
    [root@web01 ~]# groupadd -g 666 www
    [root@web01 ~]# useradd -u 666 -g 666 www

    7.修改用户权限
    [root@web01 ~]# chown -R www:www /var/www/html/

    8.重启服务并验证服务
    [root@web01 ~]# systemctl restart httpd
    [root@web01 ~]# ps aux |grep http
    root      24063  0.8  0.5 314580 12128 ?       Ss   19:49   0:00 /usr/sbin/httpd -DFOREGROUND
    www       24064  0.0  0.3 314712  6160 ?       S    19:49   0:00 /usr/sbin/httpd -DFOREGROUND
    www       24065  0.0  0.3 314712  6160 ?       S    19:49   0:00 /usr/sbin/httpd -DFOREGROUND
    www       24066  0.0  0.3 314712  6160 ?       S    19:49   0:00 /usr/sbin/httpd -DFOREGROUND
    www       24067  0.0  0.3 314712  6160 ?       S    19:49   0:00 /usr/sbin/httpd -DFOREGROUND
    www       24068  0.0  0.3 314712  6160 ?       S    19:49   0:00 /usr/sbin/httpd -DFOREGROUND
    root      24070  0.0  0.0 112708   976 pts/0   R+   19:49   0:00 grep --color=auto http

    4.NFS服务器搭建NFS服务端

    1.关闭防火墙
    [root@nfs ~]# systemctl stop firewalld
    [root@nfs ~]# systemctl disable firewalld

    2.关闭selinux
    [root@NFS ~]# setenforce 0        
    [root@NFS ~]# vim /etc/selinux/config
    SELINUX=disabled

    3.安装nfs和rpcbind
    [root@nfs ~]# yum -y install nfs-utils rpcbind

    4.配置nfs服务
    [root@nfs ~]# vim /etc/exports
    /web/data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

    5.重启服务并验证
    [root@nfs ~]# systemctl restart nfs
    [root@nfs ~]# cat /var/lib/nfs/etab
    /web/data 172.16.1.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=666,anongid=666,sec=sys,rw,secure,root_squash,all_squash)

    6.创建统一用户
    [root@nfs ~]# groupadd -g 666 www
    [root@nfs ~]# useradd -u 666 -g 666 www

    7.创建挂载目录并修改权限
    [root@nfs ~]# mkdir -p /web/data
    [root@nfs ~]# chown -R www:www /web/data/

    5.web01客户端挂载目录

    1.安装nfs和rpcbind
    [root@web01 ~]# yum -y install nfs rpcbind

    2.启动rpcbind
    [root@web01 ~]# systemctl start rpcbind

    3.查看挂载点
    [root@web01 ~]# showmount -e 172.16.1.31
    Export list for 172.16.1.31:
    /web/data 172.16.1.0/24

    4.挂载目录
    [root@web01 ~]# mount -t nfs 172.16.1.31:/web/data /var/www/html/upload

    5.查看挂载点
    [root@web01 ~]# df -h
    Filesystem             Size Used Avail Use% Mounted on
    /dev/sda3               98G  1.7G   96G   2% /
    devtmpfs               980M     0 980M   0% /dev
    tmpfs                 991M     0 991M   0% /dev/shm
    tmpfs                 991M  9.6M 981M   1% /run
    tmpfs                 991M     0 991M   0% /sys/fs/cgroup
    /dev/sda1             497M 120M 378M  25% /boot
    tmpfs                 199M     0 199M   0% /run/user/0
    172.16.1.31:/web/data   98G  1.7G   96G   2% /var/www/html/upload

    6.backup搭建rsync服务端

    1.关闭防火墙
    [root@backup ~]# systemctl stop firewalld
    [root@backup ~]# systemctl disable firewalld

    2.关闭selinux
    [root@backup ~]# setenforce 0        
    [root@backup ~]# vim /etc/selinux/config
    SELINUX=disabled

    3.安装rsync服务
    [root@backup ~]# yum -y install rsync

    4.配置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 = true
    auth users = rsync_backup
    secrets file = /etc/rsync.passwd
    log file = /var/log/rsyncd.log
    #####################################
    [backup]
    comment = "文件备份目录"
    path = /backup

    [data]
    comment = "数据备份目录"
    path = /data

    5.创建统一用户
    [root@backup ~]# groupadd -g 666 www
    [root@backup ~]# useradd -u 666 -g 666 www

    6.创建密码文件并修改权限
    [root@backup ~]# echo "rsync_backup:123456" >/etc/rsync.passwd
    [root@backup ~]# chmod 600 /etc/rsync.passwd

    7.创建备份目录并修改权限
    [root@backup ~]# mkdir /backup
    [root@backup ~]# mkdir /data
    [root@backup ~]# chown -R www:www /backup/
    [root@backup ~]# chown -R www:www /data/

    8,重启服务并验证服务
    [root@backup ~]# systemctl restart rsyncd
    [root@backup ~]# netstat -lntp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      24097/rsync        
    tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      6135/rpcbind        
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7151/sshd          
    tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      7291/master        
    tcp6       0      0 :::873                 :::*                   LISTEN      24097/rsync        
    tcp6       0      0 :::111                 :::*                   LISTEN      6135/rpcbind        
    tcp6       0      0 :::22                   :::*                   LISTEN      7151/sshd          
    tcp6       0      0 ::1:25                 :::*                   LISTEN      7291/master        

    7.NFS数据实时备份到backup服务器

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

    2.上传serdync软件包
    [root@nfs ~]# rz -bye

    [root@nfs ~]# ll
    -rw-r--r--  1 root root 727290 Aug 14 17:15 sersync2.5.4_64bit_binary_stable_final.tar.gz

    3.解压安装包
    [root@nfs ~]# [root@nfs ~]# tar -xf sersync2.5.4_64bit_binary_stable_final.tar.gz

    4.移动并改名
    [root@nfs ~]# mv GNU-Linux-x86 /usr/local/sersync

    5.修改配置文件
    [root@nfs ~]# vim /usr/local/sersync/confxml.xml
          </crontab>
          <plugin start="false" name="command"/>
      </sersync>
      <plugin name="command">
          <param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
          <filter start="false">
              <include expression="(.*).php"/>
              <include expression="(.*).sh"/>
          </filter>
      </plugin>

      <plugin name="socket">
          <localpath watch="/opt/tongbu">
              <deshost ip="192.168.138.20" port="8009"/>
          </localpath>
      </plugin>
      <plugin name="refreshCDN">
          <localpath watch="/data0/htdocs/cms.xoyo.com/site/">
              <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
              <sendurl base="http://pic.xoyo.com/cms"/>
              <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
          </localpath>
      </plugin>
    </head>

    6.创建密码文件并设置权限
    [root@nfs ~]# echo "123456" >/etc/rsync.password
    [root@nfs ~]# chmod 600 /etc/rsync.password

    7.启动数据实时同步
    [root@nfs ~]# /usr/local/sersync/sersync2 -dro /usr/local/sersync/confxml.xml
    set the system param
    execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
    execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
    parse the command param
    option: -d run as a daemon
    option: -r rsync all the local files to the remote servers before the sersync work
    option: -o config xml name: /usr/local/sersync/confxml.xml
    daemon thread num: 10
    parse xml config file
    host ip : localhost host port: 8008
    will ignore the inotify createFile event
    daemon start,sersync run behind the console
    use rsync password-file :
    user is rsync_backup
    passwordfile is /etc/rsync.password
    config xml parse success
    please set /etc/rsyncd.conf max connections=0 Manually
    sersync working thread 12  = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)
    Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)
    please according your cpu ,use -n param to adjust the cpu rate
    ------------------------------------------
    rsync the directory recursivly to the remote servers once
    working please wait...
    execute command: cd /web/data && rsync -artuz -R --delete ./ rsync_backup@172.16.1.41::data --password-file=/etc/rsync.password >/dev/null 2>&1
    run the sersync:
    watch path is: /web/data

    8.backup搭建NFS服务端

    1.安装nfs和rpcbind
    [root@backup ~]# yum -y install nfs rpcbind

    2.配置nfs服务
    [root@backup ~]# vim /etc/exports
    /backup 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

    3.重启服务并验证
    [root@backup ~]# cat /var/lib/nfs/etab
    /backup 172.16.1.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=666,anongid=666,sec=sys,rw,secure,root_squash,all_squash)

    9.测试

    1.访问交作业页面,上传图片

    2.查看web服务器
    [[root@web01 /var/www/html/upload]# ll
    total 48
    -rw-r--r-- 1 www www 46257 Aug 14 21:05 1_jh.jpg

    3.查看nfs服务器data目录
    [root@nfs /web/data]# ll
    total 48
    -rw-r--r-- 1 www www 46257 Aug 14 21:05 1_jh.jpg

    4.查看backup服务器data目录
    [root@backup /data]# ll
    total 48
    -rw-r--r-- 1 www www 46257 Aug 14 21:05 1_jh.jpg

     

  • 相关阅读:
    【设计模式】备忘录
    统计ip的发送频率和该ip发送的有效消息(去除相似消息)的数目
    Android之消息推送聊天实现
    Dictionary通过下标获取key和value
    SGU 271 水题。。。。
    二叉树递归和非递归遍历
    C#与SSL
    正则表达式总结
    SQL Server User Accounts
    嵌入式领域中各种文件系统的比较
  • 原文地址:https://www.cnblogs.com/jhno1/p/13505560.html
Copyright © 2011-2022 走看看