首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Rsync完全配置

    系统环境---Rsync完全配置 rsync version 2.6.3 protocol version 28 Slackware 9.2 配置/etc/rsyncd.conf 如果没有创建rsyncd.conf文档,自己需要创建rsyncd.conf文档(下面其实配置相同) [root@linuxas3 root]# vi /etc/rsyncd.conf uid=nobody gid=nobody max connections=4 use chroot=no log file=/var/log/rsyncd.log pid file=/var/run/rsyncd.pid lock file=/var/run/rsyncd.lock #auth users=root secrets file=/etc/rsyncd.secrets [postfix] path=/var/mail comment = backup mail ignore errors read only = yes list = no auth users = postfix [netkiller] path=/home/netkiller/web comment = backup 9812.net ignore errors read only = yes list = no auth users = netkiller [pgsqldb] path=/var/lib/pgsql comment = backup postgresql database ignore errors read only = yes list = no 选择说明 uid = nobody gid = nobody use chroot = no # 不使用chroot max connections = 4 # 最大连接数为4 pid file = /var/run/rsyncd.pid #进程ID文件 lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log # 日志记录文件 secrets file = /etc/rsyncd.pwd # 认证文件名,主要保存用户密码,权限建议设为600,所有者root [module] # 这里是认证的模块名,在client端需要指定 path = /var/mail # 需要做镜像的目录 comment = backup xxxx # 注释 ignore errors # 可以忽略一些无关的IO错误 read only = yes # 只读 list = no # 不允许列文件 auth users = postfix # 认证的用户名,如果没有这行,则表明是匿名 [other] path = /path/to... comment = xxxxx 密码文件A,(被认证的用户,就是本地与要其它地同上时,需要的认证用户) 在server端生成一个密码文件/etc/rsyncd.pwd [root@linuxas3 root]# echo postfix:xxx >>/etc/rsync_passwd [root@linuxas3 root]# chmod 600 /etc/rsync_passwd 密码文件B,(为远程用户的认证:就是其它需要与本地同步时,远程PC在执行同步时所需要的帐号) 在server端生成一个密码文件/etc/rsyncd.secrets [root@linuxas3 root]# echo postfix:xxx >>/etc/rsyncd.secrets

    03

    rsync+inotify实现触发式远程实时同步

    在Linux平台下我们可以利用2.6内核的inotify监控文件系统机制,通过inotify-tools来实现实时同步了。 具体操作如下: 1.安装所需软件 目前各大Linux发行版本都已经具有了rsync与inotify-tools的软件包,推荐通过RPM,yum,apt-get等方式进行安装。 RHEL: [root@server1 ~]# rpm -ivh rsync-* [root@server1 ~]# rpm -ivh inotify-tools-* CentOS: [root@server1 ~]# yum install rsync inotify-tools Ubuntu: [root@server1 ~]# apt-get install rsync inotify-tools 采用源码方式安装的步骤如下: [root@server1 ~]# wget ftp://ftp.samba.org/pub/rsync/rsync-3.0.8.tar.gz [root@server1 ~]# tar xzvf rsync-3.0.8.tar.gz [root@server1 ~]# cd rsync-3.0.8 [root@server1 ~]# ./configure [root@server1 ~]# make [root@server1 ~]# make install [root@server1 ~]# wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz [root@server1 ~]# tar xzvf inotify-tools-3.14.tar.gz [root@server1 ~]# cd inotify-tools-3.14 [root@server1 ~]# ./configure [root@server1 ~]# make [root@server1 ~]# make install 2.配置ssh key信任 建议通过普通用户进行操作,理由是通过root操作本身就危险,免密码登陆的root就更危险了。 在两台服务器上创建rsync用户 [root@server1 ~]# useradd -m rsync [root@server1 ~]# passwd rsync [root@server2 ~]# useradd -m rsync [root@server2 ~]# passwd rsync [root@server1 ~]# su - rsync [rsync@server1 ~]$ ssh-keygen -t rsa 在提示保存私钥(key)和公钥(public key)的位置时,使用默认值; 在提示是否需要私钥密码(passphrase)时,直接敲回车,即不使用私钥密码。 之后,将生成一对密钥,id_rsa(私钥文件)和id_rsa.pub(公钥文件),保存在/home/rsync/.ssh/目录下。 将公钥添加到远程主机的 authorized_keys 文件中 将文件上传到远程主机(假设远程主机IP为192.168.10.4) [rsync@server1 ~]$ scp ~/.ssh/id_rsa.pub rsync@192.168.10.4:/home/rsync/ 使用rsync用户SSH到登陆到远程主机,并将公钥添加到 authorized_keys 文件中 [rsync@server2 ~]$ mkdir .ssh [rsync@server2 ~]$ chmod 700 .ssh [rsync@server2 ~]$ mv ~/id_rsa.pub ~/.ssh/authorized_keys 重启SSH服务 [root@server1 ~]# /etc/init.d/sshd restart [root@server2 ~]# /etc/init.d/sshd restart 3.创建inotify_rsync.sh脚本 [root@server1 ~]# vim inotify_rsync.sh 1    #!/bin/sh 2    SRC=/home/rsync/test 3    DST=rsync@192.168.10.4:/home/rsync/test 4     5    /bin/su - rsync 6    /usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib ${SRC} | while read D E F 7            do 8                    /usr/bin/rsync -ahqzt

    02

    中国开源镜像

    China    Alibaba Cloud Computing    http://mirrors.aliyun.com/centos/ 阿里巴巴         China    Beijing Institute of Technology    http://mirror.bit.edu.cn/centos/ 北京理工大学         China    Beijing Teletron Telecom Engineering    http://mirrors.btte.net/centos/     北京电子电信工程     China    BitComm Ltd.    http://mirrors.pubyun.com/centos/ 公云         China    CDS China    http://mirrors.yun-idc.com/centos/    ftp://mirrors.yun-idc.com/centos/    rsync://mirrors.yun-idc.com/centos/ 首都在线 China    China University of Geosciences    http://mirrors.cug.edu.cn/centos/         中国地质大学 China    Dalian Neusoft University of Information    http://mirrors.neusoft.edu.cn/centos/    ftp://mirrors.neusoft.edu.cn/centos/     东软 China    Grand Cloud    http://mirrors.grandcloud.cn/centos/     盛大云     China    Huazhong University of Science and Technology    http://mirrors.hust.edu.cn/centos/        rsync://mirrors.hust.edu.cn/centos/ 华中科技大学 China    NetEase    http://mirrors.163.com/centos/     网易     China    Northeastern University, Shenyang Liaoni    http://mirror.neu.edu.cn/centos/ 东北大学         China    Qiming College of Huazhong University of Science and Technology    http://mirrors.hustunique.com/centos/        rsync://mirrors.hustunique.com/centos/ 华中科技大学 China    Sohu Inc, Beijing P.R. China    http://mirrors.sohu.com/centos/         搜狐 China    The Linux open source community mirror    http://mirrors.skyshe.cn/centos/        rsync://mirrors.skyshe.cn/centos/ 中国linux开源社团 China    University of Science and Tech of China    http://centos.ustc.edu.cn/centos/ 中国科技大学         China - Hong Kong     Web Services Ltd.    http://mirror.vpshosting.com.hk/pub/linux/centos/    ftp://mirror.vpshosting.com.hk/pub/linux/centos/     Hong Kong    01LINK NETWORK SERVICES LIMITED    http://centos.01link.hk/    ftp://centos.01link.hk/    rsync://centos.01link.hk/centos/ Hong Kong    CommuniLink Internet Limited    http://centos.communilink.net/    ftp://centos.communilink.net/centos/     Hong Kong    i-System Technology Limited    http://centos.uhost.h

    02
    领券