In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to implement commands that can be executed on any server. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Previously maintained a server cluster of thousands of servers, it would be too troublesome to manually log in to each server every time you need to execute a command on the server. If you think about it, if in a cluster of thousands of servers, each server only needs to simply execute the same command, let alone execute the command, it is enough for you to manually log in to thousands of servers in turn. It is estimated that you can log on to thousands of servers in turn, and you may not be able to log on in three days, so what should you do? Is there any good way to solve this problem?
Don't worry, that's what we're here to solve today.
To tell you the truth, when I was maintaining thousands of server clusters, I didn't log in to each server manually in turn. Why? Yes, it's because I'm lazy! I am lazy to log in, and log in to so many servers in turn, the whole person will collapse.
So, I figured out if I could write a script that would receive the commands I wanted to execute, and then distribute the commands to all the servers on the cluster for execution, wouldn't that solve the problem? Just do it.
Here, however, there is one thing to note: you need to configure in advance the correspondence between the hostname and IP address of each server in the cluster, be able to communicate with each other, and configure SSH password-free login. Do not worry about this, just let the operation and maintenance staff plan and allocate the server, there is no need to log in to the server to deal with it.
To make it easier for friends to understand, let's assume that there are 1024 servers in the cluster, each with a host name of binghe1~binghe1024. Each server can communicate through the hostname, and then I wrote a script called distribute_command.sh, as shown below.
#! / bin/bash
Pcount=$#
If ((pcount / home/hello.txt)
View the contents of the hello.txt file on each server in the cluster. / distribute_command.sh cat / home/hello.txt
Delete the hello.txt file on each server in the cluster. / distribute_command.sh rm-rf / home/hello.txt Thank you for reading! This is the end of the article on "how to execute commands on any server". 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.