๋ฐ์ํ
๋ฆฌ๋ ์ค์์ ์ฌ๋ฌ ์๋ฒ๋ค ๋์์ ์์ ํ ๋ ์ ์ฉํ 2๊ฐ์ง ๋ฐฉ๋ฒ์ ๋๋ค. (parallel-ssh๋ฅผ ์ถ์ฒ)
โพ parallel-ssh ์ค์น ๋ฐ ์ฌ์ฉ
1. ๋ค์ด ๋ฐ ์ค์น
pssh-2.3.1.tar.gz ๋ค์ด (https://code.google.com/archive/p/parallel-ssh/downloads/)
tar xvzf pssh-2.3.1.tar.gz
cd pssh-2.3.1
python setup.py install
2. ์์
host ํ์ผ ์์ฑ
vi allnodes
------------------------------
cdpwork01
cdpwork02
cdpwork03
------------------------------
3. keygen ์์ฑ ๋ฐ ๋ฐฐํฌ
ssh-keygen
chmod 700 .ssh
cd .ssh
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
cd
rsync -av .ssh cdpwork01:/root
rsync -av .ssh cdpwork02:/root
rsync -av .ssh cdpwork03:/root
4. pssh ๋ช
๋ น์ด ์ฌ์ฉ๋ฒ (pssh, pscp, prsync ์ฌ์ฉ ๊ฐ๋ฅ)
pssh -i -h ./allnodes 'df -h'
-i : ๊ฒฐ๊ณผ ๋ฉ์์ง ์ถ๋ ฅ (์์
๋ง ํ ๊ฑฐ๋ฉด ์ ์ธ)
-h : host ํ์ผ ์์น
โพ ssh remote shell ์ฌ์ฉ
vi ssh.sh
------------------------------
#!/bin/bash
hosts=(
cdpwork01
cdpwork02
cdpwork03
)
for host in "${hosts[@]}"
do
echo "===== $host ====="
ssh $host "$@"
echo ""
done
------------------------------
vi rsync.sh
------------------------------
#!/bin/bash
hosts=(
cdpwork01
cdpwork02
cdpwork03
)
for host in "${hosts[@]}"
do
echo "===== $host ====="
rsync -av $1 $host:$2
echo ""
done