https://www.youtube.com/watch?v=S0UTSQsmCc4
SOURCE 서버에 다음과 같이 설치합니다.
# ssh-keygen
# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3Nz..........OGyCkT root@ip-172-31-41-225.ap-northeast-2.compute.internal
위의 내용을 복사하여 타겟 서버의 /root/.ssh/authorized_keys 에 추가합니다.
TARGET 서버에 다음과 같이 복사합니다.
# vi /root/.ssh/authorized_keys
아까 소스 서버에서 복사한 키를 하단에 추가로 붙여넣기 합니다.
(기존에 파일이 있다면 이 코드를 추가합니다.)
ssh-rsa AAAAB3Nz..........OGyCkT root@ip-172-31-41-225.ap-northeast-2.compute.internal
# ssh-keyscan -t rsa 255.1.2.3 > /root/.ssh/known_hosts
(255.1.2.3 은 타겟서버아이피)
# yum install epel-release
# yum install lsyncd
# vi /etc/lsyncd.conf
-- sync{default.rsyncssh, source="/var/www/html", host="localhost", targetdir="/tmp/htmlcopy/"}
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd-status.log"
}
sync {
default.rsyncssh,
source="/home/ec2-user", -- 소스 서버 디렉토리
host="255.1.2.3", -- 타겟 서버 아이피 or 도메인
targetdir="/home/ec2-user", -- 타겟 서버 디렉토리
delete=true, -- 삭제시 타겟 서버에 반영하기(동기화 하기)
delay=1, -- 1초
rsync={
archive=true -- 사용자와 퍼미션 동기화 하기
}
}
설정 파일이 이상 있는지 확인하기
# lsyncd /etc/lsyncd.conf
08:05:08 Normal: --- Startup, daemonizing ---
위와 같이 정상 이라면
# systemctl start lsyncd
로그 확인하기
# tail -f /var/log/lsyncd/lsyncd.log
위와 같이 설정한후
소스 서버의 /home/ec2-user 에 파일이나 디렉토리를 생성(삭제)하면
타겟 서버의 /home/ec2-user 에 동기화 됩니다.
댓글 9개
게시글 목록
| 번호 | 제목 |
|---|---|
| 17191 | |
| 17162 | |
| 17160 | |
| 17158 | |
| 17156 | |
| 17155 | |
| 17153 | |
| 17151 | |
| 17145 | |
| 17135 |
Mobile
플러터와 네이티브 어플
2
|
| 17131 | |
| 17125 | |
| 17114 | |
| 17107 |
JavaScript
정규표현식 정리
2
|
| 17099 | |
| 17096 | |
| 17089 | |
| 17088 | |
| 17082 | |
| 17079 | |
| 17078 | |
| 17077 | |
| 17070 | |
| 17068 |
JavaScript
포인문으로 엘레먼트의 "속살" 보기
4
|
| 17067 | |
| 17063 | |
| 17060 | |
| 17048 | |
| 17045 | |
| 17044 |
PHP
알고있으면 좋은 코드
2
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기