卧式linux电脑,dsh批量管理linux服务器

dsh批量管理linux服务器

一,安装dsh

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

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

32位系统:ln -s /usr/local/lib/libdshconfig.so.1 /lib/

64位系统:ln -s /usr/local/lib/libdshconfig.so.1 /lib64/

[root@localhost ~]# which dsh

/usr/local/bin/dsh

二,用法介绍:

[root@china-channel ~]# 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显示被控制主机的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

三,创建控制的主机列表

[root@china-channel ~]# cat /root/.dsh/machines.list

web@218.85.1.2

web@218.85.1.3

[root@china-channel ~]# cat /root/.dsh/group/umail

user@218.85.1.2

user@218.85.1.3

四,配置ssh无密码登陆

[root@china-channel ~]# ssh-keygen -t rsa

回车三次。

在/root/.ssh目录下生成id_rsa,id_rsa.pub

把id_rsa.pub拷贝到被控制机的/root/.ssh/目录下:

[root@mail176 .ssh]#mv id_rsa.pub authorized_keys

[root@mail176 .ssh]#chmod 600 authorized_keys

对于有多个不同控制机的,可以通过cat id_rsa.pub >>authorized_keys 追加的形式

五,应用举例:

[root@china-channel AIMstor]# dsh -M -r ssh -a -- free

218.85.1.2: total used free shared buffers cached

218.85.1.2: Mem: 8168272 8138584 29688 0 197176 3516140

218.85.1.2: -/+ buffers/cache: 4425268 3743004

218.85.1.2: Swap: 16386260 1011732 15374528

218.85.1.3: total used free shared buffers cached

218.85.1.3: Mem: 8168272 8103304 64968 0 543324 3085280

218.85.1.3: -/+ buffers/cache: 4474700 3693572

218.85.1.3: Swap: 16386260 1039780 15346480

[root@china-channel AIMstor]# dsh -M -r ssh -a -- free|grep /cache

218.85.1.2: -/+ buffers/cache: 4423528 3744744

218.85.1.3: -/+ buffers/cache: 4462684 3705588

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值