dsh安装指南

dsh批量管理linux服务器


 
一,安装dsh

切换到root用户,然后切换到work_home_yourname


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

出错记得修复(Ubuntu: configure error: C++ preprocessor "/lib/cpp" fails sanity check  

 apt-get install   build-essential)

make && make install
 
wget http://www.netfort.gr.jp/~dancer/software/downloads/dsh-0.25.9.tar.gz
tar zxvf dsh-0.25.9.tar.gz
cd dsh-0.25.9
./configure
make && make install
 
ln -s /usr/local/lib/libdshconfig.so.1 /lib/

echo "/usr/local/lib/libdshconfig.so.1">> /etc/ld.so.conf

ldconfig


[root@localhost ~]# which dsh
/usr/local/bin/dsh
 

 


二,用法介绍:

切换回需要的用户.

mkdir .dsh

cd .dsh

touch how-to-use,内容如下:

dsh -M -r ssh -f file目录  --命令 

 

dsh --help

-v –verbose                   Verbose output  详细模式输出
-q –quiet                     Quiet  安静模式输出
-M –show-machine-names      Prepend the host name on output显示被控制主机的hostname
-H –hide-machine-names      Do not prepend host name on output  不显示主机名(default)
-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  主机列表,默认列表在/root/.dsh/machines.list
-g –group [groupname]  Execute on group member 指定主机名组,主机名组在/root/.dsh/group/
-f –file [file]               Use the file as list of machines  选择主机列表
-r –remoteshell [shellname]   Execute using shell (rsh/ssh)  指定远程工具,默认为rsh
-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

三,应用举例:
 dsh -M -r ssh -m ~/a.txt -- hostname
       

原文地址:https://www.cnblogs.com/assassin1994/p/4523031.html