linux_6.5_install_rsync-3.0.6

安装说明:
rsync_server
release: Red Hat Enterprise Linux Server release 6.5 (Santiago)
inet addr:192.168.16.66

rsync_client
release: Red Hat Enterprise Linux Server release 6.5 (Santiago)
inet addr:192.168.16.106

[root@rsync_server etc]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)

[root@rsync_client ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)

安装前准备:
[root@rsync_server etc]# service iptables stop
[root@rsync_server etc]# setenforce 0
[root@rsync_server etc]# chkconfig iptables off
[root@rsync_server etc]# sed -i 's@SELINUX=enforce@SELINUX=disabled@g /etc/sysconfig/selinux

[root@rsync_client etc]# service iptables stop
[root@rsync_client etc]# setenforce 0
[root@rsync_client etc]# chkconfig iptables off
[root@rsync_client etc]# sed -i 's@SELINUX=enforce@SELINUX=disabled@g /etc/sysconfig/selinux

安装rsync:
[root@linux_64 ~]# mount /dev/cdrom /mnt/cdrom
[root@linux_64 ~]# yum install rsync

[root@localhost yum.repos.d]# mount /dev/cdrom /mnt/cdrom
[root@localhost yum.repos.d]# yum install rsync

配置rsync_server
[root@rsync_server etc]# cat >> rsyncd.conf<<EOF
##rsyncd.conf start##
uid = rsync //指定用户,需要创建
gid = rsync
use chroot = no //出现BUG后定向的问题
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[lbw]
path = /data/
ignore errors
read only = false
list = false
hosts allow = 192.168.16.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup //虚拟用户,不是系统用户
secrets file = /etc/rsync.password //密码文件,可以将密码放在此文件中,方便定时任务。
#rsync_config_______________end
EOF

[root@rsync_server etc]# echo “rsync_backup:system”>/etc/rsync.password
[root@rsync_server etc]# cat /etc/rsync.password
rsync_backup:system
[root@rsync_server etc]# chmod 600 /etc/rsync.password
[root@rsync_server etc]# ll /etc/rsync.password
-rw------- 1 root root 20 7月 5 22:57 /etc/rsync.password

[root@rsync_server etc]# useradd rsync -s /sbin/nologin

[root@rsync_server etc]# mkdir /data
[root@rsync_server etc]# ls -ld /data
drwxr-xr-x 2 root root 4096 7月 5 23:08 /data
[root@rsync_server etc]# chown -R rsync.rsync /data
[root@rsync_server etc]# ls -ld /data
drwxr-xr-x 2 rsync rsync 4096 7月 5 23:08 /data

配置rsync_client:
[root@rsync_client ~]# echo “system”>/etc/rsync.password //客户端只放密码
[root@rsync_client ~]# ll /etc/rsync.password
-rw-r–r--. 1 root root 7 Jul 5 22:59 /etc/rsync.password
[root@rsync_client ~]# chmod 600 /etc/rsync.password
[root@rsync_client ~]# ll /etc/rsync.password
-rw-------. 1 root root 7 Jul 5 22:59 /etc/rsync.password

启动rsync_server:

[root@rsync_server etc]# ps -ef | grep rsync
root 2156 1790 0 21:58 pts/1 00:00:00 grep rsync
[root@rsync_server etc]# whereis rsync
rsync: /usr/bin/rsync /etc/rsync.password /usr/share/man/man1/rsync.1.gz
[root@rsync_server etc]# /usr/bin/rsync --daemon
[root@rsync_server etc]# ps -ef | grep rsync
root 2180 1 0 21:58 ? 00:00:00 /usr/bin/rsync --daemon
root 2182 1790 0 21:58 pts/1 00:00:00 grep rsync
[root@rsync_server etc]# lsof -i :873
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsync 2180 root 4u IPv4 12247 0t0 TCP *:rsync (LISTEN)
rsync 2180 root 5u IPv6 12248 0t0 TCP *:rsync (LISTEN)

测试拉取数据:
[root@rsync_server data]# touch {1…5}.txt
[root@rsync_server data]# ls

  1. txt 2.txt 3.txt 4.txt 5.txt

[root@rsync_client ~]# rsync -avz rsync_backup@192.168.16.66::lbw /data/
Password:
receiving incremental file list
created directory /data
./
1.txt
2.txt
3.txt
4.txt
5.txt

sent 159 bytes received 348 bytes 144.86 bytes/sec
total size is 0 speedup is 0.00
[root@rsync_client ~]# ls /data
1.txt 2.txt 3.txt 4.txt 5.txt
[root@rsync_client ~]# rm -rf /data/*
[root@rsync_client ~]# ls /data
[root@rsync_client ~]# rsync -avz rsync_backup@192.168.16.66::lbw /data/ --password-file=/etc/rsync.password
receiving incremental file list
./
1.txt
2.txt
3.txt
4.txt
5.txt

sent 159 bytes received 348 bytes 1014.00 bytes/sec
total size is 0 speedup is 0.00
[root@rsync_client ~]# ls /data
1.txt 2.txt 3.txt 4.txt 5.txt

测试推送数据:
[root@rsync_client ~]# cd /data
[root@rsync_client data]# touch {a…f}.log
[root@rsync_client data]# ls
1.txt 2.txt 3.txt 4.txt 5.txt a.log b.log c.log d.log e.log f.log
[root@rsync_client data]# rsync -avz /data/ rsync_backup@192.168.16.66::lbw --password-file=/etc/rsync.password
sending incremental file list
./
a.log
b.log
c.log
d.log
e.log
f.log

sent 379 bytes received 125 bytes 1008.00 bytes/sec
total size is 0 speedup is 0.00

[root@rsync_server data]# ls
1.txt 2.txt 3.txt 4.txt 5.txt a.log b.log c.log d.log e.log f.log

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值