In a cluster of now manage thousands of
Linux
machine became a problem, can no longer use one a login host to manage the workload is undoubtedly very great, here we can helpClustershell
with thepssh
management, it is the principle of automatic Login hosts in the cluster will help us execute scripts, or file operations, etc., had a big pig is one to manage, and one word: tired Yeah.
user's guidance
Clustershell Tools
Centos7 is used as the operation, we only need to complete all of the configuration of the machine in a cluster on a single host
master host.com #主机
cluster1 2.host.com #节点1
cluster2 3.host.com #节点2
cluster3 4.host.com #节点3
Free Password
1,2,3 host using ssh to log node must be password-free login , and can not log in for the first time, because Clustershell
not automatically enter interactive commands, such as the following will host the first login prompt.
ssh [email protected]
The authenticity of host '2.host.com (192.168.0.20)' can't be established.
ECDSA key fingerprint is d4:5d:d6:e6:bc:70:86:1b:42:32:aa:6b:86:a6:34:d4.
Are you sure you want to continue connecting (yes/no)?
Clustershell
Can not automatically process will prompt the following error
[1] 11:32:17 [FAILURE] 2.host.com Exited with error code 255
Key generation
ssh-keygen -t rsa
Copy the contents of the public key to each node
scp ~/.ssh/id_rsa.pub 192.168.0.20:/root/.ssh/authorized_keys
scp ~/.ssh/id_rsa.pub 192.168.0.21:/root/.ssh/authorized_keys
scp ~/.ssh/id_rsa.pub 192.168.0.22:/root/.ssh/authorized_keys
Configuration ClusterShell
vim /etc/clustershell/groups.d/local.cfg
Follows
# ClusterShell groups config local.cfg
#
# Replace /etc/clustershell/groups
#
# Note: file auto-loaded unless /etc/clustershell/groups is present
#
# See also groups.d/cluster.yaml.example for an example of multiple
# sources single flat file setup using YAML syntax.
#
# Feel free to edit to fit your needs.
adm: example0
oss: example4 example5
mds: example6
io: example[4-6]
compute: example[32-159]
gpu: example[156-159]
all: example[4-6,32-159]
demo: [1-3].host.com
Above we define a group: demo, by connecting this packet can 1.host.com, 2.host.com, 3.host.com, if this three to pull the node corresponding IP connection failure is not mapped, may be provided / etc / hosts correspondence relationship
cat /etc/hosts
127.0.0.1 localhost
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.20 1.host.com
192.168.0.21 2.host.com
192.168.0.22 3.host.com
clush command several important parameters
- -b: Merge same output
- -w: Specifies the node
- -a: all nodes
- -g: Specifies the group
- --copy: Bulk file
Each node executes ls
the command
clush -g demo "ls"
Create a file
clush -g demo "touch /root/demo.txt"
Bulk file
clush -g demo --copy groups --dest /root
pssh Tools
installation
yum install pssh -y
Edit IP node to pull
vim /root/hosts.txt
1.host.com
2.host.com
3.host.com
Node executes the command
pssh -H hosts.txt -P "ls"