Published

三 25 九月 2013

←Home

clustershell

之前做vps状态监控的时候注意到了这个小工具,但是需求不同,也就没有使用,有空我再来说说那一个。

这次的需求又不同了,vps空间相对都是比较小的,我们的程序时间久了会留下很多日志文件占用大量空间,因此需要定时清理。因此,使用这个小工具就不需要在每台vps布置,设置定时任务了。

直接从已写好的地方般过来了,所以将就看看,希望能帮到大家。

clustershell

ClusterShell is an event-based Python library to execute commands on local or distant cluster nodes in parallel depending on the selected engine and worker mechanisms. The library provides advanced node sets and node groups handling methods. Its goal is to improve the administration of cluster by providing a lightweight but scalable API for developers. Also, clush, clubak and nodeset, three convenient command-line tools using the library are included.

clush

clush

clush is an utility provided with ClusterShell that aims to ease cluster administration.

Features (in brief)

  • execution of commands in parallel
  • smart display of command results (gathering, sorting by node, nodeset or node groups)
  • standard input text redirection to remote nodes
  • files copying in parallel
  • pdsh options backward compatibility (compare)

TEST

setup(ubuntu)

sudo apt-get install clustershell cat /etc/clustershell/clush.conf

# Configuration file for clush # 
# Please see man clush.conf(5) # 
# $Id: clush.conf 463 2011-02-09 21:57:52Z st-cea $ 
[Main] 
fanout: 64 
connect_timeout: 15 
command_timeout: 0 
color: auto 
fd_max: 16384 
history_size: 100 
node_count: yes 
verbosity: 1 
#ssh_user: root 
#ssh_path: /usr/bin/ssh 
#ssh_options: -oStrictHostKeyChecking=no

config and it changed as below :

# Configuration file for clush # 
# Please see man clush.conf(5) # 
# $Id: clush.conf 463 2011-02-09 21:57:52Z st-cea $ 
[Main] 
fanout: 64 
connect_timeout: 15 
command_timeout: 0 
color: auto 
fd_max: 16384 
history_size: 100 
node_count: yes 
verbosity: 1 
ssh_user: root 
#ssh_path: /usr/bin/ssh 
#ssh_options: -oStrictHostKeyChecking=no

then:

sudo vim /etc/clustershell/groups

add these test case:

us: us2 us3

edit /etc/hosts:

184.22.241.102 us2
184.82.244.17 us3

add your ssh-key to us2,us3(if dont know,u can search online)

last,we run command:

clush -b -g us "uptime"

screen:

---------------  
us2
---------------
07:43:04 up 269 days, 12:59, 0 users, load average: 0.24, 0.05, 0.02
---------------  
us3
---------------  
07:43:05 up 173 days, 12:18, 0 users, load average: 0.00, 0.00, 0.00

clustershell wiki : https://github.com/cea-hpc/clustershell/wiki
clush : https://github.com/cea-hpc/clustershell/wiki/clush

Go Top
comments powered by Disqus