Batch management of cluster IP scripts on a known IP basis

Source: Internet
Author: User
Tags log

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.