使用rsync将本地文件更新到远程游…
2013-01-14 14:20
357 查看
rsync工具简介
rysnc是一个数据镜像及备份工具,具有可使本地和远程两台主机的文件,目录之间,快速同步镜像,远程数据备份等功能。在同步过程中,rsync是根据自己独特的算法,只同步有变化的文件,甚至在一个文件里只同步有变化的部分,所以可以实现快速的同步数据的功能。
更新rsync版本到最新:yum install
rsync
rpm -qa|grep -i rsync检查版本
参数说明:
-v, --verbose 详细模式输出
-z, --compress 对备份的文件在传输时进行压缩处理
-r, --recursive 对子目录以递归模式处理
-t, --times 保持文件时间信息
-p, --perms 保持文件权限
-o, --owner 保持文件属主信息
-g, --group 保持文件属组信息
服务器IP:192.168.1.253
游戏服平台:192.168.1.146
游戏服平台配置如下:
[root@localhost ~]# vim
/etc/rsyncd.conf
secrets file = /etc/rsyncd/.castlotpush_rsync.pwd
motd file = /etc/rsyncd/rsync.motd
read only = yes
list = yes
uid = root
gid = root
hosts allow = 192.168.1.253
hosts deny = 0.0.0.0/0
max connections = 2
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
[castlot_data]
comment = web folder
path = /data/castlot/client/
auth users = castlot_publish
read only =no
[root@localhost ~]# mkdir -p
/etc/rsyncd/
[root@localhost ~]# mkdir -p
/data/castlot/client/
[root@localhost ~]# vim
/etc/rsyncd/.castlotpush_rsync.pwd
castlot_publish:8QNXEDy2
[root@localhost ~]# chmod 600
/etc/rsyncd/.castlotpush_rsync.pwd
[root@localhost ~]#
ls -l
/etc/rsyncd/.castlotpush_rsync.pwd
-rw------- 1 root
root 25 02-17 17:24 /etc/rsyncd/.castlotpush_rsync.pwd
[root@localhost ~]# /usr/bin/rsync rsyncd --daemon
--config=/etc/rsyncd.conf
服务器配置如下:
[root@localhost ~]# mkdir -p
/etc/rsyncd/
[root@localhost ~]# vim
/etc/rsyncd/.castlotpush_rsync.pwd
8QNXEDy2
[root@localhost ~]# chmod 600
/etc/rsyncd/.castlotpush_rsync.pwd
[root@bogon client]#
rsync -vzrtopg --progress --delete-after
/data/castlot/client/ castlot_publish@192.168.1.146::castlot_data/
--password-file=/etc/rsyncd/.castlotpush_rsync.pwd
building file list ...
4 files to consider
./
anaconda-ks.cfg
1474 100%
0.00kB/s
0:00:00 (xfer#1, to-check=2/4)
install.log
48175 100%
11.49MB/s
0:00:00 (xfer#2, to-check=1/4)
install.log.syslog
5773 100%
805.39kB/s
0:00:00 (xfer#3, to-check=0/4)
sent 13763 bytes received 68
bytes 27662.00 bytes/sec
total size is 55422 speedup is 4.01
常见错误:
用户密码错误
@ERROR: auth failed on module test
rsync error: error starting client-server protocol (code 5) at
main.c(1503) [receiver=3.0.6]
检查存储密码文件是否出错
文件权限错误
password file must not be other-accessible
continuing without password file
Password:
@ERROR: auth failed on module ***
rsync error: error starting client-server protocol (code 5) at
main.c(1503) [receiver=3.0.6]
检查存储密码文件的权限是否为600, -rw-------
rsync: failed to connect to X.X.X.X: No route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(107)
[sender=2.6.8]
故障原因:对方没开机、防火墙阻挡、通过的网络上有防火墙阻挡,都有可能。
解决方法:关闭防火墙,或者把防火墙的tcp udp 的873端口打开,允许rsync通过。
实施方案:
1、防火墙的启动与停止
# service iptables start / stop
2、允许rsync通过防火墙
为防重启将规则清除,我将规则直接加到规则配置文件里边了(/etc/sysconfig/iptables),如下:
-A INPUT -p tcp -s X.X.X.X --dport 873 -j
ACCEPT
注意,这条规则要加在REJECT规则前。
加好后,重启下 iptables(# service iptables restart)。
rysnc是一个数据镜像及备份工具,具有可使本地和远程两台主机的文件,目录之间,快速同步镜像,远程数据备份等功能。在同步过程中,rsync是根据自己独特的算法,只同步有变化的文件,甚至在一个文件里只同步有变化的部分,所以可以实现快速的同步数据的功能。
更新rsync版本到最新:yum install
rsync
rpm -qa|grep -i rsync检查版本
参数说明:
-v, --verbose 详细模式输出
-z, --compress 对备份的文件在传输时进行压缩处理
-r, --recursive 对子目录以递归模式处理
-t, --times 保持文件时间信息
-p, --perms 保持文件权限
-o, --owner 保持文件属主信息
-g, --group 保持文件属组信息
服务器IP:192.168.1.253
游戏服平台:192.168.1.146
游戏服平台配置如下:
[root@localhost ~]# vim
/etc/rsyncd.conf
secrets file = /etc/rsyncd/.castlotpush_rsync.pwd
motd file = /etc/rsyncd/rsync.motd
read only = yes
list = yes
uid = root
gid = root
hosts allow = 192.168.1.253
hosts deny = 0.0.0.0/0
max connections = 2
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
[castlot_data]
comment = web folder
path = /data/castlot/client/
auth users = castlot_publish
read only =no
[root@localhost ~]# mkdir -p
/etc/rsyncd/
[root@localhost ~]# mkdir -p
/data/castlot/client/
[root@localhost ~]# vim
/etc/rsyncd/.castlotpush_rsync.pwd
castlot_publish:8QNXEDy2
[root@localhost ~]# chmod 600
/etc/rsyncd/.castlotpush_rsync.pwd
[root@localhost ~]#
ls -l
/etc/rsyncd/.castlotpush_rsync.pwd
-rw------- 1 root
root 25 02-17 17:24 /etc/rsyncd/.castlotpush_rsync.pwd
[root@localhost ~]# /usr/bin/rsync rsyncd --daemon
--config=/etc/rsyncd.conf
服务器配置如下:
[root@localhost ~]# mkdir -p
/etc/rsyncd/
[root@localhost ~]# vim
/etc/rsyncd/.castlotpush_rsync.pwd
8QNXEDy2
[root@localhost ~]# chmod 600
/etc/rsyncd/.castlotpush_rsync.pwd
[root@bogon client]#
rsync -vzrtopg --progress --delete-after
/data/castlot/client/ castlot_publish@192.168.1.146::castlot_data/
--password-file=/etc/rsyncd/.castlotpush_rsync.pwd
building file list ...
4 files to consider
./
anaconda-ks.cfg
1474 100%
0.00kB/s
0:00:00 (xfer#1, to-check=2/4)
install.log
48175 100%
11.49MB/s
0:00:00 (xfer#2, to-check=1/4)
install.log.syslog
5773 100%
805.39kB/s
0:00:00 (xfer#3, to-check=0/4)
sent 13763 bytes received 68
bytes 27662.00 bytes/sec
total size is 55422 speedup is 4.01
常见错误:
用户密码错误
@ERROR: auth failed on module test
rsync error: error starting client-server protocol (code 5) at
main.c(1503) [receiver=3.0.6]
检查存储密码文件是否出错
文件权限错误
password file must not be other-accessible
continuing without password file
Password:
@ERROR: auth failed on module ***
rsync error: error starting client-server protocol (code 5) at
main.c(1503) [receiver=3.0.6]
检查存储密码文件的权限是否为600, -rw-------
rsync: failed to connect to X.X.X.X: No route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(107)
[sender=2.6.8]
故障原因:对方没开机、防火墙阻挡、通过的网络上有防火墙阻挡,都有可能。
解决方法:关闭防火墙,或者把防火墙的tcp udp 的873端口打开,允许rsync通过。
实施方案:
1、防火墙的启动与停止
# service iptables start / stop
2、允许rsync通过防火墙
为防重启将规则清除,我将规则直接加到规则配置文件里边了(/etc/sysconfig/iptables),如下:
-A INPUT -p tcp -s X.X.X.X --dport 873 -j
ACCEPT
注意,这条规则要加在REJECT规则前。
加好后,重启下 iptables(# service iptables restart)。
相关文章推荐
- 使用rsync将本地文件更新到远程游戏服
- OS X / LINUX使用RSYNC拷贝远程服务器文件到本地
- rsync 简单使用 非默认ssh端口 分别从远程获取及推送本地的文件到远程
- Rsync使用非ssh默认端口从远程服务器同步文件到本地
- 使用SecureCRT在远程主机和本地之间传输文件
- ios开发之使用UIWebView打开本地的HTML、txt、PDF、PPT文件、打开远程的共享资源
- 使用TortoiseGit上传本地文件到远程服务器
- 使用XMLHttp和ADODB.Stream取得远程文件并保存到本地
- 在 Ubuntu 上使用 sshfs 映射远程 ssh 文件系统为本地磁盘
- » 在 Ubuntu 上使用 sshfs 映射远程 ssh 文件系统为本地磁盘 Wow! Ubuntu
- Objective-C之foundation框架中的NSString的使用方法、指针基本用法、读取本地和远程文件
- 使用SecureCRT在远程主机和本地之间传输文件
- 在Eclipse中,使用Aptana同步更新本地文件与FTP文件.
- fswatch rsync配置使用 实现远程与本地同步
- 上传和更新本地文件到GitHub远程仓库
- 使用paramiko模块复制远程文件到本地
- 使用SecureCRT在远程主机和本地之间传输文件
- 使用SecureCRT在远程主机和本地之间传输文件
- 使用SecueCRT在本地主机与远程主机之间交互文件
- 通过本地Excel文件更新远程SQL SERVER表中数据