码迷,mamicode.com
首页 > 其他好文 > 详细

配置rsyncd.conf

时间:2018-09-21 11:39:04      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:创建用户   speed   start   ignore   认证   led   echo $?   inux   address   

1.部署rsync=inotify同步/etc目标服务器的/wzy/下。
实验环境:

主机名称 操作系统 角色 ip地址
@bogon RHEL 7 源服务器 192.168.168.37
@client RHEL 7 目标服务器 192.168.43.199

*关闭防火墙和selinux

[root@client ~]# systemctl start firewalld.service
[root@client ~]# systemctl enable firewalld.service
[root@client ~]# setenforce 0
[root@bogon ~]# systemctl start firewalld.service
[root@bogon ~]# systemctl enable firewalld.service
[root@bogon ~]# setenforce 0

#目标服务端操作:
1.安装rsync服务端软件:

[root@bogon ~]# yum -y install rsync

2配置rsyncd.conf配置文件

[root@bogon ~]# cat >> /etc/rsyncd.conf << EOF

log file = /var/log/rsyncd.log
pidfile = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
secrets file = /etc/users
[wuzhiyong]
path = /tmp/wzy
comment = sync etc from server
uid = root
gid = root
port = 873
ignore errors
use chroot = no
read only = no
list = no
max connections = 200
timeout = 600
auth users = wzy
EOF

3创建用户认证文件,并设置文件权限:

[root@bogon ~]# echo ‘wzy:123456’ > /etc/users
[root@bogon ~]# cat /etc/users
wzy:123456
[root@bogon ~]# chmod 600 /etc/users
[root@bogon ~]# ll /etc/users
-rw-------. 1 root root 11 Sep 18 23:57 /etc/users

4.启动rsync服务并设置开机自动启动:

[root@bogon ~]# systemctl start rsyncd
[root@bogon ~]# systemctl enable rsyncd
[root@bogon ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :22 :
LISTEN 0 100 127.0.0.1:25 :
LISTEN 0 5 :873 :
LISTEN 0 128 :::22 :::
LISTEN 0 100 ::1:25 :::
LISTEN 0 5 :::873 :::

*源服务器上进行的操作:
1.安装rsync,inotify-tools。只需要安装不需要启动和配置

[root@bogont ~]# yum -y install rsync inotify-tools

2配置yum源

[root@bogon ~]# cd /etc/yum.repos.d/
[root@bogon yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
--2018-09-18 10:41:58--  http://mirrors.163.com/.help/CentOS7-Base-163.repo
正在解析主机 mirrors.163.com (mirrors.163.com)... 59.111.0.251
正在连接 mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1572 (1.5K) [application/octet-stream]
正在保存至: “CentOS7-Base-163.repo”

100%[================================>] 1,572       --.-K/s 用时 0s      

2018-09-18 10:41:59 (52.8 MB/s) - 已保存 “CentOS7-Base-163.repo” [1572/1572])

[root@bogon yum.repos.d]# echo $?
0
[root@bogon yum.repos.d]# ls
CentOS7-Base-163.repo  CentOS-Base.repo  epel.repo  redhat.repo
[root@bogon yum.repos.d]#  sed -i ‘s/\$releaserver/7/g‘ /etc/yum.repos.d/CentOS7-Base-163.repo 
[root@bogon yum.repos.d]#  sed -i ‘s/^enabled=.*/enabled=1/g‘ /etc/yum.repos.d/CentOS7-Base-163.repo 
[root@bogon yum.repos.d]# yum -y install epel-release

3创建认证密码文件,并设置其权限为600:

[root@client ~]# cat /etc/rsync.pass
123456
root@client ~]# chmod 600 /etc/rsync.pass
[root@client ~]#

4.在服务端创建测试目录:

[root@client yum.repos.d]# mkdir /wzy
[ro
ot@client tmp]# mkdir /wzy/haha

*进行数据同步:

[root@client wzy]# rsync -avH --port 873 --progress --delete /wzy wzy@192.168.43.199::wuzhiyong --password-file=/etc/rsync.pass
sending incremental file list
wzy/
wzy/haha/

sent 81 bytes received 27 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00

*在目标服务器验证查看:

[root@bogon wzy]# cd /tmp/wzy
[root@bogon wzy]# ls
ha
ha wzy
[root@bogon wzy]#

配置rsyncd.conf

标签:创建用户   speed   start   ignore   认证   led   echo $?   inux   address   

原文地址:http://blog.51cto.com/13945839/2177951

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!