rsync + nfs + sersync real case

review:

1.rsync

Unified backup each server's configuration files or important file 
    system configuration file 
    log file 
        system log file 
            messages, secure, cron 
        service log file 
            access_log, access.log 
        service profile
             /etc/rsyncd.conf,/etc/exports ...    

2.NFS
network file system that provides shared storage service
3.sersync
provide real-time synchronization service

 

Experimental combination:

1.rsync

Experimental environment: 
    rsync server 
    rsync client 
test requirements: 
rsync server synchronization module, rsync client data backup can be achieved by sliding

2.nfs

Experimental environment: 
    nfs server 
    nfs client (apache) 
test requirements: 
    nfs shared directory server provides 
    client access to web pages achieved by mounting the shared directory

3.rsync+nfs

Experimental environment: 
    rsync server 
    nfs server (rsync client) 
    nfs client (apache) 
test requirements: 
    rsync server synchronization module 
    nfs server provides shared directory 
    client by mounting a shared directory, upload files to the server nfs 
    nfs server manually rsync command rsync to push files to the server

4.rsync+sersync+nfs

Experimental environment: 
    rsync server 
    nfs server (rsync client) 
    nfs client (apache) 
test requirements: 
    rsync server synchronization module 
    nfs server provides shared directory 
    client by mounting a shared directory, upload files to the server nfs 
    nfs server via real-time synchronization sersync rsync server data to 
    analog nfs server failure, by nfs rsync server into the server, failover

 

Complete lab document

Lab topology

Experimental demand

Experimental Procedure

 

A combination of experiments:

Experimental Procedure:

Setting up an rsync server

1 ) installation packages rsync 
[Backup the root @ ~] # yum  the install - Y rsync 

2 ) modify the configuration file rsyncd.conf 
[Backup the root @ ~] # CAT > << /etc/rsyncd.conf the EOF 
UID = rsync                               
GID = rsync                          
Port = 873                           
Fake Super = Yes                     
use CHROOT = NO                        
max Connection = 200 is                 
timeout = 600                       
ignore errors                     
read only=false                   
list = false                              
auth users=rsync_backup           
secrets file=/etc/rsync.passwd    
log file=/var/log/rsyncd.log     
#!module         
[backup]                               
comment = commit      
path = /backup    
EOF  

3)创建环境
[root@backup ~]# useradd -M -s /sbin/nologin rsync
[root@backup ~] # Mkdir / Backup 
[Backup the root @ ~] # chown -R & lt rsync.rsync / Backup / 
[the root Backup @ ~] # echo  ' rsync_backup:. 1 ' .> / Etc / the rsync the passwd 
[Backup the root @ ~] # the chmod  600 . / etc / rsync the passwd  

. 4 ) to start the service 
[Backup the root @ ~] && # systemctl start the rsyncd systemctl enable the rsyncd 

. 5 ) verify 
client: 
    the installation package rsync 
    [the root NFS @ ~] # yum  the install - Y rsync 
    experiment rsync -  avz to push
    [root @ nfs~] # -Avz the rsync / etc / the passwd rsync_backup @ 172.16 . 1.51 :: Backup 
    can be used in two ways Free adhesion 
        created password - File 
        [the root NFS @ ~] # echo  ' . 1 ' > / etc / the rsync. The passwd 
        [the root @nfs ~] # the chmod  600 / etc / the rsync. the passwd 
        [the root NFS @ ~] # the rsync -avz --password- File = / etc / the rsync. the passwd 
        the environment variable assignment RSYNC_PASSWORD 
        [the root NFS @ ~] # = Export RSYNC_PASSWORD 1

 

Experiment Combination 2:

2. set up NFS server

1 ). Installation NFS-safe locking utils, rpcbind package 
[nfs the root @ ~] # yum  the install -Y NFS-safe locking utils.x86_64 

2 ). Start rpcbind nfs and services 
[nfs the root @ ~] && # systemctl Start rpcbind nfs systemctl enable nfs 
Note: 
    1 . startup sequence, the rpcbind first, then nfs
     2 after turning, is permanently enabled .rpcbind, you need only to permanent nfs boot 

3 .) modify the configuration file / etc / Exports
 echo  " / Data 172.16.1.0/24 (RW, the all_squash, Sync) " > / etc / Exports 

. 4 ). creation environment 
[the root NFS @ ~] # mkdir -p / Data 
[the root NFS @ ~] # chownNfsnobody.nfsnobody -R & lt / Data / . 5 .) Reload the configuration file 
[the root NFS @ ~] # Exports - ARV . 6 ) authentication. 
Client: 
Installation NFS - utils 
[web01 the root @ ~] # yum the install -Y NFS-safe locking utils .x86_64 
start rpcbind service 
[web01 the root @ ~ ] # systemctl start rpcbind 
view nfs mount server information 
[web02 the root @ ~] # the showmount -e 172.16 . 1.41 
the Export List for 172.16 . 1.41 :
 / Data 172.16 . 1.0 / 24 
temporary mount nfs shared storage 
[root @ web01



  ~]# mount 172.16.1.41:/data /var/www/html 
永久挂载
[root@web01 ~]# echo '172.16.1.41:/data /var/www/html nfs defaults 0 0' >> /etc/fstab 
[root@web01 ~]# mount -a

 

Experimental combination of three:

rsync+nfs

web01 (nfs client) configuration

1 ) mounted httpd
 yum  the install - Y httpd
 2 ) Start httpd service 
systemctl Start httpd && systemctl enable httpd
 . 3 ) mounted to the shared directory nfs / var / WWW / HTML
 echo  ' 172.16.1.41:/data / var / WWW / HTML Defaults 0 0 nfs ' >> / etc / fstab 
 Mount - a 

Note: 
Add here multiple web servers, the procedure is exactly the same 

question: If the nfs service failure will cause all pages of the web server can access 
solutions: 
1 will. nfs shared directory in the content, pushed to the rsync server
 2 will temporarily become rsync server nfs server 
problems: nfs and rsync program is inconsistent user, will cause permission problems (even program the user the web server is not the same) 
solution: 
the nfs rsync web user program can be unified 
steps: 
rsync server
[root@backup ~]# groupadd -g 666 www
[root@backup ~]# useradd -u 666 -g 666 -M -s /sbin/nologin www
[root@backup ~]# sed -ri 's#(.*)rsync$#\1www#g' /etc/rsyncd.conf
[root@backup ~]# chown -R www.www /backup/ /data/
[root@nfs ~]# echo "/data 172.16.1.0/24(rw,all_squash,sync,anonuid=666,anongid=666)" > /etc/exports
[root@nfs ~]# exportfs -arv
[root@backup ~]# systemctl restart rsyncd

nfs服务器
[root@nfs ~]# groupadd -g 666 www
[root@nfs ~]# useradd -u 666 -g 666 -M -s /sbin/nologin www
[root@nfs ~]# chown -R www.www /data/
[root@nfs ~]# echo "/data 172.16.1.0/24(rw,all_squash,sync,anonuid=666,anongid=666)" > /etc/exports
[root@nfs ~]# exportfs -arv

web服务器
[root@web01 ~]# groupadd -g 666 www
[root@web01 ~]# useradd -u 666 -g 666 -M -s / sbin / nologin WWW 

disadvantages: the need for human content sharing directory manually pushed to nfs rsync server, synchronize

 

4.sersync

Sersync needs to be installed on the nfs server, nfs shared directory for real-time monitoring, when the increase in file appears, delete, modify, automatically triggered rsync

The contents of the transformed pushed to rsync server, real-time synchronization

A .) Mounting sersync 
#sersync relies inotify and rsync, it is necessary to install the corresponding software 
[the root NFS @ ~] # yum  the install the rsync inotify-Tools - Y 

# mounted sersync 
[the root NFS @ ~] # mkdir / Server / Tools - P 
[root @ nfs ~] # cd / Server / Tools / 
[root @ nfs Tools] # wget HTTPS: // storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/sersync/sersync2 .5.4_64bit_binary_stable_final.tar.gz 
[root @ nfs Tools] # tar XF sersync2. 5 .4_64bit_binary_stable_final. tar .gz 
[root @ nfs Tools] # mv GNU-Linux-x86/ /usr/local/sersync
[root@nfs tools]# cd /usr/local/sersync/
2).修改配置文件
[root@nfs sersync]# vim confxml.xml 
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
    <host hostip="localhost" port="8008"></host>
    <debug start="false"/>
    <fileSystem xfs="true"/> #监控对象 false改成true
    <filter start="false">
        <exclude expression="(.*)\.svn"></exclude>
        <exclude expression="(.*)\.gz"></exclude>
        <exclude expression="^info/*"></exclude>
        <exclude expression="^static/*"></exclude>
    </filter>
    <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">
            <remote ip="172.16.1.51" name="data"/>
            <!--<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="nfs_backup" passwordfile="/etc/nfs.passwd"/> #rsync的认证信息
            <userDefinedPort start="false" port="874"/><!-- port=874 -->
            <timeout start="false" time="100"/><!-- timeout=100 -->
            <ssh start="false"/>
        </rsync>
[root@nfs sersync]# echo "1" >/etc/nfs.passwd 
[root@nfs sersync]# chmod 600 /etc/nfs.passwd  

3 ) to start the service 
# sersync2 will execute the script linked to the system path 
[root @ nfs sersync] # LN -s / usr / local / sersync / sersync2 / usr / bin / 
[root @ nfs sersync] # sersync2 - H 
the SET at The System param 
the Execute: echo  50000000 > / proc / SYS / FS / inotify / max_user_watches 
the Execute: echo  327 679 > / proc / SYS / FS / inotify / max_queued_events 
the parse at the the Command param 
_______________________________________________________ 
parameters - d: enable daemon mode 
parameter - r: monitoring before, will monitor directory to a remote host using rsync push command again 
c parameters - the n-: Specifies the number of open daemon threads, the default is 10 
parameters- O: Specifies the configuration file, the file confxml.xml using default 
parameters -m: enable other modules alone, using - m refreshCDN open CDN refresh module 
parameters -m: enable other modules alone, using - m socket open socket module 
parameters -m: enable other modules alone, using - m http open http module 
without - m parameters, default program synchronization 
________________________________________________________________ 
[NFS sersync the root @] # sersync2 -dro /usr/local/sersync/confxml.xml

Guess you like

Origin www.cnblogs.com/xmtxh/p/12229931.html
Recommended