Lightweight cluster management software-clustershell

Source: Internet
Author: User
Tags ssh port

If the number of clusters is not large, it is very necessary to choose a lightweight cluster management software. Clustershell is such a small cluster management tool, the principle is the use of SSH, can be said to be a Linux system very useful operational tools

Clustershell abbreviation Clush Advantages:

Easy to install. An instruction can be easily installed
Easy to configure. Many cluster management software need to install software on all the servers, but also to do a lot of connection operation, Clustershell is quite convenient, just need all the machine can ssh without password login, and then only install Clustershell on a single server
The easy-to-Clustershell command is relatively simple, with only one or two instructions and three or four parameters to remember

Lab Environment: CentOS7

192.168.94.11 Clustershell

192.168.94.22 host1

192.168.94.33 Host2

Install Clustershell can be used with yum, or can be installed with the source code

Yum Install Clustershell

Do host Name Mapping

[Email protected] ~]# vim/etc/hosts192.168. 94.11 Clustershell                                                                    192.168. 94.22 host1 192.168. 94.33 Host2

Configure SSH key to login for password-free login

To write a simple batch distribution key and Polygon interaction script, first need to download Sshpass

Yum Install Sshpass
Usage: Sshpass [-f |-d |-P |-e] [-HV] Command parameter-f filename Get password from file-D number use number as the file descriptor for Get password-p password provide password as parameter (security unwise)-e password as Env-var "Sshpass" Pass no parameters-the password will get the-h display Help from standard input (this screen)-V Print version information should use a maximum of-f,-d,-p or-E
[Email protected] ~]# vim Sshkey.SH#!/bin/bash./etc/rc.d/init.d/functions# create key \RM~/.SSH/id_rsa*-FSsh-keygen-T rsa-f ~/.SSH/id_rsa-n""-q# Distributing public keys forIpinch  A  -   DoSshpass-F ~/.sshpassSSH-copy-ID-I. ~/.SSH/id_rsa.pub [email protected]192.168.94. $IP-o stricthostkeychif[$?-eq0]; ThenAction"Copy-id 192.168.94. $ip"/bin/trueElseAction"Copy-id 192.168.94. $ip"/bin/falsefiEcho "" Done

Add Execute Permissions script to script to use the password file location and name customization, because it is a password file, permissions 600

chmod +x sshkey. SH  chmod ~/~]# ll ~/. Sshpass1 September   8  :/root/.sshpass

Perform a script test and do a host name Mapping

Get started with Clustershell for batch management

Configuration Clush:
In the/etc/clustershell directory, create the groups file manually

[Email protected] ~]# vim/etc/clustershell/groupsall:host[1,2]web: Host1db:host2   -A This parameter, separated by a space between the host

Common parameters for Clush management commands:
-G after specifying the set of groups
-A represents all groups
-W followed by a host node, separated by commas between multiple hosts
-X means that a node is removed from operation. followed by a host node, separated by commas between multiple hosts
-X means that a group is removed and multiple groups are separated by commas
-B Same Output result merged

Date255

change the previous IP to host name

Execute Script

[[email protected] ~]# CLUSH-G DBDatehost2:2018 Saturday September 08 -:Geneva: -Cst[[email protected]~]# clush-g WebDatehost1:2018 Saturday September 08 -:Geneva: -Cst[[email protected]~]# clush-aDatehost1:2018 Saturday September 08 -: to:xxcsthost2:2018 Saturday September 08 -: to:xxcst# support for operations such as pipelines and redirects [[email protected]~]# clush-a'echo I Love Wife >/tmp/1314'[[Email protected]~]# clush-aCat/tmp/1314host2:i Love wifehost1:i love Wife[[email protected]~]# Clush-WHost1ifconfigens33|awk-F'[ :]+' 'Nr==2{print}'192.168.94.22# plus-the B option can be the same result combined output [[email protected]~]# Clush-abDate---------------host[1-2] (2)---------------Saturday, September 08, 2018 -: -: *Cst[[email protected]~]# Clush-abhostname---------------host1---------------host1---------------Host2---------------Host2[[email protected]~]# Clush-abCat/etc/centos-Release---------------host[1-2] (2)---------------CentOS Linux Release7.5.1804(Core)

Clush can also be used for the distribution of files and directories:

--copy means copying files or directories locally from a local to a remote cluster node, equal to-C
--rcopy means copying files or directories from a remote cluster node to this computer
--dest the file or directory path to be copied locally, followed by the Remote Storage path

[Email protected] ~]#Catmingming I Love Wife[[email protected]~]# clush-g web-c/root/mingming--dest/Root[[email protected]~]# clush-g WebCat/root/mingming host1:i Love Wife[[email protected]~]# Clush-WHost2-c/root/mingming--dest=/root/[[Email protected]~]# Clush-WHost2Cat/root/mingming host2:i Love wife# Copy Local directory to remote node [[email protected]~]# clush-g Webls-l/root/host1: Total dosage14708host1:-RW-------.1Root root1257May - Geneva: +anaconda-Ks.cfghost1:-rwxr-xr-x.1Root root2236June4  A: -Dns.SHhost1:-rw-r--r--.1Root root15039314August -  -: +Master.Ziphost1:-rw-r--r--1Root root ASeptember8  -: -MINGMINGHOST1:DRWXR-xr-x2Root root6September8  -: -MYWIFEHOST1:DRWXR-xr-x.TenRoot root4096August -  -: WuVIMHOST1:DRWXR-xr-x.9Root root4096August -  -: -vim-master# Copy a directory or file from a remote node to a local [[email protected]~]# CD mywife/[email protected] mywife]#pwd/root/Mywife[[email protected] mywife]#ls[email protected] mywife]# Clush-a--rcopy/root/mingming--dest./[email protected] mywife]#lsmingming.host1 mingming.host2# Remote Copy file to local, the suffix is appended with the hostname of the node

--user=username, which indicates the user who logged in to SSH when using the Clush command

For example, I use the root account of this machine to manage the Damowang user of the Host1 node

ssh-copy-ID -I. ~/. ssh/--user=damowang-whostname----user=damowang-W  whoamiHost1:damowang

Clush is a tool for encapsulation based on SSH and SCP commands, the default SSH port if not 22, you need to specify the port number when executing the Clush command

-o-p2222 (capital P) required for file transfer
-o-p2222 (lowercase p) required for bulk execution of OPERATION commands

[Email protected] mywife]# Clush-w host1-o-p2222-c./mingming.host1--dest/root/-w host1 -o-p2222  ls /root/host1:anaconda-Ks.cfghost1:DNS. SH Host1:master. Zip Host1:mingminghost1:mingming.host1host1:mywifehost1:vimhost1:vim-master

Lightweight cluster management software-clustershell

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.