rsync同步文件的服务端,客户端配置,ubuntu,centos,debian
/ rsync这里贴一下配置,作为记录:
cat /etc/rsyncd.conf
# sample rsyncd.conf configuration file
# GLOBAL OPTIONS
#motd file=/etc/motd
#log file=/var/log/rsyncd
# for pid file, do not use /var/run/rsync.pid if
# you are going to run rsync out of the init.d script.
# The init.d script does its own pid file handling,
# so omit the "pid file" line completely in that case.
# pid file=/var/run/rsyncd.pid
#syslog facility=daemon
#socket options=
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/lock/rsyncd
# MODULE OPTIONS
[common]
comment = rsync info
path = /home/backup/
#该路径为需要同步的路径
ignore errors
auth users = li
secrets file = /etc/rsyncd.pass
hosts allow = *
hosts deny = *
list = false
port = 873
address = *
uid = root
gid = root
use chroot = no
read only = no
max connections = 10
rsync.pass里面写密码即可,不用写用户名。<注意客户端的是rsync.pass文件,服务端的是rsyncd.pass并且密码为用户名:铭文密码,所以客服端和服务端各有一个密码文件>
然后启动rsync --daemon
查看netstat -ntlp或者lsof -i:873已经有rsync在监听了。
另外在配置腾讯从华为服务器上同步内容的时候,华为的873没有允许所有端口,导致了好久没通过,
telnet ip 873来检查一下,是不是这里的问题
下面是客户端:
rsync -avz --password-file=/etc/rsync.pass li@destip::common /home/backup/
其中遇到的问题:
rsync #该路径为需要同步的路径 failed: No such file or directory (2)
rsync: change_dir failed: No such file or directory
我的问题是服务端配置文件,auth user写错了,理解错误,以为写上root实际上写客户端要验证的。
客户端那个密码也是写一个密码即可。
另外是
path = /home/backup/
后面写了个空格。
三十这个module没有配置,以为那个common是个文件夹的名字。
如此种种,试一试即可。
至于用什么服务器,其实linux都一样,rsync基本都自带了。
另外可以iptraf-ng查看传输记录。