Up
Down
1
collect
share
出差君的笔记
不定期更新的小笔记,大多数都是懒得去翻Google而做的合集,以及一些我碰见过的坑。(不定期更新)
一般都是更新一些干货,如果有问题也请在评论区指出。由于是笔记,而我也没强迫症,所以排版都是比较随意的。
关于Lsyncd:
这是一个有强迫症的软件x
主要用于目录同步
很类似于rsyncd(其实也是基于这个的带监控版本)
之前有跨服务器目录同步的要求,然后我之前匮乏的rsyncd知识使我没想到咋弄实时同步,于是在Google的搜索下找到了这个软件,但是配置文件也很强迫症,当时写错了N次才弄完。
安装也很简单:
centos:yum install -y lsyncd
Ubuntu/debian: apt install lsyncd
直接上实例:
/etc/lsyncd.conf
----
-- User configuration file for lsyncd.
--
-- Simple example for default rsync, but executing moves through on the target.
--
-- For more examples, see /usr/share/doc/lsyncd*/examples/
--
settings {
logfile = "/var/log/lsyncd.log",--日志位置
statusFile = "/var/log/lsyncd.status", --systemctl.status
pidfile = "/var/run/lsyncd.pid", --pid文件
statusInterval = 1,
nodaemon = false, --true为非后台运行 反之为后台运行
maxProcesses = 1, --最大进程(默认1,请勿修改)
maxDelays = 1, --不知道啥,反正别动就对了
}
sync {
default.rsyncssh,
source = "/source_data/", --源目录
delete = false, --false为增量保存,意思是不会对目标目录进行删除操作,true为对目标目录进行删除并完全同步源目录和目标目录
host = "user@ip", --用户@目标主机ip
targetdir = "/target_dir/", --目标主机目录
rsync = {
binary = "/usr/bin/rsync", --rsync安装目录
archive = false, -- false为不压缩,反之为压缩
compress = false, --忘了
owner = true, --文件所有者同步
perms = true, --文件权限同步
whole_file = false
},
ssh = {
port = 233 --ssh端口
}
}
弄完配置文件之后加入系统自启:
systemctl enable lsyncd
启动服务:
systemctl start lsyncd
而ubuntu下的lsyncd启动方式不同一点
shell:#lsyncd /etc/lsyncd.conf 一次性启动
ubuntu的配置文件是/etc/lsyncd/lsyncd.conf.lua
且ubuntu要手动创建/etc/lsyncd文件夹、log文件、status文件,centos不用
DeclarationAll articles on this site, unless otherwise indicated or marked, are original publications of this site. Any individual or organization is prohibited from copying, stealing, collecting, or publishing the content of this site to any website, book, or other media platform without the consent of the author. If the content of this site infringes upon the legitimate rights and interests of the original author, please contact us for processing: DMCA Report













This guy seems to be very shy (bushi