運維技能 同步lsync

2021-06-28 09:05:16 字數 3727 閱讀 7519

今天不是很高興,為啥呢?之前,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.secrets

0 directories, 3 files

為了方便,簡單的配置檔案如下所示:

[root@test test]# cat /etc/rsyncd/rsyncd.conf 

pid file = /var/run/rsyncd.pid

uid = root

gid = root

use chroot = yes

read only = no

write only = no

hosts 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.motd

log file = /tmp/rsyncd.log

transfer logging = yes

log format = %t %a %m %f %b

syslog facility = local3

timeout = 300

[data1]

path=/tmp/test

list=yes

comment = some description about this moudle

exclude = test1/ test2/

[root@test test]# vim /etc/rsyncd/rsyncd.conf

[root@test test]# cat /etc/rsyncd/rsyncd.conf

pid file = /var/run/rsyncd.pid

uid = root

gid = root

use chroot = yes

read only = no

write only = no

hosts 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.motd

log file = /tmp/rsyncd.log

transfer logging = yes

log format = %t %a %m %f %b

syslog facility = local3

timeout = 300

[data1]

path=/tmp/test

在a機器上執行如下的命令進行測試:

[root@test test]# rsync [email protected]::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.

---- ****** example for default rsync, but executing moves through on the target.

---- for more examples, see /usr/share/doc/lsyncd*/examples/

-- --

-- sync

settings

sync

[root@test test]#

source 指定的是a端的目錄,b目錄需要去同步的目錄

target   指定的是b端的需要承接同步目錄的目錄。

測試如下

[root@test test]# rsync [email protected]::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]# ll

total 0

-rw-r--r-- 1 root root 0 jan 23 13:28 test

[root@test test]# touch test1

[root@test test]# date

fri jan 23 13:46:38 cst 2015

[root@test test]# rsync [email protected]::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]# date

fri jan 23 13:46:51 cst 2015

[root@test test]# date

fri jan 23 13:47:21 cst 2015

[root@test test]# rsync [email protected]::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]#

同步的工具很多,但是感覺這個非常的易用。

linux運維技能

運維工程師必須掌握的基礎技能有哪些?知乎 這個問題挺好的,回答這個問題也是對自身的審查,看看自己還欠缺哪些。所以我估計得好好思考下,也許下一刻我就會突然驚醒,發現我還是戰 渣 首先限定在linux運維工程師上 回答僅代表我想到,不代表我都會 技能 1.linux基礎 包括對linux整體的理解 使用...

運維必備技能

熟練運用centos ubuntu 與之相關的命令列,系統配置 網路配置 系統優化 核心優化 推薦書目 鳥哥的linux私房菜 第四版 mysql 版本以5.7 8.0 為主 與之相關的資料庫安裝 配置 優化 儲存引擎 索引 資料備份 主從複製 集群方案 掌握常見的集群方案部署及原理,比如mmm m...

linux運維必備技能

作業系統 資料庫 mysql,mysql proxy,mariadb,postgresql db中介軟體 mycat,atlas,cobar amoeba,mysql proxy 相關 lvs,keepalived,haproxy,nginx,heartbeat squid,nginx,varnis...