原创文章,转载请注明出处,谢谢。
分类: LINUX
2014-04-02 15:51:37
把5.153.X.X zabbix主监控机当成rsync服务端
rsync apt安装后所有的文件都放在/etc下
/etc/rsyncd.conf /etc/rsyncd.motd /etc/rsyncd.secrets
其中/etc/rsyncd.conf的配置如下:
pid file =/var/run/rsyncd.pid //pid的存放路径
uid = root
gid = root
use chroot = yes
read only = yes
#limit access toprivate LANs
hostsallow=54.72.0.0/16 54.194.0.0/16 //允许主机
hosts deny=*
max connections =5
log file =/var/log/rsync/rsyncd.log //rsync的日志
#This will logevery file transferred - up to 85,000+ per user, per sync
#transfer logging= yes
log format = %t %a%m %f %b
syslog facility =local3
timeout = 300
[netlog] //模块名
path=/data/raidcall/netlog
list = yes
ignore errors
auth users =raidcall_rsync
secrets file =/etc/rsyncd.secrets
comment = ForStatistics Used ONLY
read only = no
/etc/rsyncd.secrets的配置如下:
raidcall_rsync:RCrsync$%^
/etc/rsyncd.motd的配置如下:
welcome tozabbix_server
打开rsync的开关
sudo vi /etc/default/rsync
RSYNC_ENABLE=true
重启rsync
sudo chmod 600 /etc/rsyncd.secrets
sudo /etc/init.d/rsync restart
客户端的配置
设置定时任务
在/etc/cron.d下编辑文件
vi statsync
添加以下内容
*/5 * * * * root/bin/bash /home/app/scripts/rsync_stat.sh //每五分钟运行一次
vi /home/app/scripts/rsync_stat.sh
添加
#!/bin/bash
cd/data/ra/log/sessiond_d
find net* parse*error* -ctime +5 -print -exec rm -rf {} \;
IP=`ip add |grepglobal|awk '{print $2}'|awk -F"/" '{print $1}'`
if [ -d `ls $IP`]
then
mkdir $IP
fi
RSYNC_PASSWORD=RCrsync$%^rsync -avz --update $IP raidcall_rsync@5.153.X.X::netlog
RSYNC_PASSWORD=RCrsync$%^rsync -avz --delete --update net* raidcall_rsync@5.153.X.X::netlog/$IP
crontab的执行日志
/var/log/cron.log