Cluster Shellとは
Introduction — clustershell 1.9.3 documentation
clustershell.readthedocs.io
概要
Cluster Shellは、クラスタ管理用の軽量かつ統一されたPythonフレームワークです。大規模なクラスタを効率的に管理するために設計されており、以下の特徴を持ちます。
- 並列かつスケーラブルなコマンド実行エンジン: 数百から数千のノードに対して同時にリモートシェルコマンドを実行可能です。
- 統一されたノードグループ構文と外部グループアクセス:
NodeSetクラスを用いてノード群を柔軟に指定可能です。
ClusterShellはフランスのCEAのHPC開発チームによって開発され、スーパーコンピュータ管理で利用されています。
仕組み
コマンド実行エンジン
- 並列処理: 内部でイベントループを用い、非同期I/Oにより多数ノードへの同時SSH接続を効率的に処理します。
- 出力収集: 各ノードからの標準出力・エラーをまとめて収集し、ノード単位でグルーピングして管理者に提示します。
導入方法 - RHEL9
Installation — clustershell 1.9.3 documentation
clustershell.readthedocs.io
- 管理ノード (1台): ClusterShellをインストールして、全ノードを制御します。
- 管理対象ノード: 必ずしもClusterShellをインストールする必要はありません。SSHでパスワード無しで接続できるようにする必要があります。
EPELからのインストール方法
EPELを有効にする (していない場合):
dnf --enablerepo=extras install epel-release
ClusterShellをインストール:
dnf install clustershell
Configuration
基本的な設定ファイルは以下の場所にあります。
/etc/clustershell/clush.conf/etc/clustershell/groups.conf/etc/clustershell/groups.d/cluster.yaml
groups.confでグループ定義の参照先を設定し、cluster.yamlが実際のグループ定義ファイルとなります。clush.confはclushコマンドの挙動を調整する設定ファイルです。
clush の設定
/etc/clustershell/clush.confを設定します。以下は公式ドキュメントからの引用です。
| Key | Value |
|---|---|
| fanout | Size of the sliding window of connectors (eg. max number of ssh allowed to run at the same time). |
| connect_timeout | Timeout in seconds to allow a connection to establish. |
| command_timeout | Timeout in seconds to allow a command to complete since the connection has been established. |
| color | Whether to use ANSI colors. Valid arguments: never, always, auto. |
| fd_max | Maximum number of open file descriptors permitted per clush process. |
| history_size | Maximum number of history entries saved. |
| node_count | Should clush display additional node count information? (yes/no) |
| maxrc | Should clush return the largest of command return codes? (yes/no) |
| ssh_user | Set the ssh user to use for remote connection. |
| ssh_path | Set the ssh binary path. |
| ssh_options | Set additional options to pass to the ssh command. |
| scp_path | Set the scp binary path. |
| scp_options | Set additional options to pass to the scp command. |
groups.conf
YAMLファイルを参照させるためにgroups.confを編集します。
cat /etc/clustershell/groups.conf
# ClusterShell node groups main configuration file
[Main]
default: roles
confdir: /etc/clustershell/groups.conf.d $CFGDIR/groups.conf.d
autodir: /etc/clustershell/groups.d $CFGDIR/groups.d
# ... (rest of the file)
[local]
map: [ -f $CFGDIR/groups ] && f=$CFGDIR/groups || f=$CFGDIR/groups.d/local.cfg; sed -n 's/^$GROUP:\(.*\)/\1/p' $f
all: [ -f $CFGDIR/groups ] && f=$CFGDIR/groups || f=$CFGDIR/groups.d/local.cfg; sed -n 's/^all:\(.*\)/\1/p' $f
list: [ -f $CFGDIR/groups ] && f=$CFGDIR/groups || f=$CFGDIR/groups.d/local.cfg; sed -n 's/^\([0-9A-Za-z_-]*\):.*/\1/p' $f
cluster.yaml
cat /etc/clustershell/groups.d/cluster.yaml
roles:
group1: 'node01'
group2: 'wn[01-99]'
gather:
- 'node01'
- 'wn[01-99]'
all: '@group1,@group2'
使用例
定義したグループの確認:
nodeset -LL
コマンドが作動するか確認:
clush -w @all df -h
任意のグループに対してコマンドを実行:
clush -w @worker_node condor_status
任意のグループへ設定ファイルを配布:
# First, create the file on the admin server
vi myfile.conf
# Then, copy it to the destination on all nodes in the group
clush -w @group -c myfile.conf --dest=/etc/myfile.conf
特定のノードを指定してコマンドを実行:
clush -w wn[02,03] "ip addr"