一、rsync+sersync實(shí)時(shí)同步數(shù)據(jù)
連接上邊的nextcloud私人網(wǎng)盤搭建
IP |
服務(wù) |
端口 |
192.168.1.134 |
Sersync |
|
192.168.1.150 |
Rsync |
873 |
先關(guān)閉防火墻與SELinux
服務(wù)端部署(150)
1.檢查軟件是否安裝
rpm -qa rsync
yum install -y rsync
2.編寫配置文件(先做的工作)
vim /etc/rsyncd.conf
uid=root
gid=root
max connections=36000
use chroot=no
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
[backup]
path=/u01/nextcloud/data/
comment = backup nextcloud
ignore errors
read only = no
hosts allow = 192.168.1.134/24
hosts deny = *
3.創(chuàng)建備份目錄
mkdir /u01/nextcloud/data/ -p
4.創(chuàng)建認(rèn)證密碼文件
echo “rsync_backup:aiyouwei” >/etc/rsync.password
chmod 600 /etc/rsync.password
(umask 077;echo “rsync_backup:oldboy123” >/etc/rsync.password)
5.啟動(dòng)rsync守護(hù)進(jìn)程
rsync –daemon
6.添加到開機(jī)自啟動(dòng)
vim /etc/rc.local
rsync –daemon
客戶端部署(134)
1.創(chuàng)建認(rèn)證密碼文件,并進(jìn)行授權(quán)
echo “aiyouwei” >/etc/rsync.password
chmod 600 /etc/rsync.password
2.進(jìn)行免交互傳輸文件測(cè)試
touch /tmp/test.txt
rsync -avz /tmp/test.txt rsync_backup@192.168.1.150::backup –password-file=/etc/rsync.password
二、sersync安裝配置(134)
1.安裝包已上傳到Linux公社資源站:
——————————————分割線——————————————
免費(fèi)下載地址在 http://linux.linuxidc.com/
用戶名與密碼都是www.linuxidc.com
具體下載目錄在 /2018年資料/10月/31日/rsync+sersync實(shí)時(shí)同步NextCloud數(shù)據(jù)/
下載方法見 http://www.linuxidc.com/Linux/2013-07/87684.htm
——————————————分割線——————————————
2.下載安裝包上傳到
/usr/local/src
3.解壓
unzip sersync_installdir_64bit.zip
4.移動(dòng)目錄
cd sersync_installdir_64bit/sersync
mv sersync_installdir_64bit/sersync/ ./../sersync
5.授權(quán)
cd /usr/local/sersync/bin/
chmod +x sersync
6.修改配置文件
vim /usr/local/sersync/conf/confxml.xml
7.設(shè)置sersync檢查腳本
mkdir -p /home/crontab/
vim check_sersync.sh
chmod +x check_sersync.sh
#!/bin/sh
sersync=”/usr/local/sersync/bin/sersync”
confxml=”/usr/local/sersync/conf/confxml.xml”
status=$(psaux |grep ‘sersync2’|grep -v ‘grep’|wc -l)
if [$status -eq 0 ];
then
$sersync -d-r -o $confxml &
else
exit 0;
fi
8.設(shè)置定時(shí)任務(wù)
crontab -e
# 檢查sersync是否運(yùn)行
*/5 * * * * /bin/bash /home/crontab/check_sersync.sh >/dev/null 2>&1
9.加入到開機(jī)自啟動(dòng)
Vim /etc/rc.local
/usr/bin/rsync –daemon
/usr/local/sersync/bin/sersync -d -r -o /usr/local/sersync/confxml.xml
10.驗(yàn)證
在134上的同步目錄下創(chuàng)建文件,到150上查看是否存在