C.W.K.
Stream
Lesson 04 of 14 · published

pssh — 전용 Parallel SSH

~12 min · pssh, pscp, fleet

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

셸 loop 으로 부족할 때

pssh(Parallel SSH) 가 적절한 출력 포맷팅, timeout, host 별 상태 보고로 많은 host 에 명령 한 번에 실행하는 전용 도구. 셸 loop 가 텍스트 벽 주는 데 비해 pssh 는 구조화된 출력 — 어느 host 성공, 어느 실패 포함.

동반 도구

pssh 가 형제와 함께 — pscp(병렬 scp), prsync(병렬 rsync), pslurp(많은 host 에서 파일 수집). 같은 인자, 같은 host 파일, 다른 transport 일 뿐.

Code

pssh 기초·bash
# Install
brew install pssh

# Run a command on every host in the file
pssh -h ~/.fleet/all.txt -i 'uptime'
# -h  hosts file
# -i  inline output (instead of per-host log files)

# With a timeout
pssh -h ~/.fleet/all.txt -t 30 -i 'df -h /'

# Concurrency cap
pssh -h ~/.fleet/all.txt -p 4 -i 'brew update'

# Push files in parallel
pscp -h ~/.fleet/all.txt local-script.sh /tmp/

# Run a local script on every host
prsync -h ~/.fleet/all.txt -a script.sh /tmp/
pssh -h ~/.fleet/all.txt -i 'bash /tmp/script.sh'
pssh vs fleet() 함수·plaintext
Feature                | fleet() loop | pssh
-----------------------+--------------+-----------------
Parallel exec          | with & wait  | built-in
Clean per-host output  | yes (serial) | -i flag
Timeouts               | manual       | -t flag
File copy              | scp loop     | pscp
Exit-code summary      | DIY          | built-in

External links

Exercise

pssh 설치 (brew install pssh). pssh -h ~/.fleet/all.txt -i 'uptime' 돌리고 구조화된 출력 관찰. 그다음 pssh -h ~/.fleet/all.txt -i -t 10 'df -h /' — 10 초 넘는 host 가 분명한 timeout 표시 받는 거 메모. Fleet 명령 실행의 production 모양.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.