Summary of the invention
The application's purpose is, a kind of server control method, controlled server and center Control Server are provided, and realizes keeping being connected of short time between center Control Server and controlled server, improves the stability of center Control Server operation.
For achieving the above object, the application provides a kind of server control method, be applied to comprise that in the system of center Control Server service end that center Control Server client computer, Duo Tai center Control Server consists of and a plurality of controlled servers, described controlled server is carried out following steps:
Starting a listening port intercepts;
Listen to connect and set up instruction;
Set up instruction according to described connection and set up short connection;
Receive control command in described connection, carry out described control command;
Receive the connection open command in described connection, disconnect described connection.
The application also provides a kind of server control method, be applied to comprise that in the system of center Control Server service end that center Control Server client computer, Duo Tai center Control Server consists of and a plurality of controlled servers, described center Control Server is carried out following steps:
Receive the request of control, described control request comprises connecting sets up instruction, controlled server information and control command;
Obtain the controlled server information of carrying in described control request;
Send to connect to server corresponding to described controlled server information and set up instruction, connect;
Forward the control command of carrying in described control request in the connection of described foundation;
Send the connection open command in described connection, disconnect described connection.
Correspondingly, the application also provides a kind of controlled server, be applied to comprise that in the system of center Control Server service end that center Control Server client computer, Duo Tai center Control Server consists of and a plurality of controlled servers, described controlled server comprises:
Start unit is used for starting a listening port and intercepts;
Listening port is used for listening to connecting and sets up instruction;
The link setup unit is used for setting up instruction according to described connection and sets up short connection;
Instruction execution unit is used for receiving control command in described connection, carries out described control command;
The chain rupture unit is used for receiving the connection open command in described connection, disconnects described connection.
Correspondingly, the application also provides a kind of center Control Server, be applied to comprise that in the system of center Control Server service end that center Control Server client computer, Duo Tai center Control Server consists of and a plurality of controlled servers, described center Control Server comprises:
Receiving element is used for receiving the request of control, and described control request comprises connecting sets up instruction, controlled server information and control command;
Acquiring unit is used for obtaining the controlled server information that described control request is carried;
The link setup transmitting element is used for sending to connect to server corresponding to described controlled server information setting up instruction, connects;
Instruction sending unit is used for sending the control command that described control request is carried in described connection;
The chain rupture transmitting element is used for sending the connection open command in described connection, disconnects described connection.
Therefore, the application has realized keeping being connected of short time between center Control Server and controlled server, after executing control command in this connection controlled server managed, disconnect immediately this short connection, thereby do not need to keep long the connection, after a center Control Server is delayed machine, can not affect the control and management to controlled server in addition.
Embodiment
Below by drawings and Examples, the application's technical scheme is described in further detail.
the application's server control method, controlled server and center Control Server, by setting up the connection of short time between center Control Server and controlled server, carrying out instruction in the connection of this short time controls, disconnect immediately this connection after completing the management of controlled server, and by domain name mapping (domain name resolution, DNS) or load balancing mode come the Selection Center Control Server, thereby realize that center Control Server and controlled server do not need to keep for a long time connection status, and when a center Control Server is delayed machine, can not affect the control and management to controlled server.
The applied system architecture of following paper the application server control method, as shown in Figure 1, this system comprise center ControlServer client computer 10, by Duo Tai center Control Server 1,2 ..., the center Control Server service end that consists of of N and a plurality of controlled server A, B ..., N.A plurality of controlled servers can be the combinations of a plurality of server clusters or a plurality of separate unit server or server cluster and separate unit server.Center ControlServer client computer 10 can access center Control Server service end by DNS or load balancing mode, connect, the user initiates the control command of certain controlled server is operated by client afterwards, at first the center Control Server that is access in connects with controlled server, restart subsequently the control command operations such as service, deployment services, transmission file, deleted file, after command operating finishes, disconnect immediately this connection.
As shown in Figure 2, it is the flow chart of a kind of server control method of the application.This embodiment main body is that in conjunction with illustrated in figures 1 and 2, the method comprises for controlled server to be managed:
Step 11 starts a listening port and intercepts;
The client terminal start-up of controlled server is opened a listening port.
Step 12 listens to connect and sets up instruction;
Step 13 is set up instruction according to described connection and is connected;
Step 14 receives control command in the described connection of setting up, carry out described control command;
Step 15 receives the connection open command in described connection, disconnect described connection.
As shown in Figure 2, step 13 is described connect after before step 14, also comprise: step 16 sends described connection and sets up the response message of instruction.
After the described control command of the described execution of step 14, and also comprise before step 15: step 17 sends the response message of described control command.
Above-mentioned steps has been described after carrying out control command, disconnect immediately, therefore, what keep between controlled server and center Control Server is the connection of short time, and controlled server need to be kept long connection status with central server unlike prior art.
Wherein, communication can be to carry out on self-defining communication protocol.
The application has realized keeping being connected of short time between center Control Server and controlled server, after executing control command in this connection controlled server managed, disconnect immediately this connection, thereby do not need to keep long the connection, realize a kind ofly just connecting when based on needs, controlled server being managed.
As shown in Figure 3, it is the flow chart of a kind of server control method of the application.This embodiment main body is for the center Control Server, and in conjunction with Fig. 1 and shown in Figure 3, the method comprises:
Step 21 receives the request of control, and described control request comprises connecting sets up instruction, controlled server information and control command;
In this application, Control Server service end in center is the group system that Duo Tai center Control Server consists of.The control interface that the user opens by center Control Server client computer, the controlled server of selecting to need to control initiates to control request, can be specifically that the user passes through the controlled server list that shows on the control interface of client computer, a controlled server is chosen in click, send the request of control, the center Control Server receives this control request.This control request comprises the corresponding control command that information, the connection of controlled server are set up instruction and be used for this controlled server is managed, and these control commands can be the service of restarting, deployment services, transmission file, deleted file instruction etc.
Step 22 is obtained the controlled server information of carrying in described control request;
Step 23 forwards to connect to server corresponding to described controlled server information and sets up instruction, connects;
Step 24 forwards the control command of carrying in described control request in the connection of described foundation;
Step 25 sends the connection open command in described connection, disconnect described connection.
Further, as shown in Figure 3, set up instruction in described the connection to server transmission corresponding to described controlled server information of step 23, after connecting, before forwarding control command in the connection of step 24 in described foundation, also comprise:
Step 29 receives described connection and sets up the response message of instruction.
After sending controling instruction, send the connection open command in the described connection of step 25 in the described connection of step 24, before disconnecting described connection, also comprise:
Step 30, the response message of the described control command of reception.
Communicating by letter can be based upon self-defining communication protocol between center Control Server and controlled server carried out, and can be encrypted according to security needs.
The application's above-mentioned steps has realized that controlled server is connected the connection of short time with the center Control Server, carrying out control command in the connection of this short time sends, controlled server is after carrying out control command, disconnect immediately, thereby do not need to keep long connection status, realize a kind ofly just connecting when based on needs, controlled server being managed.
Preferably, described server control method also comprised before step 21:
Step 20 receives the access request that forwards with domain name mapping mode or load balancing mode, connects with center Control Server client.
Also comprised before this step 20:
Step 26, SiteServer LBS receive access request, judges center Control Server system (being center Control Server service end) the middle center Control Server machine of whether delaying, and obtain the information of the center Control Server of the machine of not delaying;
Particularly, the user is by browser or other clients of center Control Server client computer, open the control interface of management server and send access request, the network equipment for example SiteServer LBS receives access request, at first judge center Control Server in the Control Server system of the center machine of whether delaying, get the center Control Server information of the machine of not delaying;
Step 27 with load balancing mode, is determined a center Control Server in the Control Server information of the center of the machine of not delaying;
Step 28 forwards described access request to described center Control Server.
Whether determine that with load balancing mode a center Control Server is specially: SiteServer LBS can be with on a plurality of IP address bindings to IP address, and can these machines of automatic inspection normal.As the user during by the browser on the client computer of center Control Server or this IP of other client-access, when namely opening the control interface initiation access request of center Control Server, directly to access SiteServer LBS, SiteServer LBS can check this IP checks whether the server in the IP address list of binding is normal, then access request is distributed (mode of distributing can be order, random or undertaken by uninterrupted) to normal center Control Server wherein.After the center Control Server is handled access request, result is returned to SiteServer LBS, SiteServer LBS returns to browser or other clients to result again, and center Control Server and client connect.It is the user has opened the center Control Server on client control interface.From then on begin, the center Control Server can receive the control request that the controlled server to needs management that the user sends by client computer manages.Concrete load balancing mode is that prior art repeats no more.
wherein, said process also can determine that a center Control Server replaces in the domain name mapping mode, it is specially: domain name analysis system can be with on a plurality of IP address binding to a domain name, for example host.taobao.net, when the user opens the control interface by the browser on the client computer of center Control Server or this domain name of other client-access, automatically requesting query domain name analysis system, domain name analysis system can distribute according to this domain name (random or order etc.) one IP address and return, then browser or other clients are just initiated access according to this IP address to the center Control Server of correspondence and are opened and control the interface.Utilize DNS to determine the center Control Server, the machine if the center Control Server is delayed, can arrange by revising DNS, the center Control Server of the machine of delaying is laid down, the Control Server IP address, center that is about to the machine of delaying is not tied on this domain name, guarantees that DNS determines that the center Control Server is all available.Concrete DNS mode is that prior art repeats no more.
Therefore, the center Control Server can be determined by DNS mode or load balancing mode in this application, and namely Control Server client in center accesses the center Control Server with DNS mode or load balancing mode.The network equipment for example DNS system or SiteServer LBS is never delayed in the center Control Server of machine according to DNS or load balancing mode, determines a center Control Server from the Control Server cluster of center.Therefore, the machine even a center Control Server is delayed can change another center Control Server the controlled server of needs management is managed, and which center Control Server of controlled server is managed without any impact it.
In this example, after for example the user sends access request, Control Server 2 centered by the center Control Server of selecting by load balancing mode, the control command sent of user is deleted file afterwards, and controlled server information is controlled server A, therefore, center Control Server 2 connects with controlled server A, in this connection, controlled server A is carried out the such bookkeeping of file deletion subsequently, after operation was completed, center Control Server 2 disconnected with controlled server A.
generally, at first, the access request that the network equipment sends by center Control Server client computer according to the user, select a center Control Server to come to connect with client from the Control Server system of center according to DNS mode or load balancing mode, subsequently, the user is on the control interface of center Control Server client, for example, controlling the controlled server that shows with tabular form on the interface, select controlled server from this list, send corresponding control request (for example click and control the corresponding control command button that shows on the interface), this control request comprises connecting sets up instruction, the controlled server information of selecting and corresponding control command, after the center Control Server is received this control request, at first send to connect to controlled server and set up instruction, controlled server receives this connection set up instruction after, connect with the center Control Server, the relevant control instruction of receiving center Control Server forwarding subsequently, carry out the relevant control instruction, this control command can be upgrade by the client-side program of Control Server and such control command such as restart, and response results is returned to the center Control Server, the center Control Server sends the connection open command immediately, disconnect described connection.
Therefore, the application has realized connecting of controlled server and center Control Server short time, carrying out control command in the connection of this short time sends, controlled server is after carrying out control command, disconnect immediately, thereby do not need to keep long connection status, realize a kind ofly just connecting when based on needs, controlled server being managed.And (so long as center Control Server corresponding all controlled server all, the center Control Server is all consistent to utilize DNS or load balancing.The load balancing here is that subscription client just utilizes this mode when the Control Server of the center of selection, the center Control Server is to manage all controlled servers, not needing to utilize load balancing mode) user is by center Control Server client, select a center Control Server that controlled server is managed from the Control Server system of center, single-point can not occur between center Control Server and controlled server like this.Change another center Control Server after machine even center Control Server is delayed, for the controlled server of needs management without any impact.The application does not have special performance index to the center Control Server, and can increase arbitrarily the quantity of controlled server.
Correspondingly, the application provides a kind of controlled server, is applied to comprise that in the system of center Control Server service end that center Control Server client computer, Duo Tai center Control Server consists of and a plurality of controlled servers, described controlled server comprises:
Start unit is used for starting a listening port and intercepts;
Listening port is used for listening to connecting and sets up instruction;
The link setup unit is used for setting up instruction according to described connection and sets up short connection;
Instruction execution unit is used for receiving control command in described connection, carries out described control command;
The chain rupture unit is used for receiving the connection open command in described connection, disconnects described connection.
Described this controlled server also can comprise:
The first response transmitting element is used for sending the response message that instruction is set up in described connection.
The second response transmitting element is for the response message that sends described control command.
Correspondingly, the application also provides a kind of center Control Server, be applied to comprise that in the system of center Control Server service end that center Control Server client computer, Duo Tai center Control Server consists of and a plurality of controlled servers, this center Control Server comprises:
Receiving element is used for controlling request, and described control request comprises connecting sets up instruction, controlled server information and control command;
Acquiring unit is used for obtaining the controlled server information that described control request is carried;
The link setup transmitting element is used for sending to connect to server corresponding to described controlled server information setting up instruction;
Instruction sending unit is used for sending the control command that described control request is carried in described connection;
The chain rupture transmitting element is used for sending the connection open command in described connection, disconnects described connection.
Described center Control Server also can comprise:
Reception link setup unit is used for receiving the access request that forwards with domain name mapping mode or load balancing mode, connects with center Control Server client.
Described center Control Server also can comprise:
Judging unit is used for SiteServer LBS and receives access request, judges in the Control Server system of center the center Control Server machine of whether delaying, and obtains the information of the center Control Server of the machine of not delaying;
Determining unit is used for load balancing mode, determines a central server in the Control Server of the center of the machine of not delaying;
Retransmission unit is used for forwarding described access request to described central server.
Perhaps described center Control Server also can comprise:
Determining unit is used in the DNS mode, determines a central server in the Control Server of the center of the machine of not delaying;
Described center Control Server also comprises:
The first response receiving element is used for receiving the response message that instruction is set up in described connection.
The second response receiving element is for the response message that receives described control command.
Therefore, the application center Control Server stateless, but infinite expanding, manageable controlled server quantity does not have the upper limit, performance to separate unit center Control Server does not have special requirement, there is no the single-point problem, and the center Control Server machine of delaying can not affect the management of server arbitrarily, communication protocol can customize and encrypts simultaneously, and very high fail safe is arranged.
The application is by the mode management server of short connection, monitor instruction at the listening port that the controlled server port open is fixing, with the scheduling mode management server that calls as required, connect when needing and call, do not connect when not required, realize the stateless of center Control Server, making it does not have single-point, but arbitrary extension also avoids long the connection to cause center Control Server performance bottleneck requirement simultaneously.And provide the mode of self-defining communication protocol, can set up the communication scheduling mode of custom protocol or encryption between center Control Server and controlled server, avoid controlled server because having opened the relevant safety problem of serving the context management server that causes of intercepting.
Those of ordinary skills should further recognize, unit and the algorithm steps of each example of describing in conjunction with embodiment disclosed herein, can realize with electronic hardware, computer software or combination both, for the interchangeability of hardware and software clearly is described, composition and the step of each example described in general manner according to function in the above description.These functions are carried out with hardware or software mode actually, depend on application-specific and the design constraint of technical scheme.The professional and technical personnel can specifically should be used for realizing described function with distinct methods to each, but this realization should not thought the scope that exceeds the application.
The method of describing in conjunction with embodiment disclosed herein or the step of algorithm can use the software module of hardware, processor execution, and perhaps both combination is implemented.Software module can be placed in the storage medium of any other form known in random asccess memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technical field.
Above-described embodiment; purpose, technical scheme and beneficial effect to the application further describe; institute is understood that; the above is only the application's embodiment; and be not used in the protection range that limits the application; all within the application's spirit and principle, any modification of making, be equal to replacement, improvement etc., within all should being included in the application's protection range.