略微加速

略速 - 互联网笔记

配置rsync服务端

2020-12-16 leiting (3635阅读)

标签 Linux 运维

安装rsync和xinetd:
yum install rsync xinetd配置rsync服务器端


配置xinetd:
vim /etc/xinetd.d/rsync
#disable = yes修改为
disable = no

service rsync
{
    disable     = no
    flags       = IPv6
    socket_type     = stream
    wait            = no
    user            = root
    server          = /usr/bin/rsync
    server_args     = --daemon
    log_on_failure  += USERID
}


1、创建rsync服务器配置文件/etc/rsyncd.conf


-------------------------------------------------

[root]# vim /etc/rsyncd.conf

uid = root

gid = root

port = 873                                #指定运行端口,默认是873,您可以自己指定

#hosts allow = 192.168.0.204, 192.168.1.205          #允许访问的客户机

#hosts deny = 0.0.0.0/32                       #拒绝访问的

use chroot = 

max connections = 

timeout=


## 下面这些绿色文件是安装完RSYNC服务后自动生成的文件,当然也可以手动配置到指定路径

pid file = /var/run/rsyncd.pid       ##pid文件的存放

lock file = /var/run/rsync.lock      ##锁文件的存放位置

log file = /var/log/rsyncd.log       ##日志记录文件的存放

#motd file = /etc/rsyncd.motd        #欢迎



## 上面这段是全局配置,下面的模块可以有

[test]                    ## 模块名字,自己命名

path = /home/workspace/test       #指定文件目录所在位置,这是必须指定 

comment = rsync files           ## 注释

ignore errors                 ##忽略IO

read only = no

list = no                   ## 是否把rsync 服务器上提供同步数据的目录显示

## 下面这一行,同步验证时用的账号,如果没有这项就是匿名同步,client同步时不用用户名也能同步。

auth users = admin

secrets file = /etc/rsync.passwd             ## 指定认证文件

-------------------------------------------------


2、然后创建认证文件:

[root]# vim /etc/rsync.passwd


admin:123456            ## 用户名:密码。注意这个不是系统用户,只是rsync用户。所以不用useradd。

(名字随便写,只要和上边配置文件里的“auth users”参数一致即可),格式(一行一个用户)

账号:密码


把密码文件的权限改成600

[root]# chmod 600 /etc/rsync.passwd          ## 只能所有者可读,否则报错


把所属用户改为root(配置中的,如果不是的话)

[root]# chown root /etc/rsync.passwd



3、如果在配置文件中指定了欢迎信息,在/etc下创建rsyncd.motd,设置欢迎信息:

[root]# vim /etc/rsyncd.motd 

Welcome the rsync services!



4、启动rsync

在启动之前,可以先看一下rsync是否已经启动运行:用lsof或者nestat都可以,启动rsync服务端(以守护进程形式,独立启动)

#/usr/bin/rsync --daemon

(切记:命令行启动的最后是daemon,而不是deamon,否则回报如下错误:

rsync: --deamon: unknown option

rsync error: syntax or usage error (code 1) at main.c(1231) [client=2.6.8])


启动rsync服务端 (以xinetd超级进程启动)

# service xinetd restart


北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3