zoukankan      html  css  js  c++  java
  • centos8环境安装配置rsync

    一,查看本地centos的版本:

    [root@localhost lib]# cat /etc/redhat-release 
    CentOS Linux release 8.1.1911 (Core) 

    说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

             对应的源码可以访问这里获取: https://github.com/liuhongdi/

     说明:作者:刘宏缔 邮箱: 371125307@qq.com

    二,查看是否已安装rsync程序包?

    [root@localhost source]# rpm -qa | grep rsync
    rsync-3.1.3-6.el8.x86_64

    三,如果没安装,用下面的命令安装:

    [root@localhost yum.repos.d]# dnf install rsync

    四,创建目录和密码文件:

    [root@localhost dest]# mkdir /data/rsync
    [root@localhost dest]# cd /data/rsync/
    [root@localhost rsync]# mkdir run
    [root@localhost rsync]# chmod 777 run
    [root@localhost rsync]# mkdir log
    [root@localhost rsync]# chmod 777 log
    [root@localhost rsync]# mkdir conf
    [root@localhost rsync]# chmod 777 conf
    [root@localhost rsync]# cd conf/
    [root@localhost conf]# vi server.pass

    说明:server.pass的内容:pusher:123456

             pusher是访问rsync服务时的用户名

             123456是pusher对应的密码

    五,配置rsync服务的配置文件

    [root@localhost yum.repos.d]# vi /etc/rsyncd.conf

    编辑内容为:

    uid = root
    gid = root
    port = 873
    #use chroot = no            #是否可以改变同步的根目录
    #read only = yes            #只读或者可以上传文件
    #hosts allow=192.168.1.220
    #hosts deny=*
    # transfer logging = yes
    #motd file = /data/rsync/conf/motd
    # log format = %t %a %m %f %b
    # syslog facility = local3
    # timeout = 300
    max connections = 200
    pid file = /data/rsync/run/rsyncd.pid
    lock file = /data/rsync/run/rsync.lock
    log file = /data/rsync/log/rsyncd.log
    
    [wwwroot]
    path         = /data/nfs/dest
    comment      = lg69_rsync
    #read only    = yes
    read only    = no
    auth users   = pusher
    secrets file = /data/rsync/conf/server.pass
    hosts allow  = 127.0.0.1,192.168.1.0/24,59.151.1.0/24,211.151.133.0/24,58.221.35.0/24,125.76.249.0/24
    # list=yes
    # ignore errors
    # exclude = test/ test.php

    六,生成rsync客户端密码文件及配置各密码文件权限

    1,生成rsync客户端密码文件

    [root@localhost conf]# vi client.pass

    说明:内容与服务端中pusher的密码相同,内容设置为:123456

    2,密码文件的权限一律切换为 600

    [root@localhost conf]# ll
    总用量 8
    -rw-r--r-- 1 root root 7 2月  24 16:51 client.pass
    -rw-r--r-- 1 root root 7 2月  24 16:47 server.pass
    [root@localhost conf]# chmod 600 *
    [root@localhost conf]# ll
    总用量 8
    -rw------- 1 root root 7 2月  24 16:51 client.pass
    -rw------- 1 root root 7 2月  24 16:47 server.pass

    七,查看rsync的版本

    [root@localhost conf]# rsync --version
    rsync  version 3.1.3  protocol version 31

    八,用systemctl管理rsync服务

    1,创建一个配置文件

    [root@localhost conf]# vi /etc/sysconfig/rsyncd

    说明:内容为:

    OPTIONS=""

    2,创建service文件

    [root@localhost conf]# vi /lib/systemd/system/rsyncd.service

    说明:service文件内容为:

    [Unit]
    Description=fast remote file copy program daemon
    ConditionPathExists=/etc/rsyncd.conf
    
    [Service]
    EnvironmentFile=/etc/sysconfig/rsyncd
    ExecStart=/usr/bin/rsync --daemon --no-detach "$OPTIONS"
    
    [Install]
    WantedBy=multi-user.target

    3,测试启动:

    [root@localhost conf]# systemctl start rsyncd

    九,启动rsync服务后,客户端测试同步一个目录到本地

    [root@localhost conf]# rsync -vzrtopg --progress --password-file=/data/rsync/conf/client.pass pusher@127.0.0.1::wwwroot /data/nfs/test
  • 相关阅读:
    20165309 Linux安装及学习
    20165309 技能学习经验与C语言
    20165309 我期望的师生关系
    20165317-我期望的师生关系
    20165308 学习基础和C语言基础调查
    20165308 我期望的师生关系
    20165320 结对编程学习第一周
    20165320 第七周学习总结
    20165320 第六周学习总结
    20165320 实验一 java环境的熟悉
  • 原文地址:https://www.cnblogs.com/architectforest/p/12360875.html
Copyright © 2011-2022 走看看