[root@sherry rsync]# cat /etc/rsyncd.conf
# Global Settings
uid = nobody
gid = nobody
use chroot = no
max connections = 10
strict modes = yes
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
[mysql]
path =/mydata/backup/rsync-mysql
ignore errors = yes
read only = no
write only = no
hosts allow = 192.168.1.0/24
hosts deny = *
list = false
uid = sherry
gid = sherry
auth users = tom
secrets file = /etc/rsyncd.passwd
[root@sherry rsync-mysql]# pwd
/mydata/backup/rsync-mysql
[root@sherry backup]# chown sherry.sherry rsync-mysql/ #用setfacl 数据一致性时候会报错
添加账号密码:
[root@sherry rsync]# cat /etc/rsyncd.passwd
tom:222222
[root@sherry rsync]# chmod 600 /etc/rsyncd.passwd
启动端口:
[root@sherry rsync]# chkconfig xinetd on
[root@sherry rsync]# service xinetd restart
[root@sherry rsync]# chkconfig rsync on
[root@sherry rsync]# ss -lntup|grep 873
tcp LISTEN 0 64 :::873 :::* users:(("xinetd",121111,5))
测试:
push 手动输入密码:
#client
[root@martin mysql]# touch a
[root@martin mysql]# ls
a
[root@martin mysql]# rsync a tom@sherry::mysql
Password:
#server
[root@sherry rsync-mysql]# ll
total 0
-rw-r--r-- 1 sherry sherry 0 May 28 10:01 a
push 用文件代替密码:
#client
[root@martin ~]# vim /etc/rsyncd.passwd
222222
[root@martin ~]# chmod 600 /etc/rsyncd.passwd
[root@martin mysql]# touch b
[root@martin mysql]# rsync --password-file=/etc/rsyncd.passwd b tom@sherry::mysql
#server
[root@sherry rsync-mysql]# ll
total 0
-rw-r--r-- 1 sherry sherry 0 May 28 10:01 a
-rw-r--r-- 1 sherry sherry 0 May 28 10:03 b
拉取:
[root@martin mysql]# rm -fr *
[root@martin mysql]# rsync --password-file=/etc/rsyncd.passwd tom@sherry::mysql/* .
[root@martin mysql]# ls
a b
增量上传:(上传服务器端没有的文件)
#client
[root@martin mysql]# rm -f *
[root@martin mysql]# ls
[root@martin mysql]# touch a b
[root@martin mysql]# ls
a b
[root@martin mysql]# rsync --password-file=/etc/rsyncd.passwd -az ./ tom@sherry::mysql
#server
[root@sherry rsync-mysql]# rm -f *
[root@sherry rsync-mysql]# ls
a b
#client
[root@martin mysql]# rm -f b
[root@martin mysql]# touch c
[root@martin mysql]# ls
a c
[root@martin mysql]# rsync --password-file=/etc/rsyncd.passwd -az ./ tom@sherry::mysql
#server
[root@sherry rsync-mysql]# ls
a b c
同步上传:(数据一致性)
12345678910111213 #client
[root@martin mysql]# touch d
[root@martin mysql]# ls
a c d
#server
[root@sherry rsync-mysql]# ls
a b c
#client
[root@martin mysql]# rsync --password-file=/etc/rsyncd.passwd -az --delete ./ tom@sherry::mysql
#server
[root@sherry rsync-mysql]# ls
a c d
同步下载:(数据一致性)
#server
[root@sherry rsync-mysql]# rm -f c
[root@sherry rsync-mysql]# touch g
[root@sherry rsync-mysql]# ls
a d g
#client
[root@martin mysql]# ls
a c d
[root@martin mysql]# rsync --password-file=/etc/rsyncd.passwd -az --delete tom@sherry::mysql ./
[root@martin mysql]# ls
a d g
Linux内核从2.6.13起开始支持inotify,通过inotify可以监控文件系统中添加 删除修改移动等各种事件。inotify是一种事件机制,它为应用程序文件系统提供实时响应事件的机制,相比cron的轮询机制相比,inotify资源消耗更低。
下载地址:
安装:
[root@martin inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify-tools-3.14
[root@martin inotify-tools-3.14]# make && make install
[root@martin local]# ln -sv /usr/local/inotify-tools-3.14/ /usr/local/inotify-tools