linux 重启rsync服务,linux停配置rsync文件同步服务

本文详细介绍了如何在Linux上配置rsync文件同步服务,包括修改xinetd.d/rsync文件,设置rsync自动启动,配置rsyncd.conf,创建并设置rsync密码文件,以及客户端的配置和计划任务设置。此外,还讲解了如何检查和重启rsync服务。

当前位置: 我的异常网 » Linux/Unix » linux停配置rsync文件同步服务

linux停配置rsync文件同步服务

www.myexceptions.net,网友分享于:2012-06-30   浏览:6次

linux下配置rsync文件同步服务

服务端配置:

前提:安装了xinetd和rsync

1. 修改/etc/xinetd.d/rsync文件

将下列内容中disable=yes改为no

service rsync

{

disable = yes

socket_type     = stream

wait            = no

user            = root

server          = /usr/bin/rsync

server_args     = --daemon

log_on_failure  += USERID

}

2. 配置rsync自动启动

执行命令:chkconfig rsync on

执行命令chkconfig rsync --list后可以看到如下内容:

rsync           on

3. 配置rsyncd.conf,该文件一般来说是不存在的,需要自己创建,内容示例如下:

uid = root

gid = root

use chroot = no

max connections = 4  (最大连接数,可以适当调整。)

strict modes = yes

port = 873  (默认端口,最好不要修改。)

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

log file = /var/log/rsyncd.log

[test]  (这个是模块名称,可以配置多个模块分别对应服务端不同的目录。)

path = /test  (这个是该模块对应的服务端路径)

comment = This is test

auth users = rsync  (客户端连接上来进行同步所使用的用户名,可以任意取名,但是后面的配置要对应。)

uid = root

gid = root

secrets file = /home/rsync.ps  (口令文件,里面保存同步所使用的用户名和口令)

read only = no

list = no

4 确保etc/services中rsync端口号正确

一般为如下内容:

rsync           873/tcp                         # rsync

rsync           873/udp                         # rsync

5 配置rsync密码(在上边的配置文件中已经写好路径)/home/rsync.ps(创建这个文件,名字随便写,只要和上边配置文件里的一致即可),格式为(用户名:密码),一行一个用户。

例如:

rsync:rsync

6 配置rsync密码文件权限

chown root.root rsync.ps

chmod 400 rsync.ps

7 启动配置

service xinetd restart

Stopping xinetd:                                           [  OK  ]

Starting xinetd:                                           [  OK  ]

8 检查rsync是否启动

执行命令:lsof -i :873

正常情况应该显示如下内容:

COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME

xinetd  4396 root    5u  IPv4 633387       TCP *:rsync (LISTEN)

客户端配置:

1. 设定口令文件/home/rsync.ps ,这个文件随便起名,放在任意目录都可以,和服务端的配置没关系,但是内容只有一个密码,并且是要和服务端一致。

根据上面服务端的配置,这里的内容应该是:

rsync

然后修改文件权限:

chown root.root rsync.ps

chmod 600 rsync.ps

2. 将rsync指令放入计划任务(crond),假设服务端ip为192.168.1.100

先测试是否可以使用

从服务端取数据: rsync -avz --progress --delete --password-file=/opt/rsync.ps  rsync@192.168.1.100::test  /opt/web/public/

向服务端发数据: rsync -avz --progress --delete --password-file=/opt/rsync.ps  /opt/web/public/  rsync@192.168.1.100::test

修改/etc/crontab文件,增加类似如下内容(每分钟执行一次,从服务端取数据):

* * * * * rsync -avz --progress --delete --password-file=/opt/rsync.ps  rsync@192.168.1.100::test  /opt/web/public/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值