Rsync+Notify NFS
Rsync+Notify:
yum install make gcc gcc-c++
客户端启动rsync port:873
/usr/local/rsync/bin/rsync --daemon --config=/usr/local/rsync/rsync.conf
Client:
tar xf rsync-3.0.9.tar.gz
cd rsync-3.0.9
./configure --prefix=/usr/local/rsync/
make && make install
rsync.conf 客户端配置
vi /usr/local/rsync/rsync.conf
uid = root
gid = root
use chroot = no
max connections = 10
strict modes = yes
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[xxx-xxx]
path = /path/to/file/
comment = xxxx
ignore errors
read only = no
write only = no
hosts allow = 192.168.1.100
hosts deny = *
list = false
uid = root
gid = root
auth users=xxx-user
secrets file = /usr/local/rsync/rsync.passwd
vi /usr/local/rsync/rsync.passwd
pwdpwdpwd
/usr/local/rsync/bin/rsync --daemon --config=/usr/local/rsync/rsync.conf
iptables -I INPUT 7 -p tcp --dport 873 -j ACCEPT
Server:
iptables -I INPUT 7 -p tcp --dport 873 -j ACCEPT
tar xf rsync-3.0.9.tar.gz
cd rsync-3.0.9
./configure --prefix=/usr/local/rsync/
make && make install
tar xf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14
./configure --prefix=/usr/local/inotify
make && make install
rsync服务端配置
vi /usr/local/rsync/rsync.passwd
pwdpwdpwd
vi /usr/local/rsync/rsync.sh
#!/bin/bash
#
host=192.168.1.101
src=/path/to/file/
des=xxxx
user=xxx-user
/usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src | while read files
do
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/usr/local/rsync/rsync.passwd $src $user@$host::$des
echo "${files} was rsynced" >>/var/log/rsync.log 2>&1
done
nohup sh /usr/local/rsync/rsync.sh &
tail -f nohup.out
tail -f /var/log/rsync.log
NFS:
Master:
yum install epel-release
yum repolist
yum makecache fast
yum install -y nfs-utils rpcbind
systemctl start rpcbind
systemctl start nfs
systemctl enable nfs
systemctl enable rpcbind
vi /etc/exports
/others/aisd 192.168.1.0/24(rw,no_root_squash,sync)
systemctl restart nfs
iptables -I INPUT 5 -s 192.168.1.101 -j ACCEPT
Salve:
yum install epel-release
yum repolist
yum makecache fast
yum install -y nfs-utils rpcbind
systemctl start rpcbind
systemctl start nfs
systemctl enable nfs
systemctl enable rpcbind
iptables -I INPUT 5 -s 192.168.1.100 -j ACCEPT
mkdir /others/aisd/
mount 192.168.1.100:/others/aisd/ others/aisd/
解绑:umount -l /others/aisd/
vi /etc/fatab
192.168.1.100:/others/aisd/ /others/aisd/ nfs defaults 0 0
mount -a
df -h