天天看點

dsh 批量管理伺服器

一,安裝dsh

wget http://www.netfort.gr.jp/~dancer/software/downloads/libdshconfig-0.20.9.tar.gz

tar xvf libdshconfig-0.20.9.tar.gz

cd libdshconfig-0.20.9

./configure --prefix=/usr/

make && make install

wget http://www.netfort.gr.jp/~dancer/software/downloads/dsh-0.25.9.tar.gz

tar xvf dsh-0.25.9.tar.gz

cd dsh-0.25.9

ldconfig

[root@heit]# dsh --help

Distributed Shell / Dancer's shell version 0.25.9

Copyright 2001-2005 Junichi Uekawa,

distributed under the terms and conditions of GPL version 2

-v --verbose                   Verbose output

-q --quiet                     Quiet

-M --show-machine-names        Prepend the host name on output

-H --hide-machine-names        Do not prepend host name on output

-i --duplicate-input           Duplicate input given to dsh

-b --bufsize                   Change buffer size used in input duplication

-m --machine [machinename]     Execute on machine

-n --num-topology              How to divide the machines

-a --all                       Execute on all machines

-g --group [groupname]         Execute on group member

-f --file [file]               Use the file as list of machines

-r --remoteshell [shellname]   Execute using shell (rsh/ssh)

-o --remoteshellopt [option]   Option to give to shell

-h --help                      Give out this message

-w --wait-shell                Sequentially execute shell

-c --concurrent-shell          Execute shell concurrently

-F --forklimit [fork limit]    Concurrent with limit on number

-V --version                   Give out version information

這說明安裝成功

ssh-keygen -t rsa

一路回車會在/root/.ssh/目錄下生成公鑰(id_rsa.pub)和私鑰(id_rsa)。

将id_rsa.pub複制到被控制端/root/.ssh/目錄下

mv id_rsa.pub authorized_keys

chmod authorized_keys 600

在控制端

mkdir /root/.dsh/

mkdir /root/.dsh/group/

touch /root/.dsh/machines.list

touch /root/.dsh/group/g1

cat //root/.dsh/machines.list

192.168.220.12

cat /root/.dsh/group/g1

dsh -r ssh -a touch /root/a

dsh -r ssh -g g1 touch /root/a

繼續閱讀