运维技能 - 同步lsync
来源:互联网 发布:unity3d培训多久学完 编辑:程序博客网 时间:2024/06/06 20:15
今天不是很高兴,为啥呢?之前,A在B找工作的时候 一直帮助B,然后有次B写了一段cpp代码,实现,变量都放在了类的内部,很臃肿的一个,然后A说了一句,太烂了,要放在公司肯定挨骂的,然后A和B就关系变差了。A很苦恼。
lsync 是啥呢? 其实可以简单的理解成inotufy+rsync,
机器角色:
A 10.210.71.144 安装了 rsync lsync
B 10.210.71.146 安装了 rsync
A机器做出了改变,会在某个特定的时间内,将变化同步到B,甚至更多的机器,inotify 感知文件的变化,rsync 用来把文件推送过去。
配置方案如下:
B机器上的配置:
安装rsync,目录树如下所示:
[root@test test]# tree /etc/rsyncd/etc/rsyncd├── rsyncd.conf├── rsyncd.motd└── rsyncd.secrets0 directories, 3 files为了方便,简单的配置文件如下所示:
[root@test test]# cat /etc/rsyncd/rsyncd.conf pid file = /var/run/rsyncd.piduid = rootgid = rootuse chroot = yesread only = nowrite only = nohosts allow = 10.209.65.21 10.210.71.146 192.168.0.1/255.255.255.0 198.162.145.1 10.0.1.0/255.255.255.0 10.210.71.145 10.210.71.144 10.210.71.143 hosts deny = *max connections = 5#motd file = /etc/rsyncd/rsyncd.motdlog file = /tmp/rsyncd.logtransfer logging = yeslog format = %t %a %m %f %bsyslog facility = local3timeout = 300[data1]path=/tmp/testlist=yescomment = some description about this moudleexclude = test1/ test2/[root@test test]# vim /etc/rsyncd/rsyncd.conf [root@test test]# cat /etc/rsyncd/rsyncd.conf pid file = /var/run/rsyncd.piduid = rootgid = rootuse chroot = yesread only = nowrite only = nohosts allow = 10.210.71.146 10.210.71.145 10.210.71.144 10.210.71.143 hosts deny = *max connections = 5#motd file = /etc/rsyncd/rsyncd.motdlog file = /tmp/rsyncd.logtransfer logging = yeslog format = %t %a %m %f %bsyslog facility = local3timeout = 300[data1]path=/tmp/test在A机器上执行如下的命令进行测试:
[root@test test]# rsync root@10.210.71.146::data1/drwxr-xr-x 4096 2015/01/23 13:28:53 .-rw-r--r-- 0 2015/01/23 13:28:53 test[root@test test]#
通了,配置成功。
配置A,A上面需要安装inotify 和lsync,比较新版本的系统可以支持yum安装了,省略
A机器上最简单的一个配置:
[root@test test]# cat /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/-- -- -- sync{-- default.rsync, -- source="/tmp/", -- host="10.210.71.146", -- targetdir="/tmp/test/"--}settings { logfile = "/var/log/lsyncd.log", statusFile = "/var/log/lsyncd-status.log", statusInterval = 20}sync{ default.rsync, source = "/tmp/test", target = "10.210.71.146::data1/",}[root@test test]#
source 指定的是A端的目录,B目录需要去同步的目录
target 指定的是B端的需要承接同步目录的目录。
测试如下
[root@test test]# rsync root@10.210.71.146::data1/drwxr-xr-x 4096 2015/01/23 13:28:53 .-rw-r--r-- 0 2015/01/23 13:28:53 test[root@test test]# pwd/tmp/test[root@test test]# lltotal 0-rw-r--r-- 1 root root 0 Jan 23 13:28 test[root@test test]# touch test1[root@test test]# dateFri Jan 23 13:46:38 CST 2015[root@test test]# rsync root@10.210.71.146::data1/drwxr-xr-x 4096 2015/01/23 13:28:53 .-rw-r--r-- 0 2015/01/23 13:28:53 test[root@test test]# dateFri Jan 23 13:46:51 CST 2015[root@test test]# dateFri Jan 23 13:47:21 CST 2015[root@test test]# rsync root@10.210.71.146::data1/drwxr-xr-x 4096 2015/01/23 13:46:37 .-rw-r--r-- 0 2015/01/23 13:28:53 test-rw-r--r-- 0 2015/01/23 13:46:37 test1[root@test test]#
同步的工具很多,但是感觉这个非常的易用。
0 0
- 运维技能 - 同步lsync
- 基于Lsync+sync实现实时文件同步
- [App] Rsync + Lsync 实现实时同步
- 使用lsync和rsync实现主备双机文件同步
- Ubuntu 14.04 LTS 实现双机文件同步lsync和rsync
- 运维技能
- 运维技能
- linux运维技能
- IT运维必备技能、网管必备技能
- 运维工程师必备技能
- 运维工程师技能图
- 运维需要的技能
- linux运维必备技能
- linux运维技能小结
- 初级运维必备技能
- 【数据库】运维必备技能-MySQL篇
- 详解Linux运维工程师必备技能
- 运维人员具备的技能
- char *s 和 char s[] 的区别小结
- bootstrap 2.3版与3.0版的使用区别
- js数组的操作
- stm32_i/o口操作——01
- 全排列
- 运维技能 - 同步lsync
- LayoutInflater作用及使用
- 配置cocosPod环境
- 二维码备忘录
- objective-c 关键字和概念
- 测试代码的报错java.lang.Exception: No tests found matching Method ***
- android开发中apk安装包常用工具
- C - 实在找不到中文题目了
- STM32F103学习笔记(六) 独立看门狗and窗口看门狗