1.rsync安装
zabbix-server01和zabbix-server02上执行:
[root@@localhost ~]# yum -y install rsync
2.rsync配置
zabbix-server01配置如下:
[root@@localhost ~]# cd /etc && ll|grep rsync
注意pwd文件的权限为600
rsyncd.conf内容
[root@localhost ~]# more /etc/rsyncd.conf
uid=root
gid=root
max connections=100
use chroot=true
log file=/var/log/rsyncd.log
motd file = /etc/rsyncd.motd
transfer logging = true
hosts allow=192.168.153.134(根据自己的ip修改)
[zabbix]
path=/etc/zabbix/
exclude = web
comment = etc zabbix
read only = no
list = yes
auth users = root
secrets file=/etc/rsyncd.pwd
[web1]
path=/etc/httpd/conf/
comment = httpd conf
read only = no
list = yes
auth users = root
secrets file=/etc/rsyncd.pwd
[web2]
path=/etc/httpd/conf.d/
comment = httpd conf.d
read only = no
list = yes
auth users = root
secrets file=/etc/rsyncd.pwd
rsyncd.motd内容
[root@localhost etc]# more rsyncd.motd
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
welcome to use the zabbix rsync services!
2019.12.25
rsyncd.pwd内容
[root@localhost etc]# more rsyncd.pwd
#用户名:密码
root:root
rsyncd.pwd2内容
[root@localhost etc]# more rsyncd.pwd2
#密码
root
相关参数
uid=root #服务器端传输文件时,要发哪个用户和用户组来执行
gid=root #服务器端传输文件时,要发哪个用户和用户组来执行
max connections=100 #客户端最多连接数
use chroot=true #用chroot,在传输文件之前,服务器守护程序在将chroot到文件系统中的目录中,这样做的好处是可能保护系统被安装漏洞侵袭的可能。缺点是需要超级用户权限。另外对符号链接文件,将会排除在外。也就是说,你在rsync服务器上,如果有符号链接,你在备份服务器上运行客户端的同步数据时,只会把符号链接名同步下来,并不会同步符号链接的内容
log file=/var/log/rsyncd.log #rsync服务器的日志
motd file=/etc/rsyncd.motd #定义motd file路径,rsyncd.motd内容是定义服务器信息的,用户登录时会看到这个信息
transfer logging = true #传输文件日志
hosts allow=192.168.153.134 #允许的ip地址
[zabbix] #模块名
path=/etc/zabbix/ #同步的目录
exclude = web #同步目录中去除的目录,即web不同步
comment = etc zabbix #注释,注释内容可自己定义,起提示作用
read only = no #只读选择,如为yes则不让客户端上传文件到服务器上
list = yes #服务器上提供同步数据的目录是否显示
auth users = root #认证用户是root
secrets file=/etc/rsyncd.pwd #密码文件保存路径