티스토리 뷰

- bash에서 실행 예시입니다.

- 테스트서버는 로컬/원격 모두 Ubuntu 입니다.

 

rsync는 scp보다 옵션이 많으며, 대역폭이 조절 가능하며, 동일 파일이 있을 시, 변경된 내역만 수정하는 아주 좋은 기능도 내재되어 있습니다!

기본포트는 ssh인 것 같습니다. 원한다면 873 PORT로 전송할수도 있습니다. (services에 기본적으로 정의되어 있다.)

 

아래 테스트를 수행했을 때에는 SSH로 통신했지만, PORT 873을 사용하는 경우를 확인하기 위해 man page를 살펴보았습니다.

 

CONNECTING TO AN RSYNC DAEMON
It is also possible to use rsync without a remote shell as the  transport.   In this  case  you will directly connect to a remote rsync daemon, typically using TCP port 873.  (This obviously requires the daemon to be running on the  remote system,  so refer to the STARTING AN RSYNC DAEMON TO ACCEPT CONNECTIONS section  below for information on that.)

 

파파고 형에게 번역을 부탁해보았습니다..

remote shell 없이 전송이 가능하다는데 이 때, 원격 rsync 데몬을 통해 한다고 되어 있네요.

 

 

기본 포맷

man page

Access via remote shell:
Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST]
Push: rsync [OPTION...] SRC... [USER@]HOST:DEST

 

간단정리

로컬 -> 원격 (Push)

root$ rsync [options] [local-server] [remote-server]

 

원격 -> 로컬 (Pull)

root$ rsync [options] [remote-server] [local-server]

 

이제 테스트를 해보겠습니다.

로컬서버 파일을 원격서버로 보내기

테스트 서버

server1 = 10.20.30.5

server2 = 10.20.30.27

server1$ rsync -avzh test1.txt root@10.20.30.27
sending incremental file list
test1.txt

sent 154 bytes  received 35 bytes  378.00 bytes/sec
total size is 166  speedup is 0.88
server1$

 

원격서버 파일을 로컬서버로 가져오기

server2$ rsync -avzh root@10.20.30.5:/home/rsync-test/*.txt .
receiving incremental file list
test1.txt
test2.txt
test3.txt
test4.txt
test5.txt

sent 122 bytes  received 829 bytes  1.90K bytes/sec
total size is 2.40K  speedup is 2.53
server2$

-a (--archive) 옵션 : archive mode equals -rlptgoD (no -H,-A,-X) / 아카이브 모드

-v (--verbose) 옵션 : increase verbosity / 상세 사항을 출력하여 보여준다.

-z (--compress) 옵션: compress file data during the transfer / 전송 중에 압축 ( 대역폭 감소 효과 )

-h (--human-readable) 옵션 : output numbers in a human-readable format / 사람이 읽을 수 있는 포맷으로 숫자를 출력

 

 - 사실 옵션은 안넣어주고 단순히 rsync [source] [destination] 형태로만 넣어주어도 무방합니다.

 - scp보다 기본적으로 빠릅니다. -z 옵션을 주면 훨씬 더 빠르게 전송이 가능합니다.

 - rsync 파일 전송 시, SSH를 이용시에는 source-port는 하나의 source-port로만 전송됩니다. 따라서, 802.3ad를 사용 시에는 분산방법을 layer2~4까지 하여도 각각 링크에서 5:5로 분산 되지는 않습니다.

 - 당연하게도, rsync를 ssh를 이용할때는 공개키 방식으로 암호화가 진행됩니다. 따라서, 공개키를 인증하였던 source-port를 그대로 사용해야지만 해당 세션을 그대로 유지하여 데이터 전송을 할 수 있습니다.

 - rsync도 기본적으로 패스워드를 물어보지만, 테스트에는 ssh 공개키를 공유했기 때문에 비밀번호 없이 전송하였습니다.

( 패스워드 없이 ssh 접속 방법 : https://devopsnet.tistory.com/31 )

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함