If you have several database servers and suddenly want to know their current real-time load, what do you do? Log on to uptime one by one? It feels silly. Write a shell? A waste of time. Use ClusterShell directly!
Installation and configuration of ClusterShell
ClusterShell installation is very Easy. If you use APT or YUM package management, it is basically a command. I will not talk about it. Here I will talk about how to install it from the source code, run the following command in the source code directory:
shell> python setup.py install
For ease of use, you also need to copy the configuration file to the specified directory:
shell> mkdir /etc/clustershellshell> cp conf/* /etc/clustershell
Next, configure the nodes we want to manage. Suppose we have configured a db Group, which contains three nodes: db _ [1-3:
shell> cat /etc/clustershell/groupsdb: db_1 db_2 db_3
Prepare. Follow the example at the beginning of the article to query the current load of all database servers:
shell> clush -g db "uptime"
Note: The premise is that you need to set password-free logon on the operating server. If you are not clear about it, please refer to the following content.
Article: How do I configure a server password-free login?
If the ssh key is not generated in advance, you need to convert it:
shell> ssh-keygen
Optional operations: For convenience, we can give the server to be logged on a readable alias. If you do similar operations, then the <USER >@< SERVER> can be replaced with the corresponding <HOST>:
shell> cat ~/.ssh/configHost db_1Hostname <SERVER>User <USER>Port <PORT>Host db_2Hostname <SERVER>User <USER>Port <PORT>Host db_3Hostname <SERVER>User <USER>Port <PORT>
Then, add the generated public key to the specified location of the server to be logged on:
shell> cat ~/.ssh/id_rsa.pub | ssh <USER>@<SERVER> "cat - >> ~/.ssh/authorized_keys"
If you cannot remember how to spell authorized_keys correctly like me, you can learn how to use ssh-copy-id. This command can make the operation simpler:
shell> ssh-copy-id -i ~/.ssh/id_rsa.pub "<USER>@<SERVER>"
Note: each time a password-free Login server is configured, it is best to manually perform the operation, because the first connection requires manual confirmation whether to save the information ~ /. Ssh/known_hosts file.
...
Some netizens may say that tools such as Munin can be used to monitor server loads. Good, but tools like Munin cannot provide you with timely data. In addition, ClusterShell is not limited to the query load function. Different commands can be used to query different data, in tools such as Munin, if you want to monitor a data, you must have a corresponding plug-in. ClusterShell is an indispensable tool for Linux O & M!
Original article: http://huoding.com/2011/11/12/133