服务端(接收日志端)
yum -y install xinetd rsync
vim /etc/xinetd.d/rsync
service rsync
{
disable = yes
flags = IPv4
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
service xinetd start
chkconfig xinetd on
uid = root
gid = root
port = 873
fake super = yes
use chroot = no
max connections = 2000
timeout = 600
ignore errors
read only = false
list = false
#auth users = rsync_backup
#secrets file = /etc/rsync.password
log file = /data/logs/rsyncd.log
[sgame_logs]
comment = welcome to sgame logs
path = /data/rsync/myproj
/usr/bin/rsync --daemon
推送端(lsync同步客户端)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum install lsyncd rsync
vim /etc/sysconfig/lsyncd
settings {
--pidfile = "/var/run/lsyncd.pid",
--nodaemon = false,
inotifyMode = "CloseWrite",
maxProcesses = 8,
statusFile = "/tmp/lsyncd.status",
statusInterval = 1,
logfile = "/var/log/lsyncd/lsyncd.log"
}
sync {
default.rsync,
source = "/data/myproj_sgame_logs",
target = "10.1.18.13::sgame_logs",
delete="running",
-- excludeFrom = "/etc/rsync_exclude.lst",
delay = 5,
init = false,
rsync = {
binary = "/usr/bin/rsync",
perms = true,
acls = true,
xattrs = true,
links = true,
quiet = true,
archive = true,
compress = true,
verbose = true,
--password_file = "/etc/rsync.pwd",
_extra = {"--bwlimit=2000"}
}
}
rsync -avz --delete /data/myproj_sgame_logs/ 10.1.18.13::sgame_logs
- sysctl优化 修改默认监控的文件数(腾讯云默认是20000)
fs.inotify.max_user_watches = 2001192
lsyncd -pidfile /var/run/lsyncd.pid /etc/sysconfig/lsyncd
ps aux|grep lsyncd
/etc/init.d/lsyncd status
- 放行防火墙端口 873(rsync默认端口), 在客户端源目录增加修改文件,测试同步效果