A kind of synchronous method of server ip address
Technical field
The present invention relates to fields of communication technology, more particularly to a kind of synchronous method of server ip address.
Background technology
Constantly expand with the scale of mobile application market, the continuous expansion of mobile phone user population size, and
" internet " theory gradually warms up, and Business group also carries out the mobile construction of own services one after another.- 2014 years 2013
Between 2 years, its autonomous cellular service channel of State Grid Corporation of China's all-round construction is realized and is provided to the user based on intelligent mobile phone terminal
The mobile supporting of the power supply services such as electricity consumption inquiry, payment, business handling.Cell-phone customer terminal combination each province marketing system is built
If present situation, using a point pattern for province's application deployment.As soon as defining a node as unit of province, there are several provinces there are several nodes.Often
A node has the server of their own, which has unique IP address, and in the server of each node with being stored with IP
Location list also includes the server of other nodes in the server list other than the IP address comprising local server
IP address.It, can only when the IP address of a node changes due to being independent from each other between the server of each node
Corresponding IP address in book server list is changed, and the server list of other nodes can not realize synchronization, therefore can go out
Now each node server list is inconsistent.If the server where present node is provided by stored server list
IP address access the server of altered IP address when, result in IP address mistake, corresponding server can not be accessed
Problem.
It can be seen that when there is the server ip address of some node to change, the service of each node how is realized
It is those skilled in the art's urgent problem to be solved that device IP address, which synchronizes,.
Invention content
The object of the present invention is to provide a kind of synchronous method of server ip address, for when the server for having some node
When IP address changes, how to realize that the server ip address of each node synchronizes.
In order to solve the above technical problems, the present invention provides a kind of synchronous method of server ip address, it to be used for server ip
Address synchronization network, the network include:It is in turn connected to form N number of node of cyclic structure, wherein N number of node includes one
Host node and N-1 are a from node;The host node is also connect with N-1 from node, and N is the positive integer more than 2, this method packet
It includes:
When the server where destination node receives the synchronic command of server ip address change, update server row
Table, and determine that the destination node is host node or from node;
If the destination node is host node, server where the host node is to each described where node
Server forwards the synchronic command;
Each server from where node receives the synchronic command, and updates respective server list;
If the destination node is where the server where node, the destination node to the host node
Server forwards the synchronic command;
Server where the host node receives the synchronic command to update server list, and to except the target
Remaining each described server from where node outside node forwards the synchronic command;
Remaining each described server from where node in addition to the destination node receives the synchronic command, and updates
Respective server list;
Wherein, the destination node is the node that the synchronic command is received in N number of node, the synchronic command packet
Include the server ip address after change.
Preferably, when the destination node is host node, further include after updating respective server list:
Server where from the server from where node to the destination node sends update feedback signal.
Preferably, further include:
When the server where the destination node receives described in whole servers transmissions from where node more
Update, which is generated, after new feedback signal completes signal.
Preferably, further include:The update, which is exported, in the server where the destination node completes signal.
Preferably, when the destination node is from node, further include after updating respective server list:
Remaining in addition to the destination node is described from the server where the server where node to the host node
Send update feedback signal;
When the server where the host node receives remaining in addition to the destination node all where node
Update is generated after the update feedback signal that server is sent completes signal.
Preferably, further include:Update completion signal is sent to the target by the server where the host node
Server where node.
Preferably, further include:Server where the destination node exports the update and completes signal.
The synchronous method of server ip address provided by the present invention first determines whether that destination node is host node or from section
Point, if it is host node then by the server where host node to all from where node server send synchronic command,
If it is the server where synchronic command to be then first sent to host node from node, then will be same as the server where host node
Step instruction is sent to other servers from where node in addition to destination node.Where receiving each node of synchronic command
Server updates respective server list according to synchronic command, with the service of the server where whole nodes in this system
Device list realizes synchronization.
Description of the drawings
In order to illustrate the embodiments of the present invention more clearly, attached drawing needed in the embodiment will be done simply below
It introduces, it should be apparent that, drawings in the following description are only some embodiments of the invention, for ordinary skill people
For member, without creative efforts, other drawings may also be obtained based on these drawings.
Fig. 1 is a kind of structure chart of server ip address synchronizing network provided by the invention;
Fig. 2 is a kind of flow chart of the synchronous method of server ip address provided by the invention;
Fig. 3 is the schematic diagram of the synchronous method of another server ip address provided by the invention;
Fig. 4 is the schematic diagram of the synchronous method of another server ip address provided by the invention.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation describes, it is clear that described embodiments are only a part of the embodiments of the present invention, rather than whole embodiments.Based on this
Embodiment in invention, without making creative work, what is obtained is every other by those of ordinary skill in the art
Embodiment belongs to the scope of the present invention.
Core of the invention is to provide a kind of synchronous method of server ip address.
In order to enable those skilled in the art to better understand the solution of the present invention, with reference to the accompanying drawings and detailed description
The present invention is described in further detail.
Embodiment one
Fig. 1 is a kind of structure chart of server ip address synchronizing network provided by the invention.Server ip address synchronizes net
Network includes:It is in turn connected to form N number of node of closed hoop structure;
Wherein, N number of node includes a host node and N-1 a from node;Host node is also connect with N-1 from node;
Wherein, N is the positive integer more than 2.
As shown in Figure 1, being illustrated so that N is 5 as an example in the figure.If there is 5 nodes, then one of node is
Host node is expressed as master, and in addition 4 are divided from node than being slave1, slave2, slave3 and slave4.In the system
In, when position relationship of each node, is arbitrary, i.e. the two neighboring node of slave1 can be slave2 and slave3, also may be used
Think slave2 and slave4.But the position regardless of node, the final connection structure of all nodes is to be sequentially connected
At a ring-type.In Fig. 1, if headed by master, be followed successively by slave1, slave2, slave3 and
Slave4, slave4 are exactly tail, and then slave4 is connect with master again, thus form the ring-type of a closure.At this
After ring-type is formed, each have from node and only two adjacent nodes, but host node also connects with all from node
It connects.It is exactly master in figure other than its adjacent two nodes slave1 and slave4, also connects with slave2 and slave3
It connects.
In specific implementation, in order to ensure the validity of server ip address synchronization system.If one of node event
Barrier so this system has not just included the node to break down, is that remaining node constitutes this system, therefore, remaining
Node connection type as also described above.Such as the master failures in Fig. 1, then server ip address synchronization system just wrap
Containing 4 nodes, a point ratio is:Slave1, slave2, slave3 and slave4.Therefore, there are one be main section in this four nodes
Point, remaining 3 nodes are from node.Realization can be specifically fetched by heartbeat chain, the present invention repeats no more.
It should be noted that it is the mobile supporting that each user provides that the network in Fig. 1, which is suitable for national grid,
In other words, each to save there are one server, as soon as a server corresponds to a node, there are multiple nodes in multiple provinces.User
The server where it can be accessed by the APP on mobile phone, and the services such as electricity consumption inquiry, payment, business handling are realized with this.
Embodiment two
Fig. 2 is a kind of flow chart of the synchronous method of server ip address provided by the invention.Server ip address it is same
One step process, including:
S10:When the server where destination node receives the synchronic command of server ip address change, more new demand servicing
Device list, and determine that destination node is host node or from node.
S11:If destination node is host node, the server where host node is to respectively from the server where node turn
Send out synchronic command.
S12:Synchronic command respectively is received from the server where node, and updates respective server list.
S13:If destination node is to turn from the server where the server to host node where node, destination node
Send out synchronic command.
S14:Server where host node receives synchronic command to update server list, and in addition to destination node
Remaining respectively forwards synchronic command from the server where node.
S15:Remaining in addition to destination node respectively receives synchronic command from the server where node, and updates respective clothes
Business device list.
Wherein, destination node is the node of the synchronic command received in N number of node, and synchronic command includes the clothes after change
Business device IP address.
In specific implementation, when server of user couple has input IP address change request, where this server
Node be exactly destination node, that is to say, that synchronic command is by destination node.It is needed since IP address synchronizes by leading
Node is initiated, therefore when the server where destination node receives the synchronic command of server ip address change, is needed really
The node that sets the goal is host node or from node.
If destination node is host node, directly synchronic command can be sent as the server where destination node
To other all from the server where node.Synchronic command respectively is received from the server where node, and updates respective clothes
Business device list.Nodes all so all synchronized updates server list, when user is other from any one server access
When server, the nonsynchronous problem of server list is avoided.
It is all from node transmission synchronic command without normal direction from node if destination node is from node, therefore, this
From node, i.e. server where destination node needs to forward synchronic command to the server where host node.When host node institute
Server receive the synchronic command that the server where destination node is sent after, other than update server list, and also
Synchronic command respectively is forwarded from the server where node to remaining in addition to destination node, so that remaining in addition to destination node is each
Synchronic command is received from the server where node, and updates respective server list.Nodes all so all synchronizes more
New server list avoids server list difference when user's server other from any one server access
The problem of step.
The address approach of server ip provided in this embodiment first determines whether that destination node is host node or from node,
If it is host node then by the server where host node to all from where node server send synchronic command, if
It is the server where synchronic command to be then first sent to host node from node, then will be synchronized and referred to as the server where host node
Order is sent to other servers from where node in addition to destination node.Receive the service where each node of synchronic command
Device updates respective server list according to synchronic command, is arranged with the server of the server where whole nodes in this system
Table realizes synchronization.
Fig. 3 is the schematic diagram of the synchronous method of another server ip address provided by the invention.Fig. 3 shows target section
Point is the corresponding schematic diagram of host node.As a preferred embodiment, when destination node is host node, it is respective in update
Server list after further include:
S20:Update feedback signal is sent from the server where the server to destination node where node.
After receiving synchronic command from the server where node, its server list is updated, then to destination node
The server at place sends update feedback signal, to inform the server where destination node to complete more new task.
As a preferred embodiment, further including after step S20:
S21:When to receive the updates that whole servers from where node are sent anti-for the server where destination node
Update is generated after feedback signal completes signal.
In step S20 respectively update feedback letter is had sent from the server where the server to destination node where node
After number, the server where destination node has been received by update feedback signal, when the server where destination node receives
After the update feedback signal that server where whole slave nodes is sent, just illustrate whole servers from where node all
Server list update is completed, at this moment the server where destination node generates update and completes signal.
As a preferred embodiment, further including after step S21:
S22:Signal is completed in the server output update where destination node.
The signal is exported after generating update and completing signal, user is enabled to know by the server where destination node
Dawn.
Fig. 4 is the schematic diagram of the synchronous method of another server ip address provided by the invention.Fig. 4 shows target section
Point is from the corresponding schematic diagram of node.As a preferred embodiment, when destination node is from node, it is respective in update
Server list after further include:
S30:Remaining in addition to destination node sends update from the server where the server to host node where node
Feedback signal;
S31:When the server where host node receives remaining in addition to destination node all from the service where node
Update is generated after the update feedback signal that device is sent completes signal.
As a preferred embodiment, further including:
S32:Signal is completed in server output update where destination node.
The detailed process of the above embodiment is seen above, and which is not described herein again.
The synchronous method of server ip address provided by the present invention is described in detail above.It is each in specification
Embodiment is described by the way of progressive, and each embodiment focuses on the differences from other embodiments, each
Just to refer each other for identical similar portion between embodiment.For the device disclosed in the embodiment, due to itself and embodiment public affairs
The method opened is corresponding, so description is fairly simple, reference may be made to the description of the method.It should be pointed out that for
For those skilled in the art, without departing from the principle of the present invention, if can also be carried out to the present invention
Dry improvement and modification, these improvement and modification are also fallen within the protection scope of the claims of the present invention.
Professional further appreciates that, unit described in conjunction with the examples disclosed in the embodiments of the present disclosure
And algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware and
The interchangeability of software generally describes each exemplary composition and step according to function in the above description.These
Function is implemented in hardware or software actually, depends on the specific application and design constraint of technical solution.Profession
Technical staff can use different methods to achieve the described function each specific application, but this realization is not answered
Think beyond the scope of this invention.
The step of method described in conjunction with the examples disclosed in this document or algorithm, can directly be held with hardware, processor
The combination of capable software module or the two is implemented.Software module can be placed in random access memory (RAM), memory, read-only deposit
Reservoir (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technology
In any other form of storage medium well known in field.