CN104378449A - Virtual IP realization method - Google Patents
Virtual IP realization method Download PDFInfo
- 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
- application service
- network interface
- address
- interface card
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 40
- 230000006870 function Effects 0.000 claims abstract description 152
- 238000012544 monitoring process Methods 0.000 claims description 25
- 238000009434 installation Methods 0.000 claims description 14
- 230000002159 abnormal effect Effects 0.000 claims description 6
- 238000012217 deletion Methods 0.000 claims description 5
- 230000037430 deletion Effects 0.000 claims description 5
- 230000027455 binding Effects 0.000 claims description 4
- 238000009739 binding Methods 0.000 claims description 4
- 230000005540 biological transmission Effects 0.000 claims 2
- 238000007689 inspection Methods 0.000 claims 1
- 238000004891 communication Methods 0.000 abstract description 6
- 230000000694 effects Effects 0.000 description 8
- 238000012986 modification Methods 0.000 description 8
- 230000004048 modification Effects 0.000 description 8
- 230000008569 process Effects 0.000 description 4
- 238000010276 construction Methods 0.000 description 2
- 238000012423 maintenance Methods 0.000 description 2
- 238000013515 script Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明公开了一种虚拟IP的实现方法,属于计算机通信网络技术领域,该方法包括计算机根据自身IP从数据库中获取到与自身IP绑定的网卡ID与网卡描述信息,从数据库中获取虚拟IP和虚拟IP子网掩码,通过调用设备驱动程序禁用所述网卡ID对应的网卡,然后通过调用驱动程序在所述网卡ID对应的网卡上绑定从数据库中获取的虚拟IP和虚拟IP子网掩码,或者删除所述网卡ID对应的网卡的注册表中与所述网卡描述信息对应的虚拟IP和虚拟IP子网掩码,然后再通过调用设备驱动程序启用所述网卡ID对应的网卡,从而实现由计算机自身实现虚拟IP增加、删除等功能,省去了人工操作,节约了人力成本。
The invention discloses a method for realizing a virtual IP, which belongs to the technical field of computer communication networks. The method comprises that the computer obtains the network card ID and network card description information bound to its own IP from a database according to its own IP, and obtains the virtual IP from the database. and the virtual IP subnet mask, disable the network card corresponding to the network card ID by calling the device driver, and then bind the virtual IP and virtual IP subnet obtained from the database on the network card corresponding to the network card ID by calling the driver mask, or delete the virtual IP and virtual IP subnet mask corresponding to the network card description information in the registry of the network card corresponding to the network card ID, and then enable the network card corresponding to the network card ID by calling the device driver, In this way, functions such as adding and deleting virtual IPs can be realized by the computer itself, which saves manual operations and saves labor costs.
Description
技术领域technical field
本发明涉及计算机通信网络技术领域,尤其涉及一种虚拟IP的实现方法。The invention relates to the technical field of computer communication networks, in particular to a virtual IP implementation method.
背景技术Background technique
在计算机机群系统中,实现业务的高可用服务主要是通过增加结点,来使多个结点工作在负荷分担方式下或主备用方式下,当主用结点故障时,备用结点接替主用结点继续提供服务。由于数字通信网络向全IP网络的演变,使得结点的通信方式主要是基于IP的通信。当主用结点故障时,访问主用结点的客户端会继续向主用结点的IP地址索取服务,这就要求备用结点接替主用结点时以同样的IP地址提供服务,这样将多个结点共用一个IP地址对外提供服务的方法称为虚拟IP(VIP)。In the computer cluster system, the high availability service of the business is mainly achieved by adding nodes to make multiple nodes work in the load sharing mode or the active standby mode. When the active node fails, the standby node takes over the active The node continues to provide services. Due to the evolution of the digital communication network to an all-IP network, the communication mode of nodes is mainly based on IP communication. When the active node fails, the client accessing the active node will continue to request services from the IP address of the active node, which requires the standby node to provide services with the same IP address when taking over from the active node. The method that multiple nodes share one IP address to provide external services is called virtual IP (VIP).
现有的虚拟IP的实现方法,以多台服务器组成的计算机集群系统为例,多是通过人工手动配置虚拟IP实现的,这样的实现方式耗费人力成本;现有的虚拟IP实现方法还有是通过增加网络地址转换(NAT)设备对多个服务器的IP地址进行转换,使得多个服务器对外呈现一个统一的IP地址,这样的实现方式需要增加一个专门的NAT设备,增加了网络建设和维护成本。目前没有一种比较切实可行的由服务器自身实现虚拟IP增加、删除等功能的方法。Existing virtual IP implementation methods, taking a computer cluster system composed of multiple servers as an example, are mostly implemented through manual configuration of virtual IP, which consumes labor costs; the existing virtual IP implementation methods also have By adding a network address translation (NAT) device to convert the IP addresses of multiple servers, so that multiple servers present a unified IP address to the outside world, this implementation requires adding a special NAT device, which increases the cost of network construction and maintenance . At present, there is no more feasible method for the server itself to implement functions such as adding and deleting virtual IPs.
发明内容Contents of the invention
为解决现有技术中存在的问题,本发明提出了一种虚拟IP的实现方法,由服务器自身实现虚拟IP增加、删除等功能,服务器之间共享一个数据库存储虚拟IP,服务器自身实现虚拟IP的增加与删除,不需要借助另外的硬件存储设备对服务器虚拟IP的配置进行控制。In order to solve the problems existing in the prior art, the present invention proposes a method for realizing virtual IP. The server itself realizes functions such as adding and deleting virtual IP, a database is shared between servers to store virtual IP, and the server itself realizes the function of virtual IP. Addition and deletion do not need to use additional hardware storage devices to control the configuration of the server virtual IP.
本发明采用的技术方案如下:一种虚拟IP的实现方法,包括:The technical scheme that the present invention adopts is as follows: a kind of realization method of virtual IP, comprises:
步骤S1:计算机根据自身IP从数据库中获取到与自身IP绑定的网卡ID和网卡描述信息,从数据库中获取虚拟IP和虚拟IP子网掩码;Step S1: The computer obtains the network card ID and network card description information bound to its own IP from the database according to its own IP, and obtains the virtual IP and virtual IP subnet mask from the database;
步骤S2:调用设备驱动程序禁用所述网卡ID对应的网卡;Step S2: calling the device driver to disable the network card corresponding to the network card ID;
步骤S3:根据数据库中的预设标志位判断是否已设置虚拟IP,是则执行步骤S4,否则执行步骤S5;Step S3: judge whether the virtual IP has been set according to the preset flag in the database, if yes, execute step S4, otherwise execute step S5;
步骤S4:调用设备驱动程序删除所述网卡ID对应的网卡的注册表中与所述网卡描述信息对应的虚拟IP和虚拟IP子网掩码,然后执行步骤S5;Step S4: calling the device driver to delete the virtual IP and virtual IP subnet mask corresponding to the network card description information in the registry of the network card corresponding to the network card ID, and then perform step S5;
步骤S5:调用设备驱动程序在所述网卡ID对应的网卡上绑定从数据库中获取的虚拟IP和虚拟IP子网掩码,并更新数据库中的预设标志位;Step S5: call the device driver to bind the virtual IP and virtual IP subnet mask obtained from the database on the network card corresponding to the network card ID, and update the preset flag in the database;
步骤S6:调用设备驱动程序启用所述网卡ID对应的网卡。Step S6: calling the device driver to enable the network card corresponding to the network card ID.
所述步骤S1之前还包括步骤S0:计算机启动定时心跳监听并实时记录监听日志。Step S0 is also included before the step S1: the computer starts the regular heartbeat monitoring and records the monitoring log in real time.
所述步骤S0与所述步骤S1之间还包括:计算机判断预设切换模式及本机状态,当所述预设切换模式及本机状态为主机备机模式/主机时,所述计算机执行所述步骤S1-步骤S6之后启动应用服务;当所述预设切换模式及本机状态为主机主机模式/主机,且检测到监听目标未启动应用服务时,所述计算机执行所述步骤S1-步骤S6之后启动应用服务;当所述预设切换模式及本机状态为主机备机模式/备机,且检测到监听目标未启动应用服务时,所述计算机执行所述步骤S1-步骤S6之后启动应用服务。Between the step S0 and the step S1, it also includes: the computer judges the preset switching mode and the state of the machine, and when the preset switching mode and the state of the machine are the main machine standby mode/main machine, the computer executes the Start the application service after the above step S1-step S6; when the preset switching mode and the state of the machine are host host mode/host, and it is detected that the monitoring target has not started the application service, the computer executes the step S1-step Start the application service after S6; when the preset switching mode and the state of the machine are the main machine standby mode/standby machine, and when it is detected that the monitoring target has not started the application service, the computer starts after performing the steps S1-Step S6 application services.
当所述预设切换模式及本机状态为主机主机模式/主机,且检测到监听目标已启动应用服务时,所述计算机判断是否接收到启动应用服务的通知,是则执行所述步骤S1-步骤S6之后启动应用服务;否则返回执行所述判断预设切换模式及本机状态。When the preset switching mode and the state of the machine are host mode/host, and it is detected that the monitoring target has started the application service, the computer determines whether the notification of starting the application service has been received, and if so, executes the step S1- Start the application service after step S6; otherwise, return to execute the judgment of the preset switching mode and the state of the machine.
当所述预设切换模式及本机状态为主机备机模式/备机,且检测到监听目标已启动应用服务时,所述计算机执行自动删除虚拟IP的操作后停止应用服务,然后返回执行所述判断预设切换模式及本机状态。When the preset switching mode and the state of the machine are the main machine standby mode/standby machine, and when it is detected that the monitoring target has started the application service, the computer executes the operation of automatically deleting the virtual IP and then stops the application service, and then returns to execute the Describe the judgment of the preset switching mode and the status of the machine.
所述自动删除虚拟IP的操作具体包括:The operation of automatically deleting the virtual IP specifically includes:
步骤s1:调用设备驱动程序禁用所述网卡ID对应的网卡;Step s1: calling the device driver to disable the network card corresponding to the network card ID;
步骤s2:调用设备驱动程序删除所述网卡ID对应的网卡的注册表中与所述网卡描述信息对应的虚拟IP和虚拟IP子网掩码,并更新数据库中的预设标志位;Step s2: calling the device driver to delete the virtual IP and virtual IP subnet mask corresponding to the description information of the network card in the registry of the network card corresponding to the network card ID, and updating the preset flag in the database;
步骤s3:调用设备驱动程序启用所述网卡ID对应的网卡。Step s3: calling the device driver to enable the network card corresponding to the network card ID.
上述启动应用服务之后包括:After the above startup application service includes:
步骤1:检测网关和应用服务的运行状况,若应用服务正常网关畅通,则返回执行所述判断预设切换模式及本机状态;若应用服务正常网关不畅通,则执行自动删除虚拟IP的操作后停止应用服务,然后执行步骤2;若应用服务异常网关不畅通则直接执行步骤2;若应用服务异常网关畅通则重新启动应用服务,若启动成功则返回继续执行步骤1,若启动失败则执行步骤2;Step 1: detect the operation status of gateway and application service, if the normal gateway of application service is unimpeded, then return to carry out described judgment preset switching mode and local state; If the normal gateway of application service is not unimpeded, then carry out the operation of automatically deleting virtual IP Then stop the application service, and then perform step 2; if the application service is abnormal and the gateway is not smooth, then directly perform step 2; if the application service is abnormal and the gateway is unblocked, restart the application service, if the startup is successful, return to step 1, and if the startup fails, execute Step 2;
步骤2:根据当前的监听日志判断监听目标是否正常工作,是则向监听目标发送启动应用服务的通知后返回执行所述判断预设切换模式及本机状态,否则报警提示出错,结束。Step 2: Judging whether the monitoring target is working normally according to the current monitoring log, if so, send a notification to the monitoring target to start the application service and then return to execute the judgment of the preset switching mode and the state of the machine, otherwise the alarm prompts an error and ends.
步骤S2所述调用设备驱动程序禁用所述网卡ID对应的网卡具体为:调用第一函数获取服务器上已安装设备信息集合,调用第二函数对获取的已安装设备信息集合进行枚举得到一个当前已安装设备信息,调用第三函数获取当前已安装设备的详细设备信息;调用第四函数和第五函数将当前已安装设备的详细信息中包含的安装参数修改为第一预设值并使修改生效;调用第六函数释放当前内存。In step S2, calling the device driver to disable the network card corresponding to the network card ID is as follows: calling the first function to obtain the installed device information set on the server, calling the second function to enumerate the obtained installed device information set to obtain a current Installed device information, call the third function to obtain the detailed device information of the currently installed device; call the fourth function and the fifth function to modify the installation parameters contained in the detailed information of the currently installed device to the first preset value and make the modification Take effect; call the sixth function to release the current memory.
步骤S4所述调用设备驱动程序删除所述网卡ID对应的网卡的注册表中与所述网卡描述信息对应的虚拟IP和虚拟IP子网掩码具体为:调用第七函数和第八函数从所述网卡ID对应的网卡的注册表中获取原始IP、原始IP子网掩码;调用第九函数从原始IP、原始IP子网掩码中删除虚拟IP、虚拟IP子网掩码对应的字段,并将删除操作后的注册表回写到注册表键中的相应位置;调用第十函数释放当前内存。Step S4 described invoking the device driver to delete the virtual IP and virtual IP subnet mask corresponding to the network card description information in the registry of the network card corresponding to the network card ID is specifically: calling the seventh function and the eighth function from the Obtain the original IP and the original IP subnet mask in the registration form of the network card corresponding to the network card ID; call the ninth function to delete the corresponding field of the virtual IP and the virtual IP subnet mask from the original IP and the original IP subnet mask, And write back the registry after the delete operation to the corresponding position in the registry key; call the tenth function to release the current memory.
步骤S5所述调用设备驱动程序在所述网卡ID对应的网卡上绑定从数据库中获取的虚拟IP和虚拟IP子网掩码具体为:调用第七函数和第八函数从所述网卡ID对应的网卡的注册表中获取原始IP、原始IP子网掩码;调用第九函数在原始IP、原始IP子网掩码的字段中绑定从数据库中获取的虚拟IP、虚拟IP子网掩码,并将绑定操作后的注册表回写到注册表键中的相应位置;调用第十函数释放当前内存。In step S5, the calling device driver program binds the virtual IP and the virtual IP subnet mask obtained from the database on the network card corresponding to the network card ID as follows: calling the seventh function and the eighth function corresponding to the network card ID Obtain the original IP and original IP subnet mask from the registry of the network card; call the ninth function to bind the virtual IP and virtual IP subnet mask obtained from the database in the original IP and original IP subnet mask fields , and write back the registry key after the binding operation to the corresponding position in the registry key; call the tenth function to release the current memory.
步骤S6所述调用设备驱动程序启用所述网卡ID对应的网卡具体为:调用第一函数获取服务器上已安装设备信息集合,调用第二函数对获取的已安装设备信息集合进行枚举得到一个当前已安装设备信息,调用第三函数获取当前已安装设备的详细设备信息;调用第四函数和第五函数将当前已安装设备的详细信息中包含的安装参数修改为第二预设值并使修改生效;调用第六函数释放当前内存。In step S6, calling the device driver to enable the network card corresponding to the network card ID is as follows: calling the first function to obtain the installed device information set on the server, and calling the second function to enumerate the obtained installed device information set to obtain a current Installed device information, call the third function to obtain the detailed device information of the currently installed device; call the fourth function and the fifth function to modify the installation parameters contained in the detailed information of the currently installed device to the second preset value and make the modification Take effect; call the sixth function to release the current memory.
本发明公开的另一种虚拟IP的实现方法,包括:Another virtual IP implementation method disclosed by the present invention includes:
步骤S1:计算机根据自身IP从数据库中获取到与自身IP绑定的网卡ID,从数据库中获取虚拟IP和虚拟IP子网掩码;执行查询配置信息命令;Step S1: The computer obtains the network card ID bound to its own IP from the database according to its own IP, and obtains the virtual IP and virtual IP subnet mask from the database; executes the query configuration information command;
步骤S2:根据所述查询配置信息命令的命令执行结果判断所述网卡ID对应的网卡的配置信息是否正确,是则执行步骤S4,否则执行步骤S3;Step S2: judging whether the configuration information of the network card corresponding to the network card ID is correct according to the command execution result of the query configuration information command, if yes, perform step S4, otherwise perform step S3;
步骤S3:执行停止虚拟IP命令删除所述配置信息中的虚拟IP和虚拟IP子网掩码,执行配置命令在所述配置信息中增加从数据库中获取的虚拟IP和虚拟IP子网掩码,执行步骤S4;Step S3: Execute the stop virtual IP command to delete the virtual IP and virtual IP subnet mask in the configuration information, execute the configuration command to increase the virtual IP and virtual IP subnet mask obtained from the database in the configuration information, Execute step S4;
步骤S4:进入配置目录下的配置文件,执行检查配置文件命令;Step S4: enter the configuration file in the configuration directory, and execute the command to check the configuration file;
步骤S5:根据所述检查配置文件命令的命令执行结果判断配置文件中的配置信息是否正确,是则结束,否则执行步骤S6;Step S5: judge whether the configuration information in the configuration file is correct according to the command execution result of the check configuration file command, if yes, end, otherwise execute step S6;
步骤S6:执行删除命令删除所述配置文件,执行写入命令在所述配置目录下重新写入一个配置文件,重新写入的配置文件的配置信息中包含有从数据库中获取的虚拟IP和虚拟IP子网掩码,结束。Step S6: Execute the delete command to delete the configuration file, execute the write command to rewrite a configuration file in the configuration directory, and the configuration information of the rewritten configuration file includes the virtual IP and virtual IP obtained from the database. IP subnet mask, end.
所述根据所述查询配置信息命令的命令执行结果判断所述网卡ID对应的网卡的配置信息是否正确具体为:判断所述查询配置信息命令的命令执行结果中包含的虚拟IP和虚拟IP子网掩码是否与从数据库中获取的虚拟IP和虚拟IP子网掩码一致,是则表示配置信息正确,否则不正确。The judging whether the configuration information of the network card corresponding to the network card ID according to the command execution result of the query configuration information command is correct is specifically: judging the virtual IP and virtual IP subnet contained in the command execution result of the query configuration information command Whether the mask is consistent with the virtual IP and virtual IP subnet mask obtained from the database, if yes, the configuration information is correct, otherwise it is incorrect.
本发明达到的有益效果如下:本发明提供的技术方案与现有技术相比,通过自动方式配置并实现虚拟IP,省去了人工操作,节约了人力成本,同时本发明提供的技术方案可直接应用到服务器上由服务器自身实现虚拟IP,不需要第三方设备控制实现,从而省去了NAT设备,降低了整个数字通信网络的建设和维护成本。通过本发明提供的技术方案,可根据具体需要对代码进行调整,具有良好的可扩展性。The beneficial effects achieved by the present invention are as follows: compared with the prior art, the technical solution provided by the present invention configures and realizes virtual IP in an automatic manner, which saves manual operation and saves labor costs. At the same time, the technical solution provided by the present invention can directly When applied to the server, the virtual IP is realized by the server itself, without the need for third-party device control and implementation, thereby eliminating the need for NAT devices and reducing the construction and maintenance costs of the entire digital communication network. Through the technical solution provided by the invention, the code can be adjusted according to specific needs, and has good scalability.
附图说明Description of drawings
为了更清楚的说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单的介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. Those skilled in the art can also obtain other drawings based on these drawings without creative work.
图1是本发明实施例1提供的虚拟IP的实现方法在双机热备应用场景下的使用方法流程图;Fig. 1 is the flow chart of the implementation method of the virtual IP provided by Embodiment 1 of the present invention in the dual-system hot standby application scenario;
图2-1是图1所示自动配置实现虚拟IP并启动应用服务在Windows平台下的实现流程图;Figure 2-1 is the flow chart of the automatic configuration shown in Figure 1 to realize the virtual IP and start the application service under the Windows platform;
图2-2是图1所示自动删除虚拟IP并停止应用服务在Windows平台下的实现流程图;Figure 2-2 is a flow chart of automatically deleting the virtual IP and stopping the application service shown in Figure 1 under the Windows platform;
图3是本发明实施例2提供的一种基于Windows平台的虚拟IP实现方法的流程图;Fig. 3 is a flow chart of a method for implementing a virtual IP based on the Windows platform provided by Embodiment 2 of the present invention;
图4-1是图1所示自动配置实现虚拟IP并启动应用服务在Linux平台下的实现流程图;Figure 4-1 is the implementation flow chart of the automatic configuration shown in Figure 1 to realize the virtual IP and start the application service under the Linux platform;
图4-2是图1所示自动删除虚拟IP并停止应用服务在Linux平台下的实现流程图。Figure 4-2 is a flow chart of the implementation of automatically deleting the virtual IP and stopping the application service shown in Figure 1 under the Linux platform.
具体实施方式Detailed ways
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式做进一步详细描述。In order to make the object, technical solution and advantages of the present invention clearer, the following will further describe in detail the embodiments of the present invention in conjunction with the accompanying drawings.
虚拟IP可以使一台计算机对外提供多个访问的IP地址,发挥出VLAN的优势,合理分配网络资源,均衡网络负载,在集群部署的时候常会使用到虚拟IP的技术,对外提供一个虚拟IP访问。Virtual IP can enable a computer to provide multiple access IP addresses to the outside world, give full play to the advantages of VLAN, reasonably allocate network resources, and balance network loads. Virtual IP technology is often used in cluster deployment to provide a virtual IP access to the outside world. .
实施例1Example 1
为了对本发明提供的一种虚拟IP的实现方法有更深入的理解,首先在实施例1中对本发明提出的虚拟IP的实现方法在双机热备应用场景下的使用进行说明,如图1所示,具体如下:In order to have a deeper understanding of the implementation method of a virtual IP provided by the present invention, first, in Embodiment 1, the use of the implementation method of the virtual IP proposed by the present invention in the dual-machine hot standby application scenario is described, as shown in Figure 1 , the details are as follows:
步骤101:开机,启动定时心跳监听并实时记录监听日志;Step 101: start the machine, start the regular heartbeat monitoring and record the monitoring log in real time;
步骤102:判断预设切换模式及本机状态,若为主机主机模式/主机则执行步骤103,若为主机备机模式/主机则执行步骤107,若为主机备机模式/备机则执行步骤105;Step 102: Determine the preset switching mode and the state of the machine. If it is the master host mode/master, go to step 103; if it is the master backup mode/master, go to step 107; if it is the master backup mode/standby, go to step 105;
本实施例中优选的,所示预设切换模式包括主机主机模式、主机备机模式和主机备机模式,所述本机状态可以为主机或备机。In this embodiment, preferably, the preset switching modes shown include host host mode, host standby mode, and host standby mode, and the state of the local machine can be host or standby.
步骤103:检测监听目标是否已经启动应用服务,是则执行步骤104,否则执行步骤107;Step 103: Detect whether the listening target has started the application service, if yes, execute step 104, otherwise execute step 107;
步骤104:判断是否接收到启动应用服务的通知,是则执行步骤107,否则执行步骤102;Step 104: Judging whether the notification of starting the application service has been received, if yes, execute step 107, otherwise execute step 102;
步骤105:检测监听目标是否已经启动应用服务,是则执行步骤106,否则执行步骤107;Step 105: Detect whether the listening target has started the application service, if yes, execute step 106, otherwise execute step 107;
步骤106:自动删除虚拟IP,并停止应用服务,返回步骤102;Step 106: automatically delete the virtual IP, and stop the application service, return to step 102;
步骤107:自动配置实现虚拟IP,启动应用服务;Step 107: Automatic configuration to realize virtual IP, start application service;
例如,启动的应用服务为网银系统或身份认证系统等。For example, the started application service is an online banking system or an identity authentication system.
步骤108:检测网关和应用服务的运行状况,若应用服务正常网关畅通则执行步骤102,若应用服务正常网关不畅通则执行步骤110,若应用服务异常网关畅通则执行步骤109,若应用服务异常网关不畅通则执行步骤111;Step 108: Detect the operation status of the gateway and application service. If the application service is normal and the gateway is unblocked, then execute step 102. If the application service is normal and the gateway is not unblocked, then execute step 110. If the gateway is unblocked, step 111 is performed;
步骤109:重新启动应用服务,若启动成功则返回执行步骤108,若启动失败则执行步骤111;Step 109: Restart the application service, if the startup is successful, return to step 108, and if the startup fails, go to step 111;
步骤110:自动删除虚拟IP,并停止应用服务,执行步骤111;Step 110: automatically delete the virtual IP, and stop the application service, go to step 111;
步骤111:根据当前的监听日志判断监听目标是否正常工作,是则执行步骤112,否则报警提示出错,结束;Step 111: judge whether the monitoring target is working normally according to the current monitoring log, if yes, execute step 112; otherwise, an alarm prompts an error and ends;
步骤112:向监听目标发送启动应用服务的通知,然后返回步骤102。Step 112 : Send a notification of starting the application service to the listening target, and then return to step 102 .
本实施例提供的双机热备方案应用中的步骤107所述自动配置实现虚拟IP,启动应用服务的流程,在基于Windows平台的具体实现如图2-1所示,包括以下步骤:The automatic configuration in step 107 of the application of the dual-machine hot standby solution provided by this embodiment realizes the virtual IP and starts the process of the application service. The specific implementation based on the Windows platform is shown in Figure 2-1, including the following steps:
步骤201:根据自身IP从数据库中获取到与自身IP绑定的网卡ID和网卡描述信息,从数据库中获取虚拟IP和虚拟IP子网掩码。Step 201: Obtain the network card ID and network card description information bound to its own IP from the database according to its own IP, and obtain the virtual IP and virtual IP subnet mask from the database.
步骤202:调用设备驱动程序禁用所述网卡ID对应的网卡;Step 202: calling the device driver to disable the network card corresponding to the network card ID;
本实施例中具体的,所述设备驱动程序主要包括有第一函数、第二函数、第三函数、第四函数、第五函数、第六函数、第七函数、第八函数、第九函数和第十函数。Specifically in this embodiment, the device driver mainly includes a first function, a second function, a third function, a fourth function, a fifth function, a sixth function, a seventh function, an eighth function, and a ninth function and the tenth function.
本步骤具体的,通过调用第一函数、第二函数、第三函数、第四函数、第五函数和第六函数实现,其中调用第一函数可以获取服务器上已安装设备信息集合,调用第二函数可以对获取的已安装设备信息集合进行枚举得到一个当前已安装设备信息,调用第三函数可以获取当前已安装设备的详细设备信息;调用第四和第五函数可以将当前已安装设备的详细信息中包含的安装参数修改为第一预设值并使修改生效;调用第六函数可以释放调用第一函数至第五函数所做操作占用的内存。Specifically, this step is implemented by calling the first function, the second function, the third function, the fourth function, the fifth function, and the sixth function, wherein calling the first function can obtain the information set of devices installed on the server, and calling the second The function can enumerate the obtained installed device information set to obtain a currently installed device information, call the third function to obtain detailed device information of the currently installed device; call the fourth and fifth functions to get the current installed device information The installation parameters contained in the detailed information are modified to the first preset value and the modification takes effect; calling the sixth function can release the memory occupied by the operations of calling the first function to the fifth function.
步骤203:根据数据库中的预设标志位判断是否已设置虚拟IP,是则执行步骤204,否则执行步骤205;Step 203: judging whether the virtual IP has been set according to the preset flag in the database, if yes, execute step 204, otherwise execute step 205;
本实施例中优选的,当预设标志位为1时表示已设置虚拟IP,当预设标志位为0时表示未设置虚拟IP。Preferably in this embodiment, when the preset flag bit is 1, it means that the virtual IP has been set, and when the preset flag bit is 0, it means that the virtual IP is not set.
步骤204:调用设备驱动程序删除所述网卡ID对应的网卡的注册表中与所述网卡描述信息对应的虚拟IP和虚拟IP子网掩码,然后执行步骤205;Step 204: call the device driver to delete the virtual IP and virtual IP subnet mask corresponding to the network card description information in the registry of the network card corresponding to the network card ID, and then perform step 205;
本步骤具体的,通过调用第七函数、第八函数、第九函数和第十函数实现,其中调用第七和第八函数可以从所述网卡ID对应的网卡的注册表中获取原始IP、原始IP子网掩码;调用第九函数可以从原始IP、原始IP子网掩码中删除虚拟IP、虚拟IP子网掩码对应的字段,并将删除操作后的注册表回写到注册表键中的相应位置;调用第十函数可以释放调用第七函数至第九函数所做操作占用的内存。Specifically, this step is implemented by calling the seventh function, the eighth function, the ninth function and the tenth function, wherein calling the seventh and eighth functions can obtain the original IP, original IP subnet mask; Calling the ninth function can delete the corresponding fields of virtual IP and virtual IP subnet mask from the original IP and original IP subnet mask, and write the registry key after the delete operation to the registry key Corresponding positions in ; Calling the tenth function can release the memory occupied by the operation of calling the seventh to ninth functions.
步骤205:调用设备驱动程序在所述网卡ID对应的网卡上绑定从数据库中获取的所述虚拟IP和虚拟IP子网掩码,并更新数据库中的预设标志位;Step 205: call the device driver to bind the virtual IP and virtual IP subnet mask obtained from the database on the network card corresponding to the network card ID, and update the preset flag in the database;
本步骤具体的,通过调用第七函数、第八函数、第九函数和第十函数实现,其中调用第七和第八函数可以从所述网卡ID对应的网卡的注册表中获取原始IP、原始IP子网掩码;调用第九函数可以在原始IP、原始IP子网掩码的字段中绑定从数据库中获取的所述虚拟IP、虚拟IP子网掩码,并将绑定操作后的注册表回写到注册表键中的相应位置;调用第十函数可以释放调用第七函数至第九函数所做操作占用的内存。Specifically, this step is implemented by calling the seventh function, the eighth function, the ninth function and the tenth function, wherein calling the seventh and eighth functions can obtain the original IP, original IP subnet mask; calling the ninth function can bind the virtual IP and virtual IP subnet mask obtained from the database in the field of the original IP and the original IP subnet mask, and bind the operation after The registry is written back to the corresponding location in the registry key; calling the tenth function can release the memory occupied by the operation of calling the seventh to ninth functions.
本实施例中优选的,本步骤具体为将预设标志位设置为1。Preferably in this embodiment, this step is specifically setting the preset flag bit to 1.
步骤206:调用设备驱动程序启用所述网卡ID对应的网卡。Step 206: Call the device driver to enable the network card corresponding to the network card ID.
本步骤具体的,通过调用第一函数、第二函数、第三函数、第四函数、第五函数和第六函数实现,其中调用第一函数可以获取服务器上已安装设备信息集合,调用第二函数可以对获取的已安装设备信息集合进行枚举得到一个当前已安装设备信息,调用第三函数可以获取当前已安装设备的详细设备信息;调用第四和第五函数可以将当前已安装设备的详细信息中包含的安装参数修改为第二预设值并使修改生效;调用第六函数可以释放调用第一函数至第五函数所做操作占用的内存。Specifically, this step is implemented by calling the first function, the second function, the third function, the fourth function, the fifth function, and the sixth function, wherein calling the first function can obtain the information set of devices installed on the server, and calling the second The function can enumerate the obtained installed device information set to obtain a currently installed device information, call the third function to obtain detailed device information of the currently installed device; call the fourth and fifth functions to get the current installed device information The installation parameters contained in the detailed information are modified to the second preset value and the modification takes effect; calling the sixth function can release the memory occupied by the operations of calling the first function to the fifth function.
步骤207:启动应用服务。Step 207: Start the application service.
本实施例提供的双机热备方案应用中的步骤106或步骤110所述自动删除虚拟IP,并停止应用服务的流程,在基于Windows平台的具体实现如图2-2所示,包括以下步骤:The process of automatically deleting the virtual IP and stopping the application service described in step 106 or step 110 in the application of the dual-system hot backup solution provided by this embodiment is shown in Figure 2-2 for the specific implementation based on the Windows platform, including the following steps :
步骤201':调用设备驱动程序禁用所述网卡ID对应的网卡;Step 201': call the device driver to disable the network card corresponding to the network card ID;
本步骤具体的,通过调用第一函数、第二函数、第三函数、第四函数、第五函数和第六函数实现,其中调用第一函数可以获取服务器上已安装设备信息集合,调用第二函数可以对获取的已安装设备信息集合进行枚举得到一个当前已安装设备信息,调用第三函数可以获取当前已安装设备的详细设备信息;调用第四和第五函数可以将当前已安装设备的详细信息中包含的安装参数修改为第一预设值并使修改生效;调用第六函数可以释放调用第一函数至第五函数所做操作占用的内存。Specifically, this step is implemented by calling the first function, the second function, the third function, the fourth function, the fifth function, and the sixth function, wherein calling the first function can obtain the information set of devices installed on the server, and calling the second The function can enumerate the obtained installed device information set to obtain a currently installed device information, call the third function to obtain detailed device information of the currently installed device; call the fourth and fifth functions to get the current installed device information The installation parameters contained in the detailed information are modified to the first preset value and the modification takes effect; calling the sixth function can release the memory occupied by the operations of calling the first function to the fifth function.
步骤202':调用设备驱动程序删除所述网卡ID对应的网卡的注册表中与所述网卡描述信息对应的虚拟IP和虚拟IP子网掩码,并更新数据库中的预设标志位;Step 202': call the device driver to delete the virtual IP and the virtual IP subnet mask corresponding to the description information of the network card in the registry of the network card corresponding to the network card ID, and update the preset flag in the database;
本步骤具体的,通过调用第七函数、第八函数、第九函数和第十函数实现,其中调用第七和第八函数可以从所述网卡ID对应的网卡的注册表中获取原始IP、原始IP子网掩码;调用第九函数可以从原始IP、原始IP子网掩码中删除虚拟IP、虚拟IP子网掩码对应的字段,并将删除操作后的注册表回写到注册表键中的相应位置;调用第十函数可以释放调用第七函数至第九函数所做操作占用的内存。Specifically, this step is implemented by calling the seventh function, the eighth function, the ninth function and the tenth function, wherein calling the seventh and eighth functions can obtain the original IP, original IP subnet mask; Calling the ninth function can delete the corresponding fields of virtual IP and virtual IP subnet mask from the original IP and original IP subnet mask, and write the registry key after the delete operation to the registry key Corresponding positions in ; Calling the tenth function can release the memory occupied by the operation of calling the seventh to ninth functions.
本实施例中优选的,本步骤具体为将预设标志位设置为0。Preferably in this embodiment, this step is specifically setting the preset flag bit to 0.
步骤203':调用设备驱动程序启用所述网卡ID对应的网卡。Step 203': Call the device driver to enable the network card corresponding to the network card ID.
本步骤具体的,通过调用第一函数、第二函数、第三函数、第四函数、第五函数和第六函数实现,其中调用第一函数可以获取服务器上已安装设备信息集合,调用第二函数可以对获取的已安装设备信息集合进行枚举得到一个当前已安装设备信息,调用第三函数可以获取当前已安装设备的详细设备信息;调用第四和第五函数可以将当前已安装设备的详细信息中包含的安装参数修改为第二预设值并使修改生效;调用第六函数可以释放调用第一函数至第五函数所做操作占用的内存。Specifically, this step is implemented by calling the first function, the second function, the third function, the fourth function, the fifth function, and the sixth function, wherein calling the first function can obtain the information set of devices installed on the server, and calling the second The function can enumerate the obtained installed device information set to obtain a currently installed device information, call the third function to obtain detailed device information of the currently installed device; call the fourth and fifth functions to get the current installed device information The installation parameters contained in the detailed information are modified to the second preset value and the modification takes effect; calling the sixth function can release the memory occupied by the operation of calling the first function to the fifth function.
步骤204':停止应用服务。Step 204': stop the application service.
实施例2Example 2
如图3所示是本实施例2提供的一种基于Windows平台的虚拟IP实现方法,包括以下内容:As shown in Figure 3, it is a kind of virtual IP implementation method based on Windows platform provided by the present embodiment 2, including the following contents:
步骤301:根据自身IP从数据库中获取到与该IP绑定的网卡ID和网卡描述信息;Step 301: Obtain the network card ID and network card description information bound to the IP from the database according to its own IP;
例如,自身IP是192.168.16.47。For example, its own IP is 192.168.16.47.
步骤302:从数据库中获取虚拟IP与虚拟IP子网掩码;Step 302: Obtain the virtual IP and virtual IP subnet mask from the database;
例如:虚拟IP是192.168.25.200,虚拟IP子网掩码是255.255.255.0。For example: the virtual IP is 192.168.25.200, and the virtual IP subnet mask is 255.255.255.0.
步骤303:从数据库中获取表示是否已设置虚拟IP的字段值;Step 303: Obtain the field value indicating whether the virtual IP has been set from the database;
例如:获取到的字段值是flag。For example: the obtained field value is flag.
步骤304:调用SetupDiGetClassDevs函数获取已安装设备信息集合;Step 304: Call the SetupDiGetClassDevs function to obtain the installed device information set;
例如:获取的已安装设备信息集合是:For example: the obtained installed device information collection is:
({650D5BB1-9BB4-45CD-90C8-ECE70B72EB35},({650D5BB1-9BB4-45CD-90C8-ECE70B72EB35},
{E90A38FA-BA87-40F8-8BA9-B86F6852A9D3},{E90A38FA-BA87-40F8-8BA9-B86F6852A9D3},
{4D36E96C-E325-11CE-BFC1-08002BE10318},{4D36E96C-E325-11CE-BFC1-08002BE10318},
{4D36E96D-E325-11CE-BFC1-08002BE10318}{4D36E96D-E325-11CE-BFC1-08002BE10318}
….)....)
步骤305:调用SetupDiEnumDeviceInfo函数枚举所述已安装设备信息集合,获取一个当前已安装设备信息;Step 305: call the SetupDiEnumDeviceInfo function to enumerate the set of installed device information, and obtain a currently installed device information;
例如:获取的当前已安装设备信息是:For example: The currently installed device information obtained is:
({650D5BB1-9BB4-45CD-90C8-ECE70B72EB35})。({650D5BB1-9BB4-45CD-90C8-ECE70B72EB35}).
步骤306:调用SetupDiGetDeviceRegistryProperty函数获取当前已安装设备信息对应的设备详细信息;Step 306: call the SetupDiGetDeviceRegistryProperty function to obtain the device detailed information corresponding to the currently installed device information;
步骤307:比较所述设备详细信息中包含的描述信息与从数据库中获取的所述网卡描述信息是否相同,是则执行步骤308,否则返回执行步骤305;Step 307: Compare whether the description information contained in the device detailed information is the same as the network card description information obtained from the database, if yes, execute step 308, otherwise return to execute step 305;
步骤308:调用SetupDiSetClassInstallParams函数将所述设备详细信息中包含的安装参数修改为第一预设值;Step 308: calling the SetupDiSetClassInstallParams function to modify the installation parameters contained in the device detailed information to the first preset value;
本实施例中具体的,安装参数是stateChange,第一预设值是DICS_DISABLE。Specifically in this embodiment, the installation parameter is stateChange, and the first preset value is DICS_DISABLE.
步骤309:调用SetupDiCallClassInstaller函数使得对安装参数的修改生效;Step 309: calling the SetupDiCallClassInstaller function to make the modification of the installation parameters take effect;
步骤310:调用SetupDiDestroyDeviceInfoList函数释放当前内存;Step 310: call the SetupDiDestroyDeviceInfoList function to release the current memory;
具体的,通过调用SetupDiDestroyDeviceInfoList函数销毁获取的已安装设备信息集合释放当前内存。Specifically, the current memory is released by calling the SetupDiDestroyDeviceInfoList function to destroy the acquired installed device information collection.
步骤311:根据所述字段值判断是否已设置虚拟IP,是则执行步骤312,否则执行步骤316;Step 311: judge whether the virtual IP has been set according to the field value, if yes, execute step 312, otherwise execute step 316;
步骤312:调用RegOpenKeyEx函数打开所述网卡描述信息所对应的注册表键;Step 312: calling the RegOpenKeyEx function to open the registry key corresponding to the network card description information;
具体的,所述网卡描述信息所对应的注册表键为:SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces。Specifically, the registry key corresponding to the network card description information is: SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces.
步骤313:调用RegQueryValueEx函数从注册表中获取所述网卡描述信息对应的原始IP、原始IP子网掩码;Step 313: calling the RegQueryValueEx function to obtain the original IP and original IP subnet mask corresponding to the network card description information from the registry;
例如:获取的原始IP是192.168.16.47(192.168.25.200),原始IP子网掩码是255.255.255.0(255.255.255.0)。For example: the obtained original IP is 192.168.16.47 (192.168.25.200), and the original IP subnet mask is 255.255.255.0 (255.255.255.0).
步骤314:调用RegSetValueEx函数从原始IP、原始IP子网掩码中删除虚拟IP、虚拟IP子网掩码对应的字段,并将删除操作后的IP和子网掩码回写到注册表键中的相应位置;Step 314: call the RegSetValueEx function to delete the field corresponding to the virtual IP and the virtual IP subnet mask from the original IP and the original IP subnet mask, and write back the deleted IP and the subnet mask to the registry key corresponding position;
例如:删除操作后的IP和子网掩码分别是192.168.16.47和255.255.255.0。For example: the IP and subnet mask after the delete operation are 192.168.16.47 and 255.255.255.0 respectively.
步骤315:调用RegCloseKey函数释放当前内存,执行步骤316;Step 315: call the RegCloseKey function to release the current memory, and execute step 316;
具体的,通过释放当前打开的注册表键释放当前内存。Specifically, the current memory is released by releasing the currently opened registry key.
步骤316:调用RegOpenKeyEx函数打开所述网卡描述信息所对应的注册表键;Step 316: calling the RegOpenKeyEx function to open the registry key corresponding to the network card description information;
步骤317:调用RegQueryValueEx函数从注册表中获取所述网卡描述信息对应的原始IP、原始IP子网掩码;Step 317: calling the RegQueryValueEx function to obtain the original IP and original IP subnet mask corresponding to the network card description information from the registry;
步骤318:调用RegSetValueEx函数在原始IP、原始IP子网掩码的字段中绑定从数据库中获取的所述虚拟IP、虚拟IP子网掩码,并将绑定操作后的IP和子网掩码回写到注册表键中的相应位置,更改所述字段值并写入数据库中;Step 318: Call the RegSetValueEx function to bind the virtual IP and virtual IP subnet mask obtained from the database in the fields of the original IP and the original IP subnet mask, and bind the IP and subnet mask after the binding operation Write back to the corresponding position in the registry key, change the field value and write it into the database;
例如,绑定操作后的IP是192.168.16.47(192.168.25.200),子网掩码是255.255.255.0(255.255.255.0)。For example, the IP after the binding operation is 192.168.16.47 (192.168.25.200), and the subnet mask is 255.255.255.0 (255.255.255.0).
步骤319:调用RegCloseKey函数释放当前内存;Step 319: call the RegCloseKey function to release the current memory;
具体的,通过释放当前打开的注册表键释放当前内存。Specifically, the current memory is released by releasing the currently opened registry key.
步骤320:调用SetupDiGetClassDevs函数获取已安装设备信息集合;Step 320: Call the SetupDiGetClassDevs function to obtain the installed device information collection;
步骤321:调用SetupDiEnumDeviceInfo函数枚举所述已安装设备信息集合,获取一个当前已安装设备信息;Step 321: call the SetupDiEnumDeviceInfo function to enumerate the set of installed device information, and obtain a currently installed device information;
步骤322:调用SetupDiGetDeviceRegistryProperty函数获取当前已安装设备信息对应的设备详细信息;Step 322: call the SetupDiGetDeviceRegistryProperty function to obtain the device detailed information corresponding to the currently installed device information;
步骤323:比较所述设备详细信息中包含的描述信息与从数据库中获取的所述网卡描述信息是否相同,是则执行步骤324,否则返回执行步骤321;Step 323: Compare whether the description information included in the device detailed information is the same as the network card description information obtained from the database, if yes, execute step 324, otherwise return to execute step 321;
步骤324:调用SetupDiSetClassInstallParams函数将所述设备详细信息中包含的安装参数修改为第二预设值;Step 324: calling the SetupDiSetClassInstallParams function to modify the installation parameters contained in the device detailed information to the second preset value;
本实施例中具体的,安装参数是stateChange,第二预设值是DICS_ENABLE。Specifically in this embodiment, the installation parameter is stateChange, and the second preset value is DICS_ENABLE.
步骤325:调用SetupDiCallClassInstaller函数使得对安装参数的修改生效;Step 325: calling the SetupDiCallClassInstaller function to make the modification of the installation parameters take effect;
步骤326:调用SetupDiDestroyDeviceInfoList函数释放当前内存。Step 326: call the SetupDiDestroyDeviceInfoList function to release the current memory.
具体的,通过调用SetupDiDestroyDeviceInfoList函数销毁获取的已安装设备信息集合释放当前内存。Specifically, the current memory is released by calling the SetupDiDestroyDeviceInfoList function to destroy the acquired installed device information collection.
实施例3Example 3
本实施例是在实施例1提供的双机热备方案基础上提供的,其中图1中所述自动配置实现虚拟IP,启动应用服务的流程,在基于linux平台的具体实现如图4-1所示,包括以下步骤:This embodiment is provided on the basis of the dual-machine hot backup solution provided in Embodiment 1, wherein the automatic configuration in Figure 1 realizes the virtual IP and starts the process of application services, and the specific implementation based on the Linux platform is shown in Figure 4-1 shown, including the following steps:
步骤401:根据自身IP从数据库中获取到与自身IP绑定的网卡ID,从数据库中获取虚拟IP和虚拟IP子网掩码;Step 401: Obtain the network card ID bound to its own IP from the database according to its own IP, and obtain the virtual IP and virtual IP subnet mask from the database;
例如,获取的网卡ID为eth0,获取的虚拟IP为192.168.25.100,获取的虚拟IP子网掩码为255.255.255.0。For example, the obtained network card ID is eth0, the obtained virtual IP is 192.168.25.100, and the obtained virtual IP subnet mask is 255.255.255.0.
步骤402:执行查询配置信息命令;Step 402: Execute the query configuration information command;
例如:所述查询配置信息命令为:ifconfig eth0:0。For example: the query configuration information command is: ifconfig eth0:0.
步骤403:根据所述查询配置信息命令的命令执行结果判断所述网卡ID对应的网卡的配置信息是否正确,是则执行步骤405,否则执行步骤404;Step 403: Judging whether the configuration information of the network card corresponding to the network card ID is correct according to the command execution result of the query configuration information command, if yes, perform step 405, otherwise perform step 404;
例如,所述命令执行结果为:For example, the execution result of the command is:
eth0:0 Link encap:Ethernet HWaddr 00:50:56:81:73:F3eth0:0 Link encap:Ethernet HWaddr 00:50:56:81:73:F3
inet addr:192.168.25.220 Bcast:192.168.25.100inet addr:192.168.25.220 Bcast:192.168.25.100
Mask:255.255.255.0Mask: 255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500UP BROADCAST RUNNING MULTICAST MTU:1500
Metric:1Metric: 1
所述命令执行结果中的Bcast:192.168.25.100和Mask:255.255.255.0与从数据库中获取的虚拟IP和虚拟IP子网掩码一致,则判断结果为所述网卡的配置信息正确。Bcast: 192.168.25.100 and Mask: 255.255.255.0 in the command execution result are consistent with the virtual IP and virtual IP subnet mask obtained from the database, and the judgment result is that the configuration information of the network card is correct.
步骤404:执行停止虚拟IP命令删除所述配置信息中的虚拟IP和虚拟IP子网掩码,执行配置命令在所述配置信息中增加从数据库中获取的所述虚拟IP和虚拟IP子网掩码,执行步骤405;Step 404: Execute the stop virtual IP command to delete the virtual IP and virtual IP subnet mask in the configuration information, execute the configuration command to add the virtual IP and virtual IP subnet mask obtained from the database to the configuration information code, execute step 405;
例如,对所述网卡ID对应的网卡执行的所述停止虚拟IP命令为:ifconfgeth0:0 down。执行的所述配置命令为:ifconfig eth0:0 192.168.25.100 netmask255.255.255.0up。For example, the command to stop the virtual IP executed on the network card corresponding to the network card ID is: ifconfgeth0:0 down. The configuration command executed is: ifconfig eth0:0 192.168.25.100 netmask255.255.255.0up.
步骤405:进入配置目录下的配置文件,执行检查配置文件命令;Step 405: enter the configuration file in the configuration directory, and execute the command to check the configuration file;
例如,进入配置目录下的配置文件具体为执行命令:cd/etc/sysconfig/network-scripts;执行的所述检查配置文件命令具体为:moreifcfg-eth0:0。For example, entering the configuration file in the configuration directory specifically executes the command: cd/etc/sysconfig/network-scripts; the executed command to check the configuration file specifically is: moreifcfg-eth0:0.
步骤406:根据所述检查配置文件命令的命令执行结果判断配置文件中的配置信息是否正确,是则执行步骤408,否则执行步骤407:Step 406: Judging whether the configuration information in the configuration file is correct according to the command execution result of the check configuration file command, if yes, execute step 408, otherwise execute step 407:
例如,执行more ifcfg-eth0:0后得到的命令执行结果为:DEVICE=eth0:0For example, the command execution result after executing more ifcfg-eth0:0 is: DEVICE=eth0:0
BOOTPROTO=noneBOOTPROTO=none
IPADDR=192.168.25.80IPADDR=192.168.25.80
NETMASK=255.255.255.0NETMASK=255.255.255.0
GATEWAY=192.168.25.254GATEWAY=192.168.25.254
HWADDR=00:50:56:81:73:f3HWADDR=00:50:56:81:73:f3
NM_CONTROLLED=yesNM_CONTROLLED=yes
ONBOOT=yes>
TYPE=EthernetTYPE=Ethernet
IPV6INIT=noIPV6INIT=no
USERCTL=noUSERCTL=no
上述命令执行结果中包含的IPADDR=192.168.25.80与从数据库中获取的虚拟IP=192.168.25.100不同,则执行步骤407。If IPADDR=192.168.25.80 contained in the execution result of the above command is different from the virtual IP=192.168.25.100 obtained from the database, step 407 is executed.
步骤407:执行删除命令删除所述配置文件,执行写入命令在所述配置目录下重新写入一个在配置信息中包含有从数据库中获取的所述虚拟IP和虚拟IP子网掩码的配置文件,执行步骤408;Step 407: Execute the delete command to delete the configuration file, execute the write command to rewrite a configuration containing the virtual IP and virtual IP subnet mask obtained from the database in the configuration information under the configuration directory file, execute step 408;
例如,执行的所述删除命令具体为:rm ifcfg-eth0:0;执行的所述写入命令具体为:For example, the delete command executed is specifically: rm ifcfg-eth0:0; the write command executed is specifically:
vi ifcfg-eth0:0vi ifcfg-eth0:0
DEVICE=eth0:0DEVICE=eth0:0
BOOTPROTO=noneBOOTPROTO=none
IPADDR=192.168.25.100IPADDR=192.168.25.100
NETMASK=255.255.255.0NETMASK=255.255.255.0
GATEWAY=192.168.25.254GATEWAY=192.168.25.254
HWADDR=00:50:56:81:73:f3HWADDR=00:50:56:81:73:f3
NM_CONTROLLED=yesNM_CONTROLLED=yes
ONBOOT=yes>
TYPE=EthernetTYPE=Ethernet
IPV6INIT=noIPV6INIT=no
USERCTL=noUSERCTL=no
步骤408:启动应用服务。Step 408: Start the application service.
本实施例是在实施例1提供的双机热备方案基础上提供的,其中图1中所述自动删除虚拟IP,停止应用服务的流程,在基于linux平台的具体实现如图4-2所示,包括以下步骤:This embodiment is provided on the basis of the dual-machine hot backup solution provided in Embodiment 1, wherein the process of automatically deleting the virtual IP and stopping the application service described in Figure 1 is implemented on a Linux-based platform as shown in Figure 4-2 , including the following steps:
步骤401':执行停止虚拟IP命令删除配置信息中的虚拟IP和虚拟IP子网掩码;Step 401': Execute the stop virtual IP command to delete the virtual IP and virtual IP subnet mask in the configuration information;
例如,所述停止虚拟IP命令具体为:ifconfg eth0:0 down。For example, the command to stop the virtual IP is specifically: ifconfg eth0:0 down.
步骤402':进入配置目录下的配置文件;Step 402': enter the configuration file in the configuration directory;
例如,通过执行命令cd/etc/sysconfig/network-scripts进入配置目录下的配置文件。For example, run the command cd /etc/sysconfig/network-scripts to enter the configuration file in the configuration directory.
步骤403':执行删除命令删除所述配置文件;Step 403': execute a delete command to delete the configuration file;
例如,执行的所述删除命令具体为:rm ifcfg-eth0:0。For example, the deletion command executed is specifically: rm ifcfg-eth0:0.
步骤404':停止应用服务。Step 404': stop the application service.
以上所述的实施例只是本发明较优选的具体实施方式,本领域的技术人员在本发明技术方案范围内进行的通常变化和替换都应包含在本发明的保护范围内。The above-described embodiments are only preferred specific implementations of the present invention, and ordinary changes and substitutions made by those skilled in the art within the scope of the technical solution of the present invention should be included in the protection scope of the present invention.
Claims (19)
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 Expired - Fee Related 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)
| 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)
| 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 |
-
2014
- 2014-12-09 CN CN201410749176.7A patent/CN104378449B/en not_active Expired - Fee Related
Patent Citations (8)
| 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)
| Title |
|---|
| 岳建辉等: "VIP: 集群环境下面向高可靠和高性能的通信", 《小型微型计算机系统》 * |
Cited By (7)
| 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 |
|---|---|---|
| EP3716532B1 (en) | Supporting concurrency for graph-based high level configuration models | |
| US9628334B2 (en) | VLAN tagging in a virtual environment | |
| US7890613B2 (en) | Program deployment apparatus and method | |
| CN113452830B (en) | Batch control method of android cloud mobile phone, computer readable medium and electronic device | |
| CN106790758B (en) | Method and device for accessing network object in NAT network | |
| CN107005426B (en) | A kind of life cycle management method and device of virtual network function | |
| CN111064649B (en) | Method and device for realizing binding of layered ports, control equipment and storage medium | |
| EP1780940A1 (en) | High availability network systems | |
| WO2010032249A2 (en) | System and method for emulating a computing device | |
| US20190018710A1 (en) | Managing resource allocation of a managed system | |
| CN103532731A (en) | method and device for preventing network configuration of virtual machine from losing | |
| CN104378449B (en) | A kind of implementation method of virtual IP address | |
| US11750475B1 (en) | Monitoring customer application status in a provider network | |
| CN103457945A (en) | Intrusion detection method and system | |
| CN110855488B (en) | Virtual machine access method and device | |
| CN105404530B (en) | It is a kind of to realize easy deployment and the system and method using private clound | |
| CN113835834A (en) | A method and system for scaling computing nodes based on K8S container cluster | |
| US10419392B2 (en) | Method, device and system for implementing address sharing | |
| US20170295452A1 (en) | Method and Registration Node for Managing Application Resource in Machine to Machine (M2M) | |
| US20170302617A1 (en) | Method and Registration Node for Managing Application Resource in Machine to Machine (M2M) | |
| CN107819556A (en) | A kind of service state switching method and device | |
| CN109039764A (en) | A kind of network parameter configuration method of distributed memory system | |
| CN112099902A (en) | Network adapter configuration method and device of virtual machine, electronic device and storage medium | |
| CN111901395B (en) | Multi-cluster switching method and device | |
| CN110413322B (en) | A server network port management method, system and baseboard management controller |
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 | ||
| CF01 | Termination of patent right due to non-payment of annual fee | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20170714 |