CN104378449A - Virtual IP realization method - Google Patents

Virtual IP realization method Download PDF

Info

Publication number
CN104378449A
CN104378449A CN201410749176.7A CN201410749176A CN104378449A CN 104378449 A CN104378449 A CN 104378449A CN 201410749176 A CN201410749176 A CN 201410749176A CN 104378449 A CN104378449 A CN 104378449A
Authority
CN
China
Prior art keywords
virtual
address
network interface
interface card
application service
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201410749176.7A
Other languages
Chinese (zh)
Other versions
CN104378449B (en
Inventor
陆舟
于华章
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201410749176.7A priority Critical patent/CN104378449B/en
Publication of CN104378449A publication Critical patent/CN104378449A/en
Application granted granted Critical
Publication of CN104378449B publication Critical patent/CN104378449B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a virtual IP realization method and belongs to the technical field of a computer communication network. The method includes allowing a computer to acquire a network card ID boned with the computer and the network card description information from a database according to the own IP, acquiring a virtual IP and a virtual IP subnet mask from the database, forbidding the network card corresponding to the network card ID by invoking an equipment drive program, bonding the virtual IP and the virtual IP subnet mask which are acquired from the database with the network card corresponding to the network card ID by invoking the drive program, or deleting the virtual IP and the virtual IP subnet mask which correspond to register tables of the network card corresponding to the network card ID, then starting the network card corresponding to the network card ID by invoking the equipment drive program, and realizing the virtual IP adding and deleting functions of the computer. Manual operation is omitted, and labor force cost is saved.

Description

A kind of implementation method of virtual IP address
Technical field
The present invention relates to computer communication network technical field, particularly relate to a kind of implementation method of virtual IP address.
Background technology
In computer cluster system, realize the High Availabitity service of business mainly by increasing node, under making multiple node be operated in load sharing mode or under main-standby mode, when primary node failure, back-up paths is taken over primary node and is continued to provide service.Because digital communications network is to the differentiation of complete IP network, make the mainly IP-based communication of the communication mode of node.When primary node failure, the client of accessing primary node can continue to ask for service to the IP address of primary node, with same IP address provision service when this will ask back-up paths to take over primary node, so multiple node being shared an IP address will externally provide the method for service to be called virtual IP address (VIP).
Mostly the implementation method of existing virtual IP address, for the computer cluster of multiple servers composition, be to be realized by configuration virtual IP manually, such implementation labor intensive cost; Existing virtual IP address implementation method is change by increasing the IP address of network address translation (NAT) equipment to multiple server in addition, multiple server is made externally to present a unified IP address, the NAT device that such implementation needs increase by special, adds networking and maintenance cost.There is no a kind of more practicable method being realized the functions such as virtual IP address increase, deletion by server self at present.
Summary of the invention
For solving problems of the prior art, the present invention proposes a kind of implementation method of virtual IP address, the functions such as virtual IP address increase, deletion are realized by server self, a database purchase virtual IP address is shared between server, server self realizes increase and the deletion of virtual IP address, does not need to control by the configuration of other hardware storage device to server virtual IP.
The technical solution used in the present invention is as follows: a kind of implementation method of virtual IP address, comprising:
Step S1: computer gets the network interface card ID and network interface card descriptor that bind with self IP from database according to self IP, obtain virtual IP address and virtual IP address subnet mask from database;
Step S2: invocation facility driver forbids network interface card corresponding to described network interface card ID;
Step S3: judging whether to arrange virtual IP address according to the default flag bit in database, is perform step S4, otherwise perform step S5;
Step S4: invocation facility driver deletes virtual IP address corresponding with described network interface card descriptor in the registration table of network interface card corresponding to described network interface card ID and virtual IP address subnet mask, then performs step S5;
Step S5: invocation facility driver binds the virtual IP address and virtual IP address subnet mask that obtain from database on the network interface card that described network interface card ID is corresponding, and the default flag bit more in new database;
Step S6: invocation facility driver enables network interface card corresponding to described network interface card ID.
Also step S0 is comprised: computer starting timing heartbeat is monitored and real time record monitors daily record before described step S1.
Also comprise between described step S0 and described step S1: computer judges to preset switch mode and local state, when described default switch mode and local state are main frame standby host pattern/main frame, described computer starts application service after performing described step S1-step S6; When described default switch mode and local state are mainframe host computer pattern/main frame, and when detecting that monitoring target does not start application service, described computer starts application service after performing described step S1-step S6; When described default switch mode and local state are main frame standby host pattern/standby host, and when detecting that monitoring target does not start application service, described computer starts application service after performing described step S1-step S6.
When described default switch mode and local state are mainframe host computer pattern/main frame, and when detecting that monitoring target has started application service, described computer judges whether to receive the notice starting application service, is start application service after performing described step S1-step S6; Otherwise return the described judgement of execution and preset switch mode and local state.
When described default switch mode and local state are main frame standby host pattern/standby host, and when detecting that monitoring target has started application service, described computer stops application service after performing the operation of automatically deleting virtual IP address, then returns the described judgement of execution and presets switch mode and local state.
The operation of described automatic deletion virtual IP address specifically comprises:
Step s1: invocation facility driver forbids network interface card corresponding to described network interface card ID;
Step s2: invocation facility driver deletes virtual IP address corresponding with described network interface card descriptor in the registration table of network interface card corresponding to described network interface card ID and virtual IP address subnet mask, and the default flag bit more in new database;
Step s3: invocation facility driver enables network interface card corresponding to described network interface card ID.
Comprise after above-mentioned startup application service:
Step 1: the operation conditions detecting gateway and application service, if the normal gateway of application service is unimpeded, then returns the described judgement of execution and presets switch mode and local state; If the normal gateway of application service is not smooth, then stop application service after performing the operation of automatically deleting virtual IP address, then perform step 2; If the abnormal gateway of application service is not smooth, directly perform step 2; If the abnormal gateway of application service is unimpeded, restart application service, if start successfully, return and continue to perform step 1, if start unsuccessfully, perform step 2;
Step 2: judge that whether monitor target normally works, and is according to current monitoring daily record, returns the described judgement of execution and preset switch mode and local state, otherwise alarm is made mistakes, and terminates after the notice of monitoring target transmission startup application service.
The network interface card that invocation facility driver described in step S2 forbids described network interface card ID corresponding is specially: call the first function and to obtain on server erection unit information aggregate, call the second function to enumerate obtain the current information of erection unit to the information aggregate of erection unit obtained, call the detailed device information that the 3rd function obtains current erection unit; Call the 4th function and the installation parameter comprised in the details of current erection unit is revised as the first preset value and amendment is come into force by the 5th function; Call the 6th function release current memory.
Invocation facility driver described in step S4 deletes virtual IP address corresponding with described network interface card descriptor in the registration table of network interface card corresponding to described network interface card ID and virtual IP address subnet mask is specially: call the 7th function and the 8th function and obtain initial IP, initial IP subnet mask from the registration table of network interface card corresponding to described network interface card ID; Call the 9th function from initial IP, initial IP subnet mask, delete field corresponding to virtual IP address, virtual IP address subnet mask, and the registration table after deletion action is written back to the relevant position in registry key; Call the tenth function release current memory.
Invocation facility driver described in step S5 binds the virtual IP address that obtains from database on the network interface card that described network interface card ID is corresponding and virtual IP address subnet mask is specially: call the 7th function and the 8th function and obtain initial IP, initial IP subnet mask from the registration table of network interface card corresponding to described network interface card ID; Call the 9th function in the field of initial IP, initial IP subnet mask, bind the virtual IP address, the virtual IP address subnet mask that obtain from database, and the registration table after bindings is written back to the relevant position in registry key; Call the tenth function release current memory.
The network interface card that invocation facility driver described in step S6 enables described network interface card ID corresponding is specially: call the first function and to obtain on server erection unit information aggregate, call the second function to enumerate obtain the current information of erection unit to the information aggregate of erection unit obtained, call the detailed device information that the 3rd function obtains current erection unit; Call the 4th function and the installation parameter comprised in the details of current erection unit is revised as the second preset value and amendment is come into force by the 5th function; Call the 6th function release current memory.
The implementation method of another kind of virtual IP address disclosed by the invention, comprising:
Step S1: computer gets the network interface card ID bound with self IP from database according to self IP, obtains virtual IP address and virtual IP address subnet mask from database; Perform query configuration message command;
Step S2: judge that whether the configuration information of the network interface card that described network interface card ID is corresponding is correct according to the command execution results of described query configuration message command, be perform step S4, otherwise perform step S3;
Step S3: perform and stop virtual IP address order to delete virtual IP address in described configuration information and virtual IP address subnet mask, perform configuration order increases the virtual IP address and virtual IP address subnet mask that obtain from database in described configuration information, performs step S4;
Step S4: enter the configuration file under config directory, performs and checks profile command;
Step S5: whether correct according to the configuration information that the command execution results of described inspection profile command judges in configuration file, is terminate, otherwise performs step S6;
Step S6: perform delete command and delete described configuration file, perform write order under described config directory, re-write a configuration file, include the virtual IP address obtained from database and virtual IP address subnet mask in the configuration information of the configuration file re-write, terminate.
The described command execution results according to described query configuration message command judges whether the configuration information of the network interface card that described network interface card ID is corresponding is correctly specially: judge that whether the virtual IP address comprised in the command execution results of described query configuration message command is consistent with the virtual IP address obtained from database and virtual IP address subnet mask with virtual IP address subnet mask, represent that configuration information is correct, otherwise incorrect.
The beneficial effect that the present invention reaches is as follows: technical scheme provided by the invention compared with prior art, configured by automated manner and realize virtual IP address, eliminate manual operation, save human cost, technical scheme provided by the invention can be applied directly on server and realize virtual IP address by server self simultaneously, do not need third party device control realization, thus eliminate NAT device, reduce construction and the maintenance cost of whole digital communications network.By technical scheme provided by the invention, can adjust code according to specific needs, be with good expansibility.
Accompanying drawing explanation
In order to the clearer explanation embodiment of the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
Fig. 1 is the using method flow chart of implementation method under two-node cluster hot backup application scenarios of the virtual IP address that the embodiment of the present invention 1 provides;
Fig. 2-1 is that shown in Fig. 1, configuration realizes virtual IP address and starts the realization flow figure of application service under windows platform automatically;
Fig. 2-2 deletes virtual IP address and the realization flow figure stopping application service under windows platform shown in Fig. 1 automatically;
Fig. 3 is the flow chart of a kind of virtual IP address implementation method based on windows platform that the embodiment of the present invention 2 provides;
Fig. 4-1 is that shown in Fig. 1, configuration realizes virtual IP address and starts the realization flow figure of application service under Linux platform automatically;
Fig. 4-2 deletes virtual IP address and the realization flow figure stopping application service under Linux platform shown in Fig. 1 automatically.
Embodiment
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with accompanying drawing, embodiment of the present invention is described in further detail.
Virtual IP address can make a computer externally provide the IP address of multiple access, has given play to the advantage of VLAN, reasonable distribution Internet resources, balance network load, often can use the technology of virtual IP address when clustered deploy(ment), externally provides a virtual IP address access.
Embodiment 1
In order to have more deep understanding to the implementation method of a kind of virtual IP address provided by the invention, first in embodiment 1 the use of implementation method under two-node cluster hot backup application scenarios of the virtual IP address that the present invention proposes is described, as shown in Figure 1, specific as follows:
Step 101: start, starts timing heartbeat monitoring and real time record monitors daily record;
Step 102: judge to preset switch mode and local state, if mainframe host computer pattern/main frame then performs step 103, if main frame standby host pattern/main frame then performs step 107, if main frame standby host pattern/standby host then performs step 105;
Preferred in the present embodiment, shown default switch mode comprises mainframe host computer pattern, main frame standby host pattern and main frame standby host pattern, and described local state can be main frame or standby host.
Step 103: whether Anti-Sniffer target starts application service, is, performs step 104, otherwise perform step 107;
Step 104: judging whether to receive the notice starting application service, is perform step 107, otherwise performs step 102;
Step 105: whether Anti-Sniffer target starts application service, is, performs step 106, otherwise perform step 107;
Step 106: automatically delete virtual IP address, and stop application service, return step 102;
Step 107: configuration realizes virtual IP address automatically, starts application service;
Such as, the application service of startup is internet banking system or identity authorization system etc.
Step 108: the operation conditions detecting gateway and application service, if the normal gateway of application service is unimpeded, perform step 102, if the normal gateway of application service is not smooth, perform step 110, if the abnormal gateway of application service is unimpeded, perform step 109, if the abnormal gateway of application service is not smooth, perform step 111;
Step 109: restart application service, if start successfully, returns and performs step 108, if start unsuccessfully, performs step 111;
Step 110: automatically delete virtual IP address, and stop application service, perform step 111;
Step 111: judge that whether monitor target normally works, and be perform step 112, otherwise alarm is made mistakes, terminates according to current monitoring daily record;
Step 112: sending to monitoring target the notice starting application service, then returning step 102.
Described in step 107 in the two-node cluster hot backup scheme application that the present embodiment provides, configuration realizes virtual IP address automatically, starts the flow process of application service, in the specific implementation based on windows platform as shown in Fig. 2-1, comprises the following steps:
Step 201: get the network interface card ID and network interface card descriptor that bind with self IP according to self IP from database, obtain virtual IP address and virtual IP address subnet mask from database.
Step 202: invocation facility driver forbids network interface card corresponding to described network interface card ID;
Concrete in the present embodiment, described device driver mainly includes the first function, the second function, the 3rd function, the 4th function, the 5th function, the 6th function, the 7th function, the 8th function, the 9th function and the tenth function.
This step is concrete, realize by calling the first function, the second function, the 3rd function, the 4th function, the 5th function and the 6th function, wherein call the first function and can to obtain on server erection unit information aggregate, call the second function to enumerate obtain the current information of erection unit to the information aggregate of erection unit obtained, call the detailed device information that the 3rd function can obtain current erection unit; Call the 4th and the 5th function the installation parameter comprised in the details of current erection unit to be revised as the first preset value and amendment is come into force; Call the 6th function can discharge call the first function to the 5th function do and operate the internal memory that takies.
Step 203: judging whether to arrange virtual IP address according to the default flag bit in database, is perform step 204, otherwise perform step 205;
Preferred in the present embodiment, represent when default flag bit is 1 and virtual IP address has been set, represent when default flag bit is 0 and virtual IP address is not set.
Step 204: invocation facility driver deletes virtual IP address corresponding with described network interface card descriptor in the registration table of network interface card corresponding to described network interface card ID and virtual IP address subnet mask, then performs step 205;
This step is concrete, realizes by calling the 7th function, the 8th function, the 9th function and the tenth function, wherein calls the 7th and the 8th function and can obtain initial IP, initial IP subnet mask from the registration table of network interface card corresponding to described network interface card ID; Call the 9th function and can delete field corresponding to virtual IP address, virtual IP address subnet mask from initial IP, initial IP subnet mask, and the registration table after deletion action is written back to the relevant position in registry key; Call the tenth function can discharge call the 7th function to the 9th function do and operate the internal memory that takies.
Step 205: invocation facility driver binds the described virtual IP address and virtual IP address subnet mask that obtain from database on the network interface card that described network interface card ID is corresponding, and the default flag bit more in new database;
This step is concrete, realizes by calling the 7th function, the 8th function, the 9th function and the tenth function, wherein calls the 7th and the 8th function and can obtain initial IP, initial IP subnet mask from the registration table of network interface card corresponding to described network interface card ID; Call the 9th function and can bind the described virtual IP address, the virtual IP address subnet mask that obtain from database in the field of initial IP, initial IP subnet mask, and the registration table after bindings is written back to the relevant position in registry key; Call the tenth function can discharge call the 7th function to the 9th function do and operate the internal memory that takies.
Preferred in the present embodiment, this step is specially and default flag bit is set to 1.
Step 206: invocation facility driver enables network interface card corresponding to described network interface card ID.
This step is concrete, realize by calling the first function, the second function, the 3rd function, the 4th function, the 5th function and the 6th function, wherein call the first function and can to obtain on server erection unit information aggregate, call the second function to enumerate obtain the current information of erection unit to the information aggregate of erection unit obtained, call the detailed device information that the 3rd function can obtain current erection unit; Call the 4th and the 5th function the installation parameter comprised in the details of current erection unit to be revised as the second preset value and amendment is come into force; Call the 6th function can discharge call the first function to the 5th function do and operate the internal memory that takies.
Step 207: start application service.
Automatically delete virtual IP address described in step 106 in the two-node cluster hot backup scheme application that the present embodiment provides or step 110, and stop the flow process of application service, in the specific implementation based on windows platform as shown in Fig. 2-2, comprise the following steps:
Step 201': invocation facility driver forbids network interface card corresponding to described network interface card ID;
This step is concrete, realize by calling the first function, the second function, the 3rd function, the 4th function, the 5th function and the 6th function, wherein call the first function and can to obtain on server erection unit information aggregate, call the second function to enumerate obtain the current information of erection unit to the information aggregate of erection unit obtained, call the detailed device information that the 3rd function can obtain current erection unit; Call the 4th and the 5th function the installation parameter comprised in the details of current erection unit to be revised as the first preset value and amendment is come into force; Call the 6th function can discharge call the first function to the 5th function do and operate the internal memory that takies.
Step 202': invocation facility driver deletes virtual IP address corresponding with described network interface card descriptor in the registration table of network interface card corresponding to described network interface card ID and virtual IP address subnet mask, and the default flag bit more in new database;
This step is concrete, realizes by calling the 7th function, the 8th function, the 9th function and the tenth function, wherein calls the 7th and the 8th function and can obtain initial IP, initial IP subnet mask from the registration table of network interface card corresponding to described network interface card ID; Call the 9th function and can delete field corresponding to virtual IP address, virtual IP address subnet mask from initial IP, initial IP subnet mask, and the registration table after deletion action is written back to the relevant position in registry key; Call the tenth function can discharge call the 7th function to the 9th function do and operate the internal memory that takies.
Preferred in the present embodiment, this step is specially and default flag bit is set to 0.
Step 203': invocation facility driver enables network interface card corresponding to described network interface card ID.
This step is concrete, realize by calling the first function, the second function, the 3rd function, the 4th function, the 5th function and the 6th function, wherein call the first function and can to obtain on server erection unit information aggregate, call the second function to enumerate obtain the current information of erection unit to the information aggregate of erection unit obtained, call the detailed device information that the 3rd function can obtain current erection unit; Call the 4th and the 5th function the installation parameter comprised in the details of current erection unit to be revised as the second preset value and amendment is come into force; Call the 6th function can discharge call the first function to the 5th function do and operate the internal memory that takies.
Step 204': stop application service.
Embodiment 2
Be a kind of virtual IP address implementation method based on windows platform that the present embodiment 2 provides as shown in Figure 3, comprise following content:
Step 301: get the network interface card ID and network interface card descriptor that bind with this IP according to self IP from database;
Such as, self IP is 192.168.16.47.
Step 302: obtain virtual IP address and virtual IP address subnet mask from database;
Such as: virtual IP address is 192.168.25.200, virtual IP address subnet mask is 255.255.255.0.
Step 303: obtain the field value representing and whether virtual IP address has been set from database;
Such as: the field value got is flag.
Step 304: call SetupDiGetClassDevs function and obtain erection unit information aggregate;
Such as: the information aggregate of erection unit of acquisition is:
({650D5BB1-9BB4-45CD-90C8-ECE70B72EB35},
{E90A38FA-BA87-40F8-8BA9-B86F6852A9D3},
{4D36E96C-E325-11CE-BFC1-08002BE10318},
{4D36E96D-E325-11CE-BFC1-08002BE10318}
….)
Step 305: call SetupDiEnumDeviceInfo function enumerate described in erection unit information aggregate, obtain the current information of erection unit;
Such as: the current information of erection unit of acquisition is:
({650D5BB1-9BB4-45CD-90C8-ECE70B72EB35})。
Step 306: call SetupDiGetDeviceRegistryProperty function and obtain equipment details corresponding to the current information of erection unit;
Step 307: whether the descriptor comprised in more described equipment details is identical with the described network interface card descriptor obtained from database, is perform step 308, otherwise return execution step 305;
Step 308: call SetupDiSetClassInstallParams function and the installation parameter comprised in described equipment details is revised as the first preset value;
Concrete in the present embodiment, installation parameter is stateChange, and the first preset value is DICS_DISABLE.
Step 309: call SetupDiCallClassInstaller function and make to come into force to the amendment of installation parameter;
Step 310: call SetupDiDestroyDeviceInfoList function release current memory;
Concrete, destroy by calling SetupDiDestroyDeviceInfoList function the information aggregate of the erection unit release current memory obtained.
Step 311: judging whether to arrange virtual IP address according to described field value, is perform step 312, otherwise perform step 316;
Step 312: call RegOpenKeyEx function and open registry key corresponding to described network interface card descriptor;
Concrete, the registry key corresponding to described network interface card descriptor is: SYSTEM CurrentControlSet Services Tcpip Parameters Interfaces.
Step 313: call RegQueryValueEx function and obtain initial IP corresponding to described network interface card descriptor, initial IP subnet mask from registration table;
Such as: the initial IP of acquisition is 192.168.16.47 (192.168.25.200), and initial IP subnet mask is 255.255.255.0 (255.255.255.0).
Step 314: call RegSetValueEx function and delete field corresponding to virtual IP address, virtual IP address subnet mask from initial IP, initial IP subnet mask, and the IP after deletion action and subnet mask are written back to the relevant position in registry key;
Such as: the IP after deletion action and subnet mask are 192.168.16.47 and 255.255.255.0 respectively.
Step 315: call RegCloseKey function release current memory, perform step 316;
Concrete, by the registry key release current memory of release when front opening.
Step 316: call RegOpenKeyEx function and open registry key corresponding to described network interface card descriptor;
Step 317: call RegQueryValueEx function and obtain initial IP corresponding to described network interface card descriptor, initial IP subnet mask from registration table;
Step 318: call RegSetValueEx function and bind the described virtual IP address, the virtual IP address subnet mask that obtain from database in the field of initial IP, initial IP subnet mask, and the relevant position IP after bindings and subnet mask are written back in registry key, change described field value and in write into Databasce;
Such as, the IP after bindings is 192.168.16.47 (192.168.25.200), and subnet mask is 255.255.255.0 (255.255.255.0).
Step 319: call RegCloseKey function release current memory;
Concrete, by the registry key release current memory of release when front opening.
Step 320: call SetupDiGetClassDevs function and obtain erection unit information aggregate;
Step 321: call SetupDiEnumDeviceInfo function enumerate described in erection unit information aggregate, obtain the current information of erection unit;
Step 322: call SetupDiGetDeviceRegistryProperty function and obtain equipment details corresponding to the current information of erection unit;
Step 323: whether the descriptor comprised in more described equipment details is identical with the described network interface card descriptor obtained from database, is perform step 324, otherwise return execution step 321;
Step 324: call SetupDiSetClassInstallParams function and the installation parameter comprised in described equipment details is revised as the second preset value;
Concrete in the present embodiment, installation parameter is stateChange, and the second preset value is DICS_ENABLE.
Step 325: call SetupDiCallClassInstaller function and make to come into force to the amendment of installation parameter;
Step 326: call SetupDiDestroyDeviceInfoList function release current memory.
Concrete, destroy by calling SetupDiDestroyDeviceInfoList function the information aggregate of the erection unit release current memory obtained.
Embodiment 3
The present embodiment provides on the two-node cluster hot backup scheme basis that embodiment 1 provides, and wherein described in Fig. 1, configuration realizes virtual IP address automatically, starts the flow process of application service, in the specific implementation based on linux platform as shown in Fig. 4-1, comprise the following steps:
Step 401: get the network interface card ID bound with self IP according to self IP from database, obtains virtual IP address and virtual IP address subnet mask from database;
Such as, the network interface card ID of acquisition is eth0, and the virtual IP address of acquisition is 192.168.25.100, and the virtual IP address subnet mask of acquisition is 255.255.255.0.
Step 402: perform query configuration message command;
Such as: described query configuration message command is: ifconfig eth0:0.
Step 403: judge that whether the configuration information of the network interface card that described network interface card ID is corresponding is correct according to the command execution results of described query configuration message command, be perform step 405, otherwise perform step 404;
Such as, described command execution results is:
eth0:0 Link encap:Ethernet HWaddr 00:50:56:81:73:F3
inet addr:192.168.25.220 Bcast:192.168.25.100
Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500
Metric:1
Bcast:192.168.25.100 with Mask:255.255.255.0 in described command execution results is consistent with the virtual IP address obtained from database and virtual IP address subnet mask, then judged result is that the configuration information of described network interface card is correct.
Step 404: perform and stop virtual IP address order to delete virtual IP address in described configuration information and virtual IP address subnet mask, perform configuration order increases the described virtual IP address and virtual IP address subnet mask that obtain from database in described configuration information, performs step 405;
Such as, the described stopping virtual IP address order that corresponding to described network interface card ID network interface card performs is: ifconfgeth0:0 down.The described configuration order performed is: ifconfig eth0:0 192.168.25.100 netmask255.255.255.0up.
Step 405: enter the configuration file under config directory, performs and checks profile command;
Such as, the configuration file entered under config directory is specially fill order: cd/etc/sysconfig/network-scripts; The described inspection profile command performed is specially: moreifcfg-eth0:0.
Step 406: whether correct according to the configuration information that the command execution results of described inspection profile command judges in configuration file, is perform step 408, otherwise performs step 407:
Such as, the command execution results obtained after performing more ifcfg-eth0:0 is: DEVICE=eth0:0
BOOTPROTO=none
IPADDR=192.168.25.80
NETMASK=255.255.255.0
GATEWAY=192.168.25.254
HWADDR=00:50:56:81:73:f3
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
The IPADDR=192.168.25.80 comprised in mentioned order execution result is different from the virtual IP address=192.168.25.100 obtained from database, then perform step 407.
Step 407: perform delete command and delete described configuration file, perform write order under described config directory, re-write the configuration file that includes described virtual IP address and the virtual IP address subnet mask obtained from database in configuration information, perform step 408;
Such as, the described delete command of execution is specially: rm ifcfg-eth0:0; The said write order performed is specially:
vi ifcfg-eth0:0
DEVICE=eth0:0
BOOTPROTO=none
IPADDR=192.168.25.100
NETMASK=255.255.255.0
GATEWAY=192.168.25.254
HWADDR=00:50:56:81:73:f3
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
Step 408: start application service.
The present embodiment provides on the two-node cluster hot backup scheme basis that embodiment 1 provides, and wherein automatically deletes virtual IP address described in Fig. 1, stops the flow process of application service, in the specific implementation based on linux platform as shown in the Fig. 4-2, comprise the following steps:
Step 401': perform the virtual IP address in stopping virtual IP address order deletion configuration information and virtual IP address subnet mask;
Such as, the order of described stopping virtual IP address being specially: ifconfg eth0:0 down.
Step 402': enter the configuration file under config directory;
Such as, the configuration file under config directory is entered by fill order cd/etc/sysconfig/network-scripts.
Step 403': perform delete command and delete described configuration file;
Such as, the described delete command of execution is specially: rm ifcfg-eth0:0.
Step 404': stop application service.
Above-described embodiment is the present invention's more preferably embodiment, and the usual change that those skilled in the art carries out within the scope of technical solution of the present invention and replacement all should be included in protection scope of the present invention.

Claims (19)

1. an implementation method for virtual IP address, is characterized in that, comprising:
Step S1: computer gets the network interface card ID and network interface card descriptor that bind with self IP from database according to self IP, obtain virtual IP address and virtual IP address subnet mask from database;
Step S2: invocation facility driver forbids network interface card corresponding to described network interface card ID;
Step S3: judging whether to arrange virtual IP address according to the default flag bit in database, is perform step S4, otherwise perform step S5;
Step S4: invocation facility driver deletes virtual IP address corresponding with described network interface card descriptor in the registration table of network interface card corresponding to described network interface card ID and virtual IP address subnet mask, then performs step S5;
Step S5: invocation facility driver binds the virtual IP address and virtual IP address subnet mask that obtain from database on the network interface card that described network interface card ID is corresponding, and the default flag bit more in new database;
Step S6: invocation facility driver enables network interface card corresponding to described network interface card ID.
2. the method for claim 1, is characterized in that: also comprise step S0 before described step S1: computer starting timing heartbeat is monitored and real time record monitors daily record.
3. method as claimed in claim 2, it is characterized in that: also comprise between described step S0 and described step S1: computer judges to preset switch mode and local state, when described default switch mode and local state are main frame standby host pattern/main frame, described computer starts application service after performing described step S1-step S6;
When described default switch mode and local state are mainframe host computer pattern/main frame, and when detecting that monitoring target does not start application service, described computer starts application service after performing described step S1-step S6;
When described default switch mode and local state are main frame standby host pattern/standby host, and when detecting that monitoring target does not start application service, described computer starts application service after performing described step S1-step S6.
4. method as claimed in claim 3, it is characterized in that: when described default switch mode and local state are mainframe host computer pattern/main frame, and when detecting that monitoring target has started application service, described computer judges whether to receive the notice starting application service, is start application service after performing described step S1-step S6; Otherwise return the described judgement of execution and preset switch mode and local state.
5. method as claimed in claim 3, it is characterized in that: when described default switch mode and local state are main frame standby host pattern/standby host, and when detecting that monitoring target has started application service, described computer stops application service after performing the operation of automatically deleting virtual IP address, then returns the described judgement of execution and presets switch mode and local state.
6. method as claimed in claim 5, is characterized in that: the operation of described automatic deletion virtual IP address specifically comprises:
Step s1: invocation facility driver forbids network interface card corresponding to described network interface card ID;
Step s2: invocation facility driver deletes virtual IP address corresponding with described network interface card descriptor in the registration table of network interface card corresponding to described network interface card ID and virtual IP address subnet mask, and the default flag bit more in new database;
Step s3: invocation facility driver enables network interface card corresponding to described network interface card ID.
7. the method as described in claim 3 or 4, is characterized in that: comprise after described startup application service:
Step 1: the operation conditions detecting gateway and application service, if the normal gateway of application service is unimpeded, then returns the described judgement of execution and presets switch mode and local state; If the normal gateway of application service is not smooth, then stop application service after performing the operation of automatically deleting virtual IP address, then perform step 2; If the abnormal gateway of application service is not smooth, directly perform step 2; If the abnormal gateway of application service is unimpeded, restart application service, if start successfully, return and continue to perform step 1, if start unsuccessfully, perform step 2;
Step 2: judge that whether monitor target normally works, and is according to current monitoring daily record, returns the described judgement of execution and preset switch mode and local state, otherwise alarm is made mistakes, and terminates after the notice of monitoring target transmission startup application service.
8. the method for claim 1, it is characterized in that: the network interface card that invocation facility driver described in step S2 forbids described network interface card ID corresponding is specially: call the first function and to obtain on server erection unit information aggregate, call the second function to enumerate obtain the current information of erection unit to the information aggregate of erection unit obtained, call the detailed device information that the 3rd function obtains current erection unit; Call the 4th function and the installation parameter comprised in the details of current erection unit is revised as the first preset value and amendment is come into force by the 5th function; Call the 6th function release current memory.
9. the method for claim 1, is characterized in that: invocation facility driver described in step S4 deletes virtual IP address corresponding with described network interface card descriptor in the registration table of network interface card corresponding to described network interface card ID and virtual IP address subnet mask is specially: call the 7th function and the 8th function and obtain initial IP, initial IP subnet mask from the registration table of network interface card corresponding to described network interface card ID; Call the 9th function from initial IP, initial IP subnet mask, delete field corresponding to virtual IP address, virtual IP address subnet mask, and the registration table after deletion action is written back to the relevant position in registry key; Call the tenth function release current memory.
10. the method for claim 1, is characterized in that: invocation facility driver described in step S5 binds the virtual IP address that obtains from database on the network interface card that described network interface card ID is corresponding and virtual IP address subnet mask is specially: call the 7th function and the 8th function and obtain initial IP, initial IP subnet mask from the registration table of network interface card corresponding to described network interface card ID; Call the 9th function in the field of initial IP, initial IP subnet mask, bind the virtual IP address, the virtual IP address subnet mask that obtain from database, and the registration table after bindings is written back to the relevant position in registry key; Call the tenth function release current memory.
11. the method for claim 1, it is characterized in that: the network interface card that invocation facility driver described in step S6 enables described network interface card ID corresponding is specially: call the first function and to obtain on server erection unit information aggregate, call the second function to enumerate obtain the current information of erection unit to the information aggregate of erection unit obtained, call the detailed device information that the 3rd function obtains current erection unit; Call the 4th function and the installation parameter comprised in the details of current erection unit is revised as the second preset value and amendment is come into force by the 5th function; Call the 6th function release current memory.
The implementation method of 12. 1 kinds of virtual IP addresses, is characterized in that, comprising:
Step S1: computer gets the network interface card ID bound with self IP from database according to self IP, obtains virtual IP address and virtual IP address subnet mask from database; Perform query configuration message command;
Step S2: judge that whether the configuration information of the network interface card that described network interface card ID is corresponding is correct according to the command execution results of described query configuration message command, be perform step S4, otherwise perform step S3;
Step S3: perform and stop virtual IP address order to delete virtual IP address in described configuration information and virtual IP address subnet mask, perform configuration order increases the virtual IP address and virtual IP address subnet mask that obtain from database in described configuration information, performs step S4;
Step S4: enter the configuration file under config directory, performs and checks profile command;
Step S5: whether correct according to the configuration information that the command execution results of described inspection profile command judges in configuration file, is terminate, otherwise performs step S6;
Step S6: perform delete command and delete described configuration file, perform write order under described config directory, re-write a configuration file, include the virtual IP address obtained from database and virtual IP address subnet mask in the configuration information of the configuration file re-write, terminate.
13. methods as claimed in claim 12, it is characterized in that: described in step S2, judge whether the configuration information of the network interface card that described network interface card ID is corresponding is correctly specially according to the command execution results of described query configuration message command: judge that whether the virtual IP address comprised in the command execution results of described query configuration message command is consistent with the virtual IP address obtained from database and virtual IP address subnet mask with virtual IP address subnet mask, represent that configuration information is correct, otherwise incorrect.
14. methods as claimed in claim 12, is characterized in that: also comprise step S0 before described step S1: computer starting timing heartbeat is monitored and real time record monitors daily record.
15. methods as claimed in claim 14, it is characterized in that: also comprise between described step S0 and described step S1: computer judges to preset switch mode and local state, when described default switch mode and local state are main frame standby host pattern/main frame, described computer starts application service after performing described step S1-step S6;
When described default switch mode and local state are mainframe host computer pattern/main frame, and when detecting that monitoring target does not start application service, described computer starts application service after performing described step S1-step S6;
When described default switch mode and local state are main frame standby host pattern/standby host, and when detecting that monitoring target does not start application service, described computer starts application service after performing described step S1-step S6.
16. methods as claimed in claim 15, it is characterized in that: when described default switch mode and local state are mainframe host computer pattern/main frame, and when detecting that monitoring target has started application service, described computer judges whether to receive the notice starting application service, is start application service after performing described step S1-step S6; Otherwise return the described judgement of execution and preset switch mode and local state.
17. methods as claimed in claim 15, it is characterized in that: when described default switch mode and local state are main frame standby host pattern/standby host, and when detecting that monitoring target has started application service, described computer stops application service after performing the operation of automatically deleting virtual IP address, then returns the described judgement of execution and presets switch mode and local state.
18. methods as claimed in claim 17, is characterized in that: the operation of described automatic deletion virtual IP address specifically comprises:
Step s1: perform and stop virtual IP address order to delete virtual IP address in the configuration information of network interface card corresponding to described network interface card ID and virtual IP address subnet mask;
Step s2: enter the configuration file under config directory;
Step s3: perform delete command and delete described configuration file.
19. methods as described in claim 15 or 16, comprise after it is characterized in that described startup application service:
Step 1: the operation conditions detecting gateway and application service, if the normal gateway of application service is unimpeded, then returns the described judgement of execution and presets switch mode and local state; If the normal gateway of application service is not smooth, then stop application service after performing the operation of automatically deleting virtual IP address, then perform step 2; If the abnormal gateway of application service is not smooth, directly perform step 2; If the abnormal gateway of application service is unimpeded, restart application service, if start successfully, return and continue to perform step 1, if start unsuccessfully, perform step 2;
Step 2: judge that whether monitor target normally works, and is according to current monitoring daily record, returns the described judgement of execution and preset switch mode and local state, otherwise alarm is made mistakes, and terminates after the notice of monitoring target transmission startup application service.
CN201410749176.7A 2014-12-09 2014-12-09 A kind of implementation method of virtual IP address Active CN104378449B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410749176.7A CN104378449B (en) 2014-12-09 2014-12-09 A kind of implementation method of virtual IP address

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410749176.7A CN104378449B (en) 2014-12-09 2014-12-09 A kind of implementation method of virtual IP address

Publications (2)

Publication Number Publication Date
CN104378449A true CN104378449A (en) 2015-02-25
CN104378449B CN104378449B (en) 2017-07-14

Family

ID=52557095

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410749176.7A Active CN104378449B (en) 2014-12-09 2014-12-09 A kind of implementation method of virtual IP address

Country Status (1)

Country Link
CN (1) CN104378449B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106878068A (en) * 2017-01-24 2017-06-20 新华三技术有限公司 A kind of configuring management method and device
CN112165537A (en) * 2020-09-17 2021-01-01 广州锦行网络科技有限公司 Virtual IP method for ping reply
CN113497765A (en) * 2021-09-08 2021-10-12 中兴通讯股份有限公司 Method and device for route management, electronic equipment and storage medium
CN114006955A (en) * 2021-10-28 2022-02-01 深信服科技股份有限公司 Data processing method, device and equipment and readable storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060087962A1 (en) * 2004-10-27 2006-04-27 Anthony Golia Fault tolerant network architecture
US20080098407A1 (en) * 2003-03-21 2008-04-24 Torrant Marc D System and method for managing distributed objects as a single representation
US20090300218A1 (en) * 2008-05-30 2009-12-03 Asustek Computer Inc. Network sharing method
CN103312661A (en) * 2012-03-07 2013-09-18 腾讯科技(深圳)有限公司 Method and device for service accessing
CN103491000A (en) * 2013-09-17 2014-01-01 烽火通信科技股份有限公司 System and method for management of virtual IPs and MACs of virtual router redundancy protocol
CN103685608A (en) * 2013-12-24 2014-03-26 北京启明星辰信息技术股份有限公司 Method and device for automatically configuring IP (Internet Protocol) address of security virtual machine
CN103731514A (en) * 2013-12-29 2014-04-16 国云科技股份有限公司 Virtual network management method
CN103812704A (en) * 2014-02-25 2014-05-21 国云科技股份有限公司 Public network IP (Internet Protocol) dynamic management method for virtual machine

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080098407A1 (en) * 2003-03-21 2008-04-24 Torrant Marc D System and method for managing distributed objects as a single representation
US20060087962A1 (en) * 2004-10-27 2006-04-27 Anthony Golia Fault tolerant network architecture
US20090300218A1 (en) * 2008-05-30 2009-12-03 Asustek Computer Inc. Network sharing method
CN103312661A (en) * 2012-03-07 2013-09-18 腾讯科技(深圳)有限公司 Method and device for service accessing
CN103491000A (en) * 2013-09-17 2014-01-01 烽火通信科技股份有限公司 System and method for management of virtual IPs and MACs of virtual router redundancy protocol
CN103685608A (en) * 2013-12-24 2014-03-26 北京启明星辰信息技术股份有限公司 Method and device for automatically configuring IP (Internet Protocol) address of security virtual machine
CN103731514A (en) * 2013-12-29 2014-04-16 国云科技股份有限公司 Virtual network management method
CN103812704A (en) * 2014-02-25 2014-05-21 国云科技股份有限公司 Public network IP (Internet Protocol) dynamic management method for virtual machine

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
岳建辉等: "VIP: 集群环境下面向高可靠和高性能的通信", 《小型微型计算机系统》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106878068A (en) * 2017-01-24 2017-06-20 新华三技术有限公司 A kind of configuring management method and device
CN106878068B (en) * 2017-01-24 2020-05-12 新华三技术有限公司 Configuration management method and device
CN112165537A (en) * 2020-09-17 2021-01-01 广州锦行网络科技有限公司 Virtual IP method for ping reply
CN112165537B (en) * 2020-09-17 2021-08-27 广州锦行网络科技有限公司 Virtual IP method for ping reply
CN113497765A (en) * 2021-09-08 2021-10-12 中兴通讯股份有限公司 Method and device for route management, electronic equipment and storage medium
CN114006955A (en) * 2021-10-28 2022-02-01 深信服科技股份有限公司 Data processing method, device and equipment and readable storage medium
CN114006955B (en) * 2021-10-28 2023-09-05 深信服科技股份有限公司 Data processing method, device, equipment and readable storage medium

Also Published As

Publication number Publication date
CN104378449B (en) 2017-07-14

Similar Documents

Publication Publication Date Title
US11323307B2 (en) Method and system of a dynamic high-availability mode based on current wide area network connectivity
DE112016006080B4 (en) MANAGEMENT OF VIRTUAL DESKTOP INSTANCE POOLS
CN110611588B (en) Network creation method, server, computer readable storage medium and system
EP1780940B1 (en) High availability network systems
CN108234158B (en) VNF establishment method, NFVO and network system
CN110086652B (en) Management system and method for service network element in 5G core network
CN105099789A (en) Network element uploading method and equipment
US6651093B1 (en) Dynamic virtual local area network connection process
CN106657354A (en) Load balancing device and method
RU2533638C2 (en) Data configuration method and device
CN104503965A (en) High-elasticity high availability and load balancing realization method of PostgreSQL (Structured Query Language)
CN104378449A (en) Virtual IP realization method
CN114070723B (en) Virtual network configuration method and system of bare metal server and intelligent network card
CN112583648B (en) Intelligent service fault processing method based on DNS
CN110635928B (en) Control method, control device and computer storage medium
US10419392B2 (en) Method, device and system for implementing address sharing
CN103825868A (en) Method for local voice escape, local gateway and system thereof
CN104618522A (en) Automatic updating method for IP address of terminal and Ethernet access device
CN107911496A (en) A kind of VPN service terminal acts on behalf of the method and device of DNS
DE102021107655A1 (en) LOG MANAGEMENT FOR A MULTI-NODE DATA PROCESSING SYSTEM
US10348521B2 (en) Distributed gateways
CN110768981A (en) Remote maintenance method for handset
CN107302600A (en) The implementation method and device of a kind of distributed FTP service
CN114785761B (en) Advanced k8s cluster intercommunication method in Internet of things operating system
CN117271064A (en) Virtual machine management method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant