1th Chapter 50Full-network backup solution for Cluster Server1.1Basic Backup Requirements
known 3 server host names are a (WEB01),B (Backup) ,C (nfs01), respectively
requirements: Every night , the whole point on the Web server A Packaging backup system configuration files, Web site program directory and visit
ask the log and push backup on server B via the rsync command (backup ideas can be local by date
package, and then push to the backup server B ).
The specific requirements are as follows:
1) The backup directory for both Web server A and backup server B must be/backup.
2) The system configuration files to be backed up include, but are not limited to:
A. the configuration file for the scheduled task Service (/var/spool/cron/root).
B. Boot -up configuration file (/etc/rc.local).
C. directory of daily Scripts (/server/scripts).
D. firewall iptables configuration file (/etc/sysconfig/iptables).
E. What else do you need to back up when you think about it?
3) The WEB Server site Directory is assumed to be (/var/html/www).
4) Web server A Access log path assumed to be (/app/logs)
5) The Web server retains the packaged 7 days of backup data ( local retention cannot be more than 7 days, because too many hard drives are full )
6) on backup server B, Keep all copies of the data for every Monday, and the other to retain a copy of the data for 6 months.
7) Backup server B on the backup data server to the IP for the directory to save the backup, the backup file is saved by the time name
===========================================================================================1.1.1 Preparation Environment:
1.1.1.1 #Server-side environment:
Rpm-qa rsync
Yum Install Rsync-y
Useradd-s/sbin/nologin-m rsync
ID rsync
Vim/etc/rsyncd.conf
echo "Rsync_backup:oldboy" >/etc/rsync.password
chmod 600/etc/rsync.password
Mkdir/backup-p
Chown-r Rsync.rsync/backup
Rsync--daemon
Ps-ef|grep rsync|grep-v grep
1.1.1.2 #Client Environment:
echo "Oldboy" >/etc/rsync.password
chmod 600/etc/rsync.password
Mkdir/backup-p
================================== Client Push script ===========================================
#!/bin/sh
ip=$ (Ifconfig eth0|awk-f "[:]+" ' Nr==2{print $4} ')
Path= "/backup"
[!-D ${path}/$ip] && mkdir-p${path}/$ip &>/dev/null
Date= ' Date +%u-d ' -1day '
If [$DATE-eq 1];then
Date=${date}_mon
Fi
#tar
CD/&& \
Tar zcf/$path/$ip/conf_${date}.tar.gzvar/spool/cron/root etc/rc.local server/scripts etc/sysconfig/iptables& &\
Tar zcf/$path/$ip/www_${date}.tar.gzvar/html/www && \
Tar zcf/$path/$ip/logs_${date}.tar.gzapp/logs && \
#md5sum
Find $path-type f-name "*.tar.gz" |xargs md5sum >/$path/$ip/bak_${date}.flag
#rsync
rsync-az/$path/[email protected]::backup--password-file=/etc/rsync.password
#delete
Find $path/$ip-type f-mtime +7|xargs rm-f
===================================== server-side scripting ============================================
#!/bin/sh
ip=$ (Ifconfig eth1|awk-f "[:]+" ' Nr==2{print $4} ')
Path= "/backup"
[!-D ${path}/$ip] && mkdir-p${path}/$ip &>/dev/null
Date= ' Date +%u-d ' -1day '
If [$DATE-eq 1];then
Date=${date}_mon
Fi
find/backup/-type f-name "Bak_*.flag" |xargs md5sum-c >/$path/$ip/mail.${date}.log
Mail-s "Backup WEB_${DATE}-LM" [email protected] < $path/$ip/mail.${date}.log
Find $path-type f! -name "*mon*"-mtime +180|xargs rm-f
2nd Chaptersite cluster back endNfsshared storage setup and optimization solutions
1. Configure NFS services:
Requirements:
1) share/data/w_shared and /data/r_shared two file directories on NFS server C (NFS01), allowing NFS Client read-only from a (WEB01),B (Backup)/data/r_shared When a shared directory is mounted on a (WEB01), B (Backup), respectively , can write /data/w_shared.
2) mount point on NFS client A (WEB01) is/data/b_w(write),/data/b_r(Read), NFS client B ( Backup) on the mount point for /data/w_ your name in English (write) ,/data/r_ your name in English (read).
3) create arbitrary files from NFS writable mount point directory on NFS client B (Backup) from NFS client A (WEB01) You can delete this created file, or vice versa.
4) Question and answer: How to optimize service for NFS
hardware:sas/ssd disk, buy multiple pieces, hardware raid, specify raid5 or raid10. network card throughput is large, at least gigabit (multi-block bond)
server-side configurationfor NFS:/data 10.0.0.0/24 (rw,sync,all_squash,anonuid=65534,anongid=65534)
NFS Client Mount Optimization configuration command:
Mount-t Nfs-o nosuid,noexec,nodev,noatime,nodiratime,rsize=131072,wsize=13107210.0.0.31:/data//mnt← Safety Performance
Cat >>/etc/sysctl.conf<<eof
Net.core.wmem_default = 8388608
Net.core.rmem_default = 8388608
Net.core.rmem_max = 16777216
Net.core.wmem_max = 16777216
Eof
Sysctl-p
If the uninstall prompt "umount:/mnt:deviceis busy", you need to exit the Mount directory and then uninstall, if the NFS Server is down, you need to force uninstall, can execute umount -lf/mnt
Large web site The Alternative Software for NFS Web file systems is Distributed File System Moosefs (NFS),GlusterFS(large file),Fastnfs.
NFS the advantages and disadvantages of system application
==================================== Service-side environment =============================================
Yum Install nfs-utils rpcbind-y
Mkdir/data/w_shared-p
Mkdir/data/r_shared-p
Chown-r nfsnobody.nfsnobody/data/
/etc/init.d/rpcbind start
/etc/init.d/nfs start
Vim/etc/exports
/data/r_shared 172.16.1.0/24 (Ro,sync,all_squash)
/DATA/W_SHARED172.16.1.0/24 (Rw,sync,all_squash)
==================================== Client Mount =============================================
[Backup]
Mount-t NFS 172.16.1.31:/data/r_shared/data/r_luoming/
Mount-t NFS 172.16.1.31:/data/w_shared/data/w_luoming/
[WEB01]
Mount-t NFS 172.16.1.31:/data/r_shared/data/b_r
Mount-t NFS 172.16.1.31:/data/w_shared/data/b_w
Examples of operations:
[Email protected] b_w]# pwd
/data/b_w
[email protected] b_w]# Touch oldboy{1..5}.txt
[[email protected] b_w]# ls
Oldboy1.txt oldboy2.txt oldboy3.txt oldboy4.txt oldboy5.txt
[Email protected] w_shared]# pwd
/data/w_shared
[[email protected] w_shared]# ls
Oldboy1.txt oldboy2.txt oldboy3.txt oldboy4.txt oldboy5.txt
[Email protected] w_luoming]# pwd
/data/w_luoming
[[email protected] w_luoming]# ls
Oldboy1.txt oldboy2.txt oldboy3.txt oldboy4.txt oldboy5.txt
[[email protected] b_r]# Touch 123.txt
Touch:cannot Touch ' 123.txt ': read-onlyfile system--- read-only
3rd Chapterresolve a site cluster back endNfsshared storage single point for real-time data synchronization
1, real-time data synchronization requirements:
when a user writes data to NFS server C (nfs01) through a Web server , it is replicated to backup server B at the same time (backup)
NFS Server configuration file:
[Email protected] data]# Cat/etc/exports
#share/data by LM at 20161228
/data 172.16.1.0/24 (Rw,sync,all_squash)
Shared directory:
[Email protected] data]# ll-d/data/
Drwxr-xr-x 4 nfsnobody nfsnobody 266240 Jan 7 20:52/data/
NFS Server-side script:
vim/server/scripts/inotify.sh
#!/bin/sh
Path=/data
ip=172.16.1.41
/usr/bin/inotifywait-mrq--format '%w%f '-ecreate,delete,close_write/data/|while read line
Do
if [-f$line];then
Rsync-az $line--delete [email protected] $Ip:: Nfsbackup--password-file=/etc/rsync.password
Else
CD $Path && \
rsync-az/data/--delete [email protected] $Ip:: Nfsbackup--password-file=/etc/rsync.password
Fi
Done
Web client Mount:
[Email protected] mnt]# df-h
Filesystem Size used Avail use% mounted on
/dev/sda3 6.9G 1.5G 5.1G 23%/
Tmpfs 491M 0 491M 0%/dev/shm
/DEV/SDA1 190M 33M 147M 19%/boot
172.16.1.31:/data 6.9G 1.6G 4.9G 25%/mnt
To create a file:
[email protected] mnt]# Touch lidao.txt
NFS Server View:
[email protected] data]# ll Lidao.txt
-rw-r--r--1 nfsnobody nfsnobody 0 Jan 7 20:58 lidao.txt
To view the backup server:
[email protected] nfsbackup]# ll Lidao.txt
-rw-r--r--1 rsync rsync 0 Jan 7 20:58 lidao.txt
Old Boys Education 32-08-09 times on-machine test questions