阿里云 linux rsync 数据同步亲自配置成功过,现在已经运行中

1.登录阿里云选择两台服务器配置A服务器

 最好是用内网,例如A:192.168.1.12

                                     B:192.168.1.13

2.查看是否安装 rsync 使用命令:#rpm-qa rsync

3.移除 rsync 使用命令: #yumremove rsync

4.安装 rsync 使用命令:# yum -yinstall rsync

5.配置 reync 使用命令:#vi/etc/rsyncd.conf

uid = nobody 
gid = nobody 
max connections = 4 
read only = true  
hosts allow = * 
transfer logging = true 
log format = %h %o %f %l %b 
log file = /var/log/rsyncd.log 
slp refresh = 300 
log file = /var/log/rsyncd.log 
pid file = /var/run/rsyncd.pid 
lock file = /var/run/rsyncd.lock

[web] 
path =/img/
comment = Mirror to Hk server 
read only = true 
list = false 
auth users = zhangsan

secrets file = /etc/rsyncd.secrets

6.配置rsyncd.secrets的密码使用命令: vi/etc/rsyncd.secrets

zhangsan:123456

7.设置权限为只读

使用命令chmod 600 /etc/rsyncd.secrets

8.命令启动rsync使用命令:rsync –daemon –config=/etc/rsyncd.conf

如果提示 failedto create pid file /var/run/rsyncd.pid: File exists

9.使用命令

rm -rf /var/run/rsyncd.pid

9-1在使用命令

rsync –daemon

10.查看端口号873是否开启

使用命令:firewall-cmd --permanent --query-port=873/tcp

11.添加开放端口号

使用命令:firewall-cmd --permanent --add-port=873/tcp

12.重新加载防火墙

使用命令 firewall-cmd --reload

配置B服务器

1.查看是否安装 rsync 使用命令:#rpm -qarsync

2.移除 rsync 使用命令: #yumremove rsync

3.安装 rsync 使用命令:# yum -yinstall rsync

4.配置同步的密码

 使用命令:vim /root/rsync.passwd

123456【此处只写密码就可以】

5.把密码问价也搞成600

使用命令:chmod 600 /root/rsync.passwd

6.测试网是不是通了

ping 192.168.1.12    ping服务器A的内网ip,看下内网连接是否正常。

telnet 192.168.1.12 873     telnet测试rsync的873端口是否联通。

7.开始同步吧

使用命令:rsync -avzp  - --password-file=/root/rsync.passwd  zhangsan@192.168.1.12::web   /img/

8.做个时时同步

使用命令:vi/tmp/rsyncd.sh

rsync-avzp   --password-file=/root/rsync.passwd   zhangsan@192.168.1.12::web    /img/

9.添加系统任务 3秒执行一次

使用命令crontab -e

*/1 *  *  * *  /bin/sh  /tmp/rsyncd.sh

*/1 * * * * sleep 3; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 6; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 9; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 12; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 15; /bin/sh /tmp/rsyncd.sh    

 */1 * ** * sleep 18; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 21; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 24; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 27; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 30; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 33; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 36; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 39; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 42; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 45; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 48; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 51; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 54; /bin/sh /tmp/rsyncd.sh

 */1 * ** * sleep 57; /bin/sh /tmp/rsyncd.sh

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值