inotify+rsync文件实时同步安装配置

Time:2010-01-25 05:44:48. Author:millken. Category:技术. Tags:inotify,rsync.

上次还要挂载分区,这次配置简单方便,对系统没有任何影响。

[root@host210 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
0c:68:96:dc:d4:e3:d7:0f:e4:8f:52:b7:6b:18:9f:38 root@host210
[root@host210 ~]# scp ~/.ssh/id_rsa.pub root@192.168.10.211:/root/  #拷贝到211
The authenticity of host '192.168.10.211 (192.168.10.211)' can't be established.
RSA key fingerprint is be:a6:fe:ce:a8:33:ca:be:cb:71:3d:25:d1:d3:38:9c.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '192.168.10.211' (RSA) to the list of known hosts.
root@192.168.10.211's password:
id_rsa.pub 100% 394 0.4KB/s 00:00
[root@host210 ~]#
[root@host210 softWare]# wget http://rsync.samba.org/ftp/rsync/rsync-3.0.6.tar.gz
--23:22:51-- http://rsync.samba.org/ftp/rsync/rsync-3.0.6.tar.gz
Resolving rsync.samba.org... 216.83.154.106
Connecting to rsync.samba.org|216.83.154.106|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 778927 (761K) [application/x-gzip]
Saving to: `rsync-3.0.6.tar.gz'
100%[=======================================>] 778,927 56.1K/s in 14s
23:23:05 (56.1 KB/s) – `rsync-3.0.6.tar.gz’ saved [778927/778927]
[root@host210 softWare]#tar zxvf rsync-3.0.6.tar.gz
[root@host210 softWare]#cd zxvf rsync-3.0.6
[root@host210 rsync-3.0.6]# ./configure
[root@host210 rsync-3.0.6]# make && make install
[root@host210 rsync-3.0.6]# cd ../
[root@host210 softWare]# tar zxvf inotify-tools-3.13.tar.gz
[root@host210 inotify-tools-3.13]# ./configure
[root@host210 inotify-tools-3.13]# make && make install
[root@host210 /]# cd root/
[root@host210 ~]# vi inotify_rsync.sh
#!/bin/sh
src=/root
des=/webServer/softWare/images
ip=192.168.10.211
/usr/local/bin/inotifywait -mrq –timefmt ‘%d/%m/%y %H:%M’ –format ‘%T %w%f’ \
-e modify,delete,create,attrib \
${src} \
| while read file
do
rsync -avz –delete –progress ${src} root@${ip}:${des} &&
echo “${file} was rsynced”
echo “—————————————————————————”
done
[root@host210 ~]# chmod 755 inotify_rsync.sh
[root@host210 ~]# inotify_rsync.sh &
[root@host210 ~]# rsync: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
—————————————————————————
rsync: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
—————————————————————————
[root@host210 ~]# ldd /usr/local/bin/rsync
linux-gate.so.1 => (0×005e4000)
libpopt.so.0 => /usr/lib/libpopt.so.0 (0×00dea000)
libiconv.so.2 => not found
libc.so.6 => /lib/libc.so.6 (0×00110000)
/lib/ld-linux.so.2 (0×004f5000)
[root@host210 ~]# vi /etc/ld.so.conf
加一行/usr/local/lib
[root@host210 ~]# ldconfig
[root@host210 ~]# vi /etc/ld.so.conf
#登录211
[root@host211 ~]# cat /root/id_rsa.pub >> /root/.ssh/authorized_keys
[root@host211 ~]# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
[root@host211~]#

有什么要说的?





* 所有字段必须填写.

关于我:

陈震(millken) 男 26岁 高级程序员

湖南石门人,现混迹于上海。

联系方式:millken#gmail.com

开放分类