Linux system cluster architecture online project configuration practice (end)

Time:2020-5-25

Linux system cluster architecture online project configuration practice (4)

Write in front

Today, I will introduce the whole network data backup planning and configuration process in the later stage of the project, including backup planning, scripting, data synchronization, etc

Network wide data backup planning

Data backup plan is as follows

data base

Open binlog from the database, and perform it through full backup and incremental backup. At 00:00 every day, full backup and 12:00 every day incremental backup. In case of small amount of data in the initial stage, adjust it according to the amount of data in the later stage

Local backup directory

/server/backup/mysql/data

/server/backup/mysql/binlog

FTPdata

Upload data synchronously in real time, prevent service failure, and switch quickly

/WWW / ftp synchronize to / www / ftp

Real time synchronization of other server data

For example, configuration file backup and code package backup

Local backup directory

/server/backup/app

/server/backup/sjapp

/server/backup/admin

/server/backup/shangjia

/server/backup/web

All data is retained locally for one week and remote backup server for 30 days

Database service backup configuration

mkdir /server/backup/mysql/data

mkdir /server/backup/mysql/binlog

mkdir /server/scripts/

Linux system cluster architecture online project configuration practice (end)

Linux system cluster architecture online project configuration practice (end)

Linux system cluster architecture online project configuration practice (end)

After the script is written, you need to write a scheduled task to execute regularly, and then check it manually

Cat>>/var/spool/cron/root<<EOF

00 00 * * * /bin/sh /server/scripts/fullbak.sh >/dev/null 2>&1

00 12 * * * /bin/sh /server/scripts/binlog_bak.sh >/dev/null 2>&1

EOF

Linux system cluster architecture online project configuration practice (end)

Static resource server data synchronization

Synchronization server creates peer directory

mkdir /www/ftp

Install Rsync service

Yum install rsync –y

Configure Rsync profile

vim /etc/rsyncd.conf

##rsync.conf config start

uid = rsync

gid = rsync

use chroot = no

max connetctions = 200

timeout = 100

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

log file = /var/log/rsyncd.log

[backup]

path = /www/ftp

ignore errors

read only = false

list = false

hosts allow = 10.0.0.8

auth users = rsync_backup

secrets file = /etc/rsync.password

##rsync config  end

Create user

useradd rsync -s /sbin/nologin -M

Configure permission settings password

chown -R rsync:rsync /www/ftp

echo "rsync_backup:rsync.conf">/etc/rsync.password

chmod 600 /etc/rsync.password

Start service

rsync –daemon

[[email protected] ~]# netstat -lntup|grep rsync

tcp  0 0 0.0.0.0:873  0.0.0.0:*  LISTEN  26280/rsync

Client configuration password

echo "rsync.conf">/etc/rsync.password

chmod 600 /etc/rsync.password

Test whether manual data synchronization is successful

[[email protected] ~]# rsync -avzP /etc/hosts [email protected]::backup --password-file=/etc/rsync.password

sending incremental file list

hosts

473 100%    0.00kB/s    0:00:00 (xfer#1, to-check=0/1)

sent 314 bytes  received 27 bytes  682.00 bytes/sec

total size is 473  speedup is 1.39

[[email protected] ~]# ll /www/ftp

total 4

-rw-r--r-- 1 rsync rsync 473 May 26 13:24 hosts

Client installation of sersync service

tar zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz -C /usr/local/

[[email protected] ~]# cd /usr/local/

[[email protected] local]# mv GNU-Linux-x86 sersync

Specification file directory

[[email protected] sersync]# mkdir -p conf bin logs

Copy configuration file and modify

[[email protected] sersync]# mv confxml.xml conf/

[[email protected] sersync]# mv sersync2 bin/sersync

Modify profile content(confxml.xml

1. Modify lines 24-28

<localpath watch="/opt/tongbu">

 <remote ip="10.0.0.11" name="tongbu1"/>

 Content of notes

 Content of notes

        </localpath>

The modified content is

 < localpath watch = "/ www / ftp" > path of local data

  < remote IP = "10.0.0.11" name = "backup" / > remote IP and module name

         </localpath>

 Comments

2. Revise lines 31-34 – Certification

<commonParams params="-artuz"/>

<auth start="false" users="root" passwordfile="/etc/rsync.pass"/>

<userDefinedPort start="false" port="874"/><!-- port=874 -->

<timeout start="false" time="100"/><!-- timeout=100 -->

<ssh start="false"/>

The modified content is

<commonParams params="-aruz"/>

<auth start="true" users="rsync_backup"  passwordfile="/etc/rsync.password"/>

<userDefinedPort start="false" port="874"/><!-- port=874 -->

<timeout start="true" time="100"/><!-- timeout=100 -->

<ssh start="false"/>

3. Modify lines 36-37

<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default

 every 60mins execute once-->

Change to the logs directory we just created

<failLog path="/usr/local/sersync/logs/rsync_fail_log.sh" timeToExecut

e="60"/><!--default every 60mins execute once-->

Configure environment variables

echo 'export PATH=$PATH:/usr/local/sersync/bin'>>/etc/profile

[[email protected] sersync]# source /etc/profile

[[email protected] sersync]# which sersync

/usr/local/sersync/bin/sersync

Start service

[[email protected] sersync]# sersync -r -d -o /usr/local/sersync/conf/confxml.xml

Test real time synchronization

[[email protected] opt]# cd backup/

[[email protected] backup]# ll

total 0

[[email protected] ~]# cd /www/ftp

[[email protected] backup]# ll

total 0

[[email protected] ftp\]# for i in `seq 10`;do mkdir -p /opt/backup/$i;done

[[email protected] ftp]# ll

1 5 10 6 2 7 3 8 4 9 

[[email protected] ftp]# ls

1 5 10 6 2 7 3 8 4 9

Can be synchronized

Network wide server data synchronization configuration

Backup server configuration

[user-app]

path = /mnt/backup/user-app

ignore errors

read only = false

list = false

hosts allow = 10.0.0.4

auth users = rsync_backup

secrets file = /etc/rsync.password

  

[sj-app]

path = /mnt/backup/sj-app

ignore errors

read only = false

list = false

hosts allow = 10.0.0.5

auth users = rsync_backup

secrets file = /etc/rsync.password

  

[admin]

path = /mnt/backup/admin

ignore errors

read only = false

list = false

hosts allow = 10.0.0.6

auth users = rsync_backup

secrets file = /etc/rsync.password

  

[shangjia]

path = /mnt/backup/shangjia

ignore errors

read only = false

list = false

hosts allow = 10.0.0.7

auth users = rsync_backup

secrets file = /etc/rsync.password

  

[web]

path = /mnt/backup/web

ignore errors

read only = false

list = false

hosts allow = 10.0.0.8

auth users = rsync_backup

secrets file = /etc/rsync.password

Other synchronization client installation and configuration of sersync shall be carried out according to the above operations

Basically, backup scripts pack and backup or directly copy files to the local backup directory

Other project articles can be viewed in previous reviews

—–So far, the whole project process has been introduced—–