| 1 2 3 4 5 6 7 8 9 10 11 12 13 | # vi /etc/xinetd.d/rsync # default: off# allows crc checksumming etc.service rsync{ disable = no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += USERID} |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # vi /etc/rsyncd.conf uid = rootgid = rootuse chroot = yesmax connections = 4strict modes = yessyslog facility = local5port = 873[backup]path = /home/rsync/test/ ##要同步的文件夹comment = This is a testignore errorsread only = no ##写权限list = yesauth users = rsyncsecrets file = /etc/rsync.pas ##验证文件,对方机子也要存在这个文件hosts allow = 192.168.1.190 ##客户端IP |
| 1 2 | # vi /etc/rsync.passync:test |
| 1 2 3 4 5 6 7 8 | #vi inotify_rsync.sh#!/bin/bashSRC=/home/rsync/test/DST=rsync@192.168.1.217::backup/usr/bin/inotifywait -mrq -e modify,<del datetime="2011-11-07T01:44:44+00:00">delete</del>,create,attrib ${SRC} | while read D E Fdo/usr/bin/rsync -ahqzt --progress <del datetime="2011-11-07T01:44:44+00:00">--delete</del> --password-file=/etc/rsync.pas $SRC $DSTdone |
| 1 | # cat "/root/inotify_rsync.sh &" >> /etc/rc.local |
| 1 2 3 4 5 | #service portmap start#service nfs start#vi /etc/exports /home/rsync/test *(rw,sync,no_root_squash) ##rw:可读写的权限;sync:资料同步写入存储器中; no_root_squash: 登入到NFS主机的用户如果是ROOT用户,他就用有ROOT的权限# exportfs -rv ##重新将设定加载 |
| 1 | mount -t nfs 192.168.1.190:/home/rsync/test /home/rsync/test |
本文出自 “kras-linux” 博客,请务必保留此出处http://klinux.blog.51cto.com/2972664/708294
