In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use ClusterShell in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
ClusterShell
ClusterShell is an event-driven open source Python library designed to run local or remote commands in parallel on a server farm or large Linux cluster. (clush is ClusterShell).
It will deal with common problems encountered on HPC clusters, such as operating on node groups, running distributed commands using optimized execution algorithms, and collecting results and merging the same output, or retrieving return codes.
ClusterShell can take advantage of existing remote shell facilities installed on the system, such as SSH.
The main goal of ClusterShell is to improve the management of high-performance clusters by providing developers with lightweight but extensible Python API. It also provides convenient command-line tools such as clush, clubak, and cluset/nodeset that allow traditional shell scripts to take advantage of some of the library's features.
ClusterShell is written in Python and requires Python (v2.6 + or v3.4 +) to run on your system.
How do I install ClusterShell on Linux?
The ClusterShell package is available in the official package manager of most distributions. Therefore, install using the distribution package manager tool.
For Fedora systems, use the DNF command to install clustershell.
$sudo dnf install clustershell
If the system defaults to Python 2, this installs Python 2 modules and tools, and you can run the following command to install the Python 3 development package.
$sudo dnf install python3-clustershell
Before performing a clustershell installation, make sure that you have enabled the EPEL repository on your system.
For RHEL/CentOS systems, use the YUM command to install clustershell.
$sudo yum install clustershell
If the system defaults to Python 2, this installs Python 2 modules and tools, and you can run the following command to install the Python 3 development package.
$sudo yum install python34-clustershell
For openSUSE Leap systems, use the Zypper command to install clustershell.
$sudo zypper install clustershell
If the system defaults to Python 2, this installs Python 2 modules and tools, and you can run the following command to install the Python 3 development package.
$sudo zypper install python3-clustershell
For Debian/Ubuntu systems, use the APT-GET command or the APT command to install clustershell.
How does sudo apt install clustershell install ClusterShell in Linux using PIP?
You can install ClusterShell using PIP because it is written in Python.
Before performing a clustershell installation, make sure that you have enabled Python and PIP on your system.
How does $sudo pip install ClusterShell use ClusterShell on Linux?
It is a straightforward and excellent tool compared to other utilities such as pssh and dsh. It has many options that can be executed remotely in parallel.
Before you start using clustershell, make sure that you have enabled password-less login on your system.
The following configuration files define system-wide default values. You don't need to change anything here.
$cat / etc/clustershell/clush.conf
If you want to create a server group, that's fine. There are some examples by default, please do the same according to your requirements.
$cat / etc/clustershell/groups.d/local.cfg
You can get information from a given node simply by running the clustershell command in the following format:
$clush-w 192.168.1.4192.168.1.9 cat / proc/version192.168.1.9: Linux version 4.15.0-45-generic ([email protected]) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) # 48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019192.168.1.4: Linux version 3.10.0-957.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)) # 1 SMP Thu Nov 8 23:39:32 UTC 2018
Options:
-w: the node on which you want to run the command.
You can use regular expressions instead of the full hostname and IP:
$clush-w 192.168.1. [4 957.el7.x86_64 9] uname-r192.168.1.9: 4.15.0-45-generic192.168.1.4: 3.10.0-957.el7.x86_64
Alternatively, if the server is in the same IP series, you can use the following format:
$clush-w 192.168.1. [4-9] date192.168.1.6: Mon Mar 4 21:08:29 IST 2019192.168.1.7: Mon Mar 4 21:08:29 IST 2019192.168.1.8: Mon Mar 4 21:08:29 IST 2019192.168.1.5: Mon Mar 4 09:16:30 CST 20192.168.1.9: Mon Mar 4 21:08:29 IST 20192.168.1.4: Mon Mar 4 09:16:30 CST 2019
Clustershell allows us to run commands in batch mode. Use the following format to do this:
$clush-w 192.168.1.4192.168.1.9-bEnter 'quit' to leave this interactive modeWorking with nodes: 192.168.1. Clush > hostnamectl-192.168.1.4- Static hostname: CentOS7.2daygeek.com Icon name: computer-vm Chassis: vm Machine ID: 002f47b82af248f5be1d67b67e03514c Boot ID: F9b37a073c534dec8b236885e754cb56 Virtualization: kvm Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-957.el7.x86_64 Architecture: x86-64-192.168.1.9-Static hostname: Ubuntu18 Icon name: computer-vm Chassis: vm Machine ID: 27f6c2febda84dc881f28fd145077187 Boot ID: f176f2eb45524d4f906d12e2b5716649 Virtualization: oracle Operating System: Ubuntu 18.04.2 LTS Kernel: Linux 4.15.0-45-generic Architecture: x86-64clush > free-Mlyle 192.168.1.4-total used free shared buff/cache availableMem: 1838 641 217 19 978 969Swap: 2047 0 2047-192.168.1.9-total used free shared buff/cache availableMem: 1993 352 1067 1573 1473Swap: 1425 0 1425clush > wmur192.168.1.4-09:21:14 up 3:21 3 users, load average: 0.00, 0.01 0.05USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATdaygeek: 0: 0 06:02? xdm? 1:28 0.30s / usr/libexec/gnome-session-binary-- session gnome-classicdaygeek pts/0: 0 06:03 315 17m 0.06s 0.06s bashdaygeek pts/1 192.168.1.6 06:03 52:26 0 .10s 0.10s-bash-192.168.1.9- 21:13:12 up 3:12 1 user, load average: 0.08,0.03, 0.00USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATdaygeek pts/0 192.168.1.6 20:42 29:41 0.05s 0.05s-bashclush > quit
If you want to run the command on a set of nodes, use the following format:
$clush-w @ dev uptimeor$ clush-g dev uptimeor$ clush-- group=dev uptime 192.168.1.9: 21:10:10 up 3:09, 1 user, load average: 0.09,0.03,0.01192.168.1.4: 09:18:12 up 3:18, 3 users, load average: 0.01,0.02,0.05
If you want to run the command on multiple node groups, use the following format:
$clush-w @ dev,@uat uptimeor$ clush-g dev,uat uptimeor$ clush-- group=dev,uat uptime 192.168.1.7: 07:57:19 up 59 min, 1 user, load average: 0.08,0.03,0.00192.168.1.9: 20:27:20 up 1:00, 1 user, load average: 0.00,0.00,0.00192.168.1.5: 08:57:21 up 59 min, 1 user, load average: 0.00000.01,0.05
Clustershell allows us to copy files to a remote computer. Copy the local file or directory to the same remote node:
$clush-w 192.168.1. [4jue 9]-- copy / home/daygeek/passwd-up.sh
We can verify it by running the following command:
$clush-w 192.168.1. [4Jing 9] ls-lh / home/daygeek/passwd-up.sh192.168.1.4:-rwxr-xr-x. 1 daygeek daygeek 159 Mar 4 09:00 / home/daygeek/passwd-up.sh192.168.1.9:-rwxr-xr-x 1 daygeek daygeek 159 Mar 4 20:52 / home/daygeek/passwd-up.sh
Copy a local file or directory to a remote node in a different location:
$clush-g uat-- copy / home/daygeek/passwd-up.sh-- dest / tmp
We can verify it by running the following command:
$clush-group=uat ls-lh / tmp/passwd-up.sh192.168.1.7:-rwxr-xr-x. 1 daygeek daygeek 159 Mar 6 07:44 / tmp/passwd-up.sh
Copy the file or directory from the remote node to the local system:
$clush-w 192.168.1.7-rcopy / home/daygeek/Documents/magi.txt-dest / tmp
We can verify it by running the following command:
$ls-lh / tmp/magi.txt.192.168.1.7-rw-r--r-- 1 daygeek daygeek 35 Mar 6 20:24 / tmp/magi.txt.192.168.1.7 Thank you for reading! This is the end of the article on "how to use ClusterShell in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.