博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何保持Linux服务器间的文件同步
阅读量:2454 次
发布时间:2019-05-10

本文共 2503 字,大约阅读时间需要 8 分钟。

具体操作步骤:

配置/etc/rsyncd.conf文件:

uid = nobody

gid = nobody
use chroot = no
max connections = 4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log

[test01]

path = /front/test01
ignore errors
read only = true
list = false
hosts allow = 192.168.1.252
hosts deny = 192.168.1.0/24
auth users = test01
secrets file = /etc/rsync.secret

[back]

path = /front/back
ignore errors
read only = true
list = false
hosts allow = 192.168.1.252
hosts deny = 192.168.1.0/24

配置test01目录需要密码,back用户不需要

建立密码文件
[root@tonykorn front]# cat /etc/rsync.secret
test01:test01
[root@tonykorn front]#

修改启动rsync文件

[root@tonykorn etc]# cat /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it
# allows crc checksumming etc.
service rsync
{
# disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
[root@tonykorn etc]#

启动服务端

[root@tonykorn front]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@tonykorn front]#

也有的地方说需要运行:rsync --daemon,经过试验不需要

没有运行rsync --daemon的时候进程状态是:
[root@tonykorn front]# ps -ef | grep rsync
root 24033 15043 0 17:40 pts/0 00:00:00 grep rsync

运行后为:

[root@tonykorn front]# rsync --daemon
[root@tonykorn front]# ps -ef | grep rsync
root 24035 1 0 17:40 ? 00:00:00 rsync --daemon
root 24042 15043 0 17:40 pts/0 00:00:00 grep rsync
[root@tonykorn front]#

客户端操作

客户端同步出错:
[test01@tonykorn02 ~]$ rsync -vzrtopg --progress /front/test01
Password:
@ERROR: auth failed on module test01
rsync error: error starting client-server protocol (code 5) at main.c(1296) [receiver=2.6.8]
[test01@tonykorn02 ~]$
原因:
secret file的文件属性有问题,该文件属性要是600的
[root@tonykorn etc]# ls -al rsync.secret
-rw-r--r-- 1 root root 14 Apr 2 17:04 rsync.secret
[root@tonykorn etc]# chmod 600 rsync.secret
[root@tonykorn etc]#

此时运行,test01需要密码,输入密码后可以,back不需要密码,直接可以同步

[root@tonykorn02 front]# rsync -vzrtopg --progress /front/test01
Password:
receiving file list ...
421 files to consider

sent 98 bytes received 8031 bytes 2322.57 bytes/sec

total size is 134589856 speedup is 16556.75
[root@tonykorn02 front]# rsync -vzrtopg --progress /front/back
receiving file list ...
50 files to consider

sent 62 bytes received 1007 bytes 2138.00 bytes/sec

total size is 12629876 speedup is 11814.66
[root@tonykorn02 front]#

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/312079/viewspace-245849/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/312079/viewspace-245849/

你可能感兴趣的文章
街机飞机游戏合集_建立游戏引擎,经典街机游戏的转折以及更多游戏新闻
查看>>
怎样用控制台开发游戏_适用于游戏开发人员HTML5,如何构建控制台以及更多游戏新闻
查看>>
优必选能开放软硬件源代码吗_开放式硬件问题将得到解答
查看>>
gog无效的验证码_GOG Galaxy Beta,适用于复古游戏的KADE miniConsole +和更多游戏新闻
查看>>
SuperTuxKart版本,Linux游戏以及更多开放游戏新闻
查看>>
Kilo版本已发布,以及其他OpenStack新闻
查看>>
summit_Summit上的用户故事以及更多OpenStack新闻
查看>>
openstack 峰会_下一届OpenStack峰会,错误修复黑客马拉松等等
查看>>
openstack中rpc_课堂中的OpenStack,PTL投票开始等等
查看>>
openstack用户列表_投票给OpenStack超级用户奖,破纪录的贡献等等
查看>>
openstack_OpenStack如何翻译
查看>>
openstack 峰会_OpenStack代码冲刺,为温哥华峰会做准备,以及更多
查看>>
银行开放api接口_开放标准API如何彻底改变银行业
查看>>
adi ibis_IBIS:基于Drupal的功能强大的信息收集工具
查看>>
阿里云自动化部署_自动化是云的关键
查看>>
bitnami_Bitnami:服务器软件的应用程序商店
查看>>
devops和docker_使用Docker的现代DevOps
查看>>
openstack项目_DefCore,项目管理和OpenStack的未来
查看>>
nlp学术研究_4种学术研究的新工具
查看>>
drupal 页面分栏_使用段落在Drupal中构建更好的页面
查看>>