Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了sersync+rsync实现数据同步大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

实验拓扑 实验步骤 (1)配置rsync配置文件 编辑配置文件vim /etc/rsyncd.conf,默认是没有这个配置文件的,然后添加如下内容: Rsyncserver gid =rsync #设置运行权限为rsync用户 #默认是true,修改为no,增加对目录的文件软连接的备份 timeout =600 #设置超时的时间 ignoreerrors list =false #不显示rsync
  • 实验拓扑

    sersync+rsync实现数据同步

  • 实验步骤
    (1)配置rsync配置文件
    编辑配置文件vim /etc/rsyncd.conf,认是没有这个配置文件的,然后添加如下内容

    Rsyncserver

    gid =rsync #设置运行权限为rsync用户
    #认是true,修改为no,增加对目录的文件软连接的备份
    timeout =600 #设置超时的时间
    ignoreerrors
    list =false #不显示rsync服务端资源列表
    #进行数据同步的客户端IP地址,可以多个,用;隔开
    authusers = rsync_BACkup
    secretsfile = /etc/rsync.passwd
    [BACkup] #自定义备份 名称
    (2)创建使用的账号和配置密码,具体操作如下:
    [[email protected]]# useradd rsync -s /sbin/nologin -M #和配置文件用户一致
    [[email protected]]# id rsync
    uid=502(rsynC)gid=502(rsynC) 组=502(rsynC)
    [[email protected]]# vim /etc/rsync.passwd #和上面的配置文件名称一致
    rsync_BACkup:hjm ##用来同步数据的用户,格式为用户名:密码br/>[[email protected]]#
    (3)创建共享目录(/backup),具体操作如下:
    [[email protected]]# mkdir /backup #创建目录
    #对文件设置所属者
    [[email protected]]# ll -d /backup/ #查看目录的属性
    br/>[[email protected]]#
    (4)启动服务,如果出现failed to create pid file/var/run/rsyncd.pid: File exists这样的错误的话,可以用rm-f /var/run/rsyncd.pid命令把它删掉,在重新运行此命令。
    [[email protected]]# netstat -tunlp | grep rsync
    tcp 0 0 0.0.0.0:873 0.0.0.0: LISTEN 7076/rsync
    tcp 0 0 :::873 :::
    LISTEN 7076/rsync

  • Sersync服务端配置
    (1)配置交换式密码,具体操作如下
    [[email protected]]# vim /etc/rsync.password #设置交换式密码
    br/>hjm
    [[email protected]]#
    (2)测试Sersync服务端,测试sersync是否可以进行pull或push操作,首先,我们先在Resync服务端的backup目录下新建几个文件夹,然后在sersync端看是否可以进行push或pull,如果可以的话,才能进sersync+resync的实战,具体操作如下:
    a) Resync服务端
    [[email protected]~]# cd /backup/ #进入目录
    [[email protected]]# touch {1..4}.txt
    [[email protected]]# ls
    1.txt 2.txt 3.txt 4.txt
    br/>[[email protected]]#
    b) Sersync服务端
    [[email protected]]# rsync -azv [email protected]::backup/hjm/ --password-file=/etc/rsync.password
    receivingincremental file list
    ./
    1.txt
    2.txt
    3.txt
    4.txt
    sent 143bytes received 294 bytes 874.00 bytes/sec
    totalsize is 0 speedup is 0.00
    [[email protected]]# ls
    1.txt 2.txt 3.txt 4.txt 5.txt hahha
    br/>[[email protected]]#
    (3)安装sersync软件
    Sersync软件包,在网上都能下载的到,我们这里事先已经下载好sersync软件包,然后对其进行解压,并把它们移动合适的位置。具体操作
    如下:
    [[email protected]]# tar xvf sersync_64bit_binary_stable_final.tar.gz -C /usr/local/
    GNU-Linux-x86/sersync2
    [[email protected]]# ll /usr/local/GNU-Linux-x86/
    -rwxr-xr-x.1 root root 2214 10月 26 2011 confxml.xml
    br/>[[email protected]]#
    (4)编辑sersync配置文件
    编辑配置文件,vim /usr/local/GNU-Linux-x86/confxml.xml ,然后修改如下几个地方:

    sersync+rsync实现数据同步


    (5)启动sersync服务
    set thesystem param
    execute:echo 50000000 >/proc/sys/fs/inotify/max_user_watches
    parse thecommand param
    daemonthread num: 10
    host ip :localhost host port: 8008
    daemonstart,sersyncrun behind the console
    user is rsync_backup
    configxml parse success
    pleaseaccording your cpu ,use-n param to adjust the cpu rate
    rsync thedirectory recursivly to the remote servers once
    -file=/etc/rsync.password>/dev/null 2>&1 run the sersync:
    [[email protected]]#
  • 实验结果
    (1)Rsync服务端配置
    [[email protected]]# ls
    br/>[[email protected]]#
    [[email protected]]# ls
    br/>[[email protected]]#
    QQ在线Zabbix答疑群177428068
  • 上一篇:为什么Nginx总体性能要比Apache高?

    大佬总结

    以上是大佬教程为你收集整理的sersync+rsync实现数据同步全部内容,希望文章能够帮你解决sersync+rsync实现数据同步所遇到的程序开发问题。

    如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

    本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
    如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。