One Click Cluster Install
Problem
We have a cluster of servers all running the same software. Upgrading a node is as simple as extracting a zip file and overwriting the existing installation. This sounds a simple task but at some point the number of nodes might become large enough to make the upgrade a tedious process. Upgrading our cluster installations becomes even more time consuming as we push frequent builds and specially if we revert and do build to build comparisons. I thought about the simplest windows bat file to automate and deal with the following issues
- Automatically grab the latest zip file from a builds directory
- Kill a remote process before overwriting files otherwise copying files fails
- Extract the zip file from the command line
Solution
Here are the steps that I followed…
- Make sure each node in the cluster has the installation directory shared.
- Make sure the shared folders have write permission
- Install the 7z zip file extractor on the machine on which you want to execute the upgrade script. Here is a direct link
Code
Here is the code to grab the latest file in a directory…
1 2 3 4 |
for /F "delims=" %%I in ('dir \\\\server\\builds\\Server*.zip /b /a-d /od') do set LATEST=%%I copy "\\\\server\\builds\\%LATEST%" C:\\some_local_path |
Here is how to kill a process on a remote Windows machine…
1 |
taskkill.exe /S name_or_ip /U "user" /P pass /IM process_name.exe |
and here is how to extract a zip file from the windows command line…
1 |
7z.exe x -o"\\\\server_node_host_or_ip\\server_installation_directory" -y "%LATEST%" |
About Author
Mohammed Abualrob
Software Engineer @ Cisco