zoukankan      html  css  js  c++  java
  • inux下配置rsyncd服务

    创建配置文件

    touch /etc/rsyncd/rsyncd.conf          #主配置文件
    touch /etc/rsyncd/rsyncd.secrets       #用户名密码文件,一组用户一行,用户名和密码使用 : 分割
    touch /etc/rsyncd/rsyncd.motd          #非必须,连接上rsyncd显示的欢迎信息,此文件可不创建

    需要注意的是,rsyncd服务的密码文件权限必须是600

    chmod 0600 /etc/rsyncd/rsyncd.secrets

    编辑主配置文件rsyncd.conf

    ######################################################################################################
    #                      ******进程相关全局配置******
    ######################################################################################################
    # = 后面的值可根据自己的实际情况更改
    #    pid file 守护进程pid文件
    #    port 守护进程监听端口,可更改,由xinetd允许rsyncd时忽略此参数
    #    address 守护进程监听ip,由xinetd允许rsyncd时忽略此参数
    pid file = /usr/local/var/run/rsyncd.pid
    port = 873
    address = 192.168.1.2
    #rsyncd 守护进程运行系统用户全局配置,也可在具体的块中独立配置,
    uid = root
    gid = root
    #允许 chroot,提升安全性,客户端连接模块,首先chroot到模块path参数指定的目录下
    #chroot为yes时必须使用root权限,且不能备份path路径外的链接文件
    use chroot = yes
    #只读
    read only = no
    #只写
    write only = no
    #允许访问rsyncd服务的ip,ip端或者单独ip之间使用空格隔开
    hosts allow = 192.168.0.1/255.255.255.0 198.162.145.1 10.0.1.0/255.255.255.0
    #不允许访问rsyncd服务的ip,*是全部(不涵盖在hosts allow中声明的ip,注意和hosts allow的先后顺序)
    hosts deny = *
    #客户端最大连接数
    max connections = 5
    #欢迎文件路径,可选的
    #motd file = /etc/rsyncd/rsyncd.motd
    #日志相关
    #    log file 指定rsync发送消息日志文件,而不是发送给syslog,如果不填这个参数默认发送给syslog
    #    transfer logging 是否记录传输文件日志
    #    log format 日志文件格式,格式参数请google
    #    syslog facility rsync发送消息给syslog时的消息级别,
    #    timeout连接超时时间
    log file = /usr/local/logs/rsyncd.log
    transfer logging = yes
    log format = %t %a %m %f %b
    syslog facility = local3
    timeout = 300
    
    ######################################################################################################
    #                      ******模块配置(多个)******
    ######################################################################################################
    #模块 模块名称必须使用[]环绕,比如要访问data1,则地址应该是

    ::data1 [data1] #模块根目录,必须指定 path=/home/username #是否允许列出模块里的内容 list=yes #忽略错误 #ignore errors #模块验证用户名称,可使用空格或者逗号隔开多个用户名 auth users = data1user #模块验证密码文件 可放在全局配置里 secrets file=/etc/rsyncd/rsyncd.secrets #注释 comment = some description about this moudle #排除目录,多个之间使用空格隔开 exclude = test1/ test2/

    启动rsyncd服务

    #默认配置文件是/etc/rsyncd.conf,所以需要显式的指定配置文件
    /usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf
    
    #假设使用终端操作,保证终端断开进程仍然执行
    nohup /usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf

    syncd 服务负载比较高的时候,设定rsyncd为独立的守护进程

    开机启动

    将以下命令添加到/etc/rc.local文件

    /usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf

    确保打开防火墙

    iptables -A INPUT -p tcp -m state --state NEW  -m tcp --dport 873 -j ACCEPT

    使用xinetd 运行rsync

    安装 xinetd

    #Ubuntu
    apt-get install xinetd
    #Red-hat(CentOS)
    yum intall xinetd

    修改xinetd配置文件

    vi /etc/xinetd.d/rsync
    修改配置文件
    server_args     = --daemon --config=/etc/rsyncd/rsyncd.conf

    启动

    chkconfig rsync on
    service xinetd restart
  • 相关阅读:
    北京Uber优步司机奖励政策(3月3日)
    ubuntu安装phpstorm
    ubuntu安装typora
    PHP定时任务Crontab结合CLI模式详解
    mysql创建用户,并授予权限
    ubuntu下使用crontab定时器
    Ubuntu 查看当前目录使用的总空间大小
    ubuntu安装ruby,安装sass,安装compass
    open_basedir restriction in effect,解决php引入文件权限问题 lnmp
    canvas 画线
  • 原文地址:https://www.cnblogs.com/nb-blog/p/6340022.html
Copyright © 2011-2022 走看看