Since the recent time is quite tight, the code implementation and testing is not ready to take into account, here only for thinking Records:
Dependent conditions:
1, know all DHCP allocated IP (hereinafter referred to as DIP), and to modify the static IP (SIP)
2, there is a script, through its configuration file, you can modify the host name, IP and other information (completed)
3, two groups of IP in the form of arrays, write script configuration file
4, not modified state, dip ONLINE,SIP must be offline.
5, unmodified state, if SIP online, log and Skip
6, the dip and the number of SIPs should be equal, but not mandatory
7, after the successful modification, dip may online,sip must online
8, modify the successful, corresponding SIP write/etc/hosts
9, after the successful modification, delete the original dip in the/etc/hosts record
10, after the successful modification, delete sip and dip in the script configuration file corresponding information
11. Consider that when a dip is more than sip, the dip it is using can be changed to sip directly (this function can be independent)
12, the cluster must be mutual trust
Implementation method:
Traversing the DIP array:
When dip online and sip offline are satisfied, continue, otherwise log and jump out of this cycle
Copy configuration file to the TMP directory and do the configuration that modifies it for SIP
Push to target node via dip
Through dip call md5sum detection profile consistency, consistent next, otherwise log out of this cycle
Call the corresponding script by dip, consider the delay of restarting Network Service, hibernate for 3 seconds
Detect the success of this modified SIP, dip in just released can mean its offline
Detect SIP and Dip states:
Func= deletes the dip in the corresponding SIP, dip, and/etc/hosts in the configuration file and writes the SIP to the/etc/hosts
SIP Online and Dip Offline:func
Sip offline and dip offline:func, logging status log
Dip online and sip online:func, logging status log
The 11th function is too easy, no longer repeat.
This article from the "Self-Improvement" blog, please be sure to retain this source http://mos1989.blog.51cto.com/4226977/1225688
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/zs/