部署rsync+inotify和gitlab
1.部署rsync+inotify同步/runtime目录至目标服务器的/liucong/下。即把/runtime目录同步至目标服务器的/liucong/下。
配置时钟同步,将源服务器当作时钟服务器
源服务器:
[root@10 ~]# vim /etc/chrony.conf
25 # Serve time even if not synchronized to a time source.
26 local stratum 10
[root@10 ~]# systemctl restart chronyd
[root@10 ~]# systemctl enable chronyd
[root@10 ~]# hwclock -w
[root@10 ~]#
目标服务器:
[root@20 ~]# vim /etc/chrony.conf
server 192.168.89.10 iburst
[root@20 ~]# systemctl restart chronyd
[root@20 ~]# systemctl restart chronyd
[root@20 ~]# systemctl enable chronyd
[root@20 ~]# hwclock -w
[root@20 ~]# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* time.cloudflare.com 3 6 17 11 +9191ns[-2551ms] +/- 100ms
^- tock.ntp.infomaniak.ch 1 6 17 10 -30ms[ -30ms] +/- 151ms
^? ntp.wdc1.us.leaseweb.net 0 7 0 - +0ns[ +0ns] +/- 0ns
^- ntp8.flashdance.cx 2 7 301 2 +7672us[+7672us] +/- 186ms
^? 192.168.89.10 0 7 0 - +0ns[ +0ns] +/- 0ns
//关闭防火墙与SELINUX
[root@20 ~]# systemctl stop firewalld
[root@20 ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@20 ~]# setenforce 0
[root@20 ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/sysconfig/selinux
[root@20 ~]# yum -y install rsync //安装rsync服务端软件
[root@20 ~]# mkdir /liucong/
[root@20 ~]# vim /etc/rsyncd.conf //设置rsyncd.conf配置文件
log file = /var/log/rsyncd.log # 日志文件位置,启动rsync后自动产生这个文件,无需提前创建
pidfile = /var/run/rsyncd.pid # pid文件的存放位置
lock file = /var/run/rsync.lock # 支持max connections参数的锁文件
secrets file = /etc/rsync.pass # 用户认证配置文件,里面保存用户名称和密码,必须手动创建这个文件
[etc_from_client] # 自定义同步名称
path = /liucong/ # rsync服务端数据存放路径,客户端的数据将同步至此目录
comment = sync etc from client
uid = root # 设置rsync运行权限为root
gid = root # 设置rsync运行权限为root
port = 873 # 默认端口
ignore errors # 表示出现错误忽略错误
use chroot = no # 默认为true,修改为no,增加对目录文件软连接的备份
read only = no # 设置rsync服务端为读写权限
list = no # 不显示rsync服务端资源列表
max connections = 200 # 最大连接数
tim