In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The data of the front Web Server is stored in the NFS server,NFS Server regular monitoring data, and when the data changes, it is automatically synchronized to the rsync server. The rsync server stores the Web Server data files and the configuration files of each server. The data of Web Server are all in NFS and rsync.
Actual combat on the plane
There is a Web server in a company, in which the data is very important. If the hard drive is broken, the data will be lost. Now the leader requires that the data be backed up, so that the data loss of the Web server can be recovered.
Demand:
Package the backup system configuration files, website program directories and access logs on Web server An exactly at 00:00 every night, and push them to server B for backup by rsync command (backup idea can be to package the logs locally now, and then push them to backup server B).
Problem 1. Backup the data from Web server A to server B
Specific requirements:
1) the backup directories of both Web server An and backup server B must be / backup
2) system configuration files include, but are not limited to:
A) configuration file for the scheduled task service (/ var/spool/cron/root)
B) self-boot configuration file (/ etc/rc.local)
C) Directory of daily scripts (/ server/scripts)
D) configuration file for firewall iptables (/ etc/sysconfig/iptables)
E) think about what else needs to be backed up
3) the Web server site directory is assumed to be (/ var/html/www)
4) Web server An access log path is assumed to be (/ app/logs)
5) the Web server can keep the backup data for 7 days after packaging (the local retention cannot be more than 7 days, because too many hard disks will be full), and the backup server B should keep a copy of the data for 6 months.
6) the backup server B should save the directory according to the IP of the backup data server, and the packaged files should be saved according to the time name.
Achieve:
1.B server configuration rsync server
Uid=rsync
Gid=rsync
Use chroot = no
Max connections = 2000
Timeout = 600,
Pid file = / var/run/rsyncd.pid
Lock file = / var/run/rsync.lock
Log file = / var/log/rsyncd.log
Ignore errors
Read only = false
List = false
Hosts allow = 192.168.24.0 Universe 24
Hosts deny = 0.0.0.0amp 32
Auth users = rsync_backup
Secrets file = / etc/rsync.password
# #
[backup]
Comment = backup server
Path=/backup
Create a rsync user puppet account without a home directory
Useradd rsync-s / sbin/nologin-M
Create / backup directory
Mkdir / backup
Create a rsync.password password file
Echo "rsync_backup:oldboy" > / etc/rsync.password
Chmod 600 / etc/rsync.password
Rsync-daemon turn on test whether it works properly
Rsync-daemon
Join the boot self-boot
Echo "rsync-- daemon" > > / etc/rc.local
Check whether it can be transmitted
Rsync-avz / tmp/backup/ rsync_backup@192.168.24.32::backup
two。 Test backup files
A) configuration file for the scheduled task service (/ var/spool/cron/root)
B) self-boot configuration file (/ etc/rc.local)
C) Directory of daily scripts (/ server/scripts)
D) configuration file for firewall iptables (/ etc/sysconfig/iptables)
E) think about what else needs to be backed up
7) the Web server site directory is assumed to be (/ var/html/www)
8) Web server An access log path is assumed to be (/ app/logs)
Pack ameld, pack 7, 7, 7, 8, 7, 8, 8, 7, 8, 8, 7, 8, 8, 7, 7, 8, 8, 7, 8, 8, 7, 8, 8, 7, 8, 8, 7, 7, 8, 8, 7, 8, 8, 7, 8, 8, 7, 8, 8, 8, 7, 8, 8, 8, 7, 8, 8, 8, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 7, 7, 8, 7, 7, 8, 7, 7, 8, 7, 7, 8, 8, 7, 7, 7, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
Mkdir / backup/ "`ifconfig ens192 | awk-F'[:] +''NR==2 {print $3}' `_ $(date +% F)"
Cp / etc/rc.local / backup/192.168.24.21_2019-11-14 RC. localizations $(date +% F)
Other files are copied in this format
% File name _% date
Write as a sh script:
[root@lnmp01 /] # vi backup.sh
IP=$ (ifconfig ens192 | awk-F'[:] + 'NR==2 {print $3}')
Path= "/ backup/$IP."
[!-d / backup/$IP] & & mkdir / backup/$IP-p
#! / bin/sh
Tar zcf $Path/www_$ (date +% F) .tar.gz / var/html/www/
Tar zcf $Path/conf_$ (date +% F). Tar.gz / var/spool/cron/root / etc/rc.local / etc/sysconfig/iptables / server/scrips
Tar zcf $Path/log_$ (date +% F) .tar.gz / app/logs/
# backup to server
Rsync-avz / backup rsync_backup@192.168.24.32::backup-- password-file=/etc/rsync.password
# del
Find / backup-type f-name "* .tar.gz"-mtime + 7 | xargs rm-f
Set scheduled tasks:
[root@lnmp01 backup] # crontab-l
#
00 * / bin/sh / server/scrips/backup.sh & > / dev/null
Set up a scheduled task on the server side to retain data for 6 months
[root@localhost ~] # vi / server/scrips/backupdel.sh
/ bin/find / backup-type f-name "* .tar.gz"-mtime + 180 | xargs rm-f
[root@localhost] # crontab-e
No crontab for root-using an empty one
#
00 00 * / bin/sh / server/scrips/backupdel.sh
Determine file integrity by adding md5 check values
[root@lnmp01 backup] # find / backup/-type f-name "* $(date +% F) .tar.gz" | xargs md5sum > / backup/flag_$ (date +% F)
Use the-c parameter to test whether the file is complete
[root@lnmp01 backup] # md5sum-c flag_2019-11-19
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.