CenOS 生產環境部署 RSYNC
準備編譯下載環境
yum install gcc gcc-c++ wget
下載
wget https://download.samba.org/pub/rsync/src/rsync-3.1.2.tar.gz
安裝
tar zxvf rsync-3.1.2.tar.gz
cd rsync-3.1.2
./configure --prefix=/usr/local/rsync
make
make install
配置
vim /etc/rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 4
pid file = /var/run/rsyncd.pid
Advertisements
exclude = lost+found/
transfer logging = yes
timeout = 900
ignore nonreadable = yes
dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 *.7z
[ziplog]
path = /home/ziplog
comment = ziplog
read only = false
hosts allow = 192.168.1.140
hosts deny = 0.0.0.0/0
secrets file = /etc/rsync.pass
[ziplog2]
path = /home/ziplog2
Advertisements
comment = ziplog2
read only = false
hosts allow = 192.168.1.140
hosts deny = 0.0.0.0/0
secrets file = /etc/rsync.pass
vim /etc/rsync.pas
ziplog:xxxxxx
啟動
systemctl start rsyncd
systemctl enable rsyncd
檢查
[root@localhost ~]# vim /etc/rsync.pas
[root@localhost ~]# netstat -a | grep rsync
tcp 0 0 0.0.0.0:rsync 0.0.0.0:* LISTEN
tcp6 0 0 [::]:rsync [::]:* LISTEN
[root@localhost ~]# ps -ef | grep rsync
root 31135 1 0 15:12 ? 00:00:00 /usr/bin/rsync --daemon --no-detach
root 31355 30727 0 15:27 pts/1 00:00:00 grep --color=auto rsync
使用
# 從 SERVER 取文件
/usr/bin/rsync -vzrtopg --progress 192.168.1.110::ttlop_backup /root/ttlopBackup/
# 向 SERVER 傳文件,需要在相應模塊中添加 read only = false,確保不是只讀的許可權
/usr/bin/rsync -vzrtopg --progress /root/ttlopBackup/ 192.168.1.110::ttlop_backup