반응형
구성정보
HOST
|
Server#1
|
Server#2
|
IP
|
172.20.0.29
|
172.20.0.30
|
SSH Port
|
7722
|
7722
|
Source
|
/imgfile
|
/imgfile
|
Destnation
|
root@172.20.0.30//imgfile
|
root@172.20.0.29//imgfile
|
Permision
|
root
|
root
|
## 공통
## 어플리케이션 설치
yum install -y lsyncd unison
## Server#1
## root 권한으로 패스워드 없이 접속 가능하도록 셋팅
vi /etc/ssh/sshd_config
PermitRoot no => PermitRoot yes
AllowUsers root@172.20.0.30 root@192.168.100.0/24
ssh-keygen
ssh-copy-id -p 7722 root@172.20.0.30
ssh -p 7722 root@172.20.0.30 ( 접속 테스트 )
## lsyncd 설정
vi /etc/lsyncd
settings {
logfile="/var/log/lsyncd/lsyncd.log",
statusFile="/var/log/lsyncd/lsyncd-status.log"
}
sync {
default.rsyncssh,
source="/imgfile",
host="172.20.0.30",
targetdir="/imgfile",
delay=1,
delete=false,
rsync = {
archive = true,
compress = false,
verbose = true,
owner = true,
group = true,
_extra = {"-a"},
rsh = "/usr/bin/ssh -p 7722 -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no"
}
}
|
## unison 설정 #1 Conf 방식 ( 두대의 서버중 1개에서만 진행 )
// Delete를 위한 설정 ( lsyncd로 양방향 동기화시 delete옵션을 사용하면 서버 1대가 꺼져있을때 추가된 파일들이 의도치 않게 삭제 됨 )
unison default 엔터
vi /root/.unison/default.prf
root = /imgfile
batch = true
times = true
logfile = /var/log/unison.log
|
# crontab 설정 ( unison 실행 )
crontab -e
* * * * * root /usr/sbin/unison
## Unison 설정 #2 Command 방식 ( 두대의 서버중 1개에서만 진행 )
/bin/sbin/unison /imgfile ssh://root@172.20.0.30//imgfile -times -batch
# crontab 설정 ( unison 실행 )
crontab -e
* * * * * root /bin/sbin/unison /imgfile ssh://root@172.20.0.30//imgfile -times -batch
## 서비스 재시작 및 자동시작 등록
systemctl restart lsyncd
systemctl enable lsyncd
## Server#2
## root 권한으로 패스워드 없이 접속 가능하도록 셋팅
vi /etc/ssh/sshd_config
PermitRoot no => PermitRoot yes
AllowUsers root@172.20.0.29 root@192.168.100.0/24
ssh-keygen
ssh-copy-id -p 7722 root@172.20.0.29
ssh -p 7722 root@172.20.0.29 ( 접속 테스트 )
vi /etc/lsyncd
settings {
logfile="/var/log/lsyncd/lsyncd.log",
statusFile="/var/log/lsyncd/lsyncd-status.log"
}
sync {
default.rsyncssh,
source="/imgfile",
host="172.20.0.29",
targetdir="/imgfile",
delay=1,
delete=false,
rsync = {
archive = true,
compress = false,
verbose = true,
owner = true,
group = true,
_extra = {"-a"},
rsh = "/usr/bin/ssh -p 7722 -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no"
}
}
|
## 서비스 재시작 및 자동시작 등록
systemctl restart lsyncd
systemctl enable lsyncd
반응형
'SYSTEM > Software' 카테고리의 다른 글
MariaDB upgrade 10.2 to 10.7 (0) | 2022.11.07 |
---|---|
Rocky Linux 8 / cockpit / system monitoring / management (0) | 2022.08.31 |
linux software raid / mdadm 사용 방법 (0) | 2022.08.31 |
hpsmh - HP Smart Management Home Page on CentOS (0) | 2022.08.31 |
How to install Let's Encrypt SSL / 무료 인증서 (0) | 2022.08.25 |