CN103259863B - Based on the system and method that the control zookeeper of cluster serves - Google Patents

Based on the system and method that the control zookeeper of cluster serves Download PDF

Info

Publication number
CN103259863B
CN103259863B CN201310184832.9A CN201310184832A CN103259863B CN 103259863 B CN103259863 B CN 103259863B CN 201310184832 A CN201310184832 A CN 201310184832A CN 103259863 B CN103259863 B CN 103259863B
Authority
CN
China
Prior art keywords
zookeeper
server
service
cluster
control
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.)
Expired - Fee Related
Application number
CN201310184832.9A
Other languages
Chinese (zh)
Other versions
CN103259863A (en
Inventor
井淑明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Opzoon Technology Co Ltd
Original Assignee
Opzoon Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Opzoon Technology Co Ltd filed Critical Opzoon Technology Co Ltd
Priority to CN201310184832.9A priority Critical patent/CN103259863B/en
Publication of CN103259863A publication Critical patent/CN103259863A/en
Application granted granted Critical
Publication of CN103259863B publication Critical patent/CN103259863B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a kind of method that control zookeeper based on cluster serves, comprising: in the cluster running n station server, select m station server wherein to start zookeeper service, m is the odd number being less than n; Record the server that zookeeper serves place respectively, and record result is distributed in cluster; When cluster all restart or m zookeeper serve below place server half delay machine time, control more than half zookeeper service started zookeeper service server in last time starts, residue zookeeper service starts on the server being not activated zookeeper arbitrarily; The invention enables when whole cluster reboot or zookeeper serve the server at place more than half delay machine time, the data of zookeeper service are not moved, and keep integrality and the correctness of data.

Description

Based on the system and method that the control zookeeper of cluster serves
Technical field
The present invention relates to distributed system Clustering field, particularly a kind of control zookeeper based on cluster system and method for serving.
Background technology
In the prior art, the zookeeper service based on cluster utilizes parametric controller below to be started usually:
1, basis: each server (node) in cluster starts a management service (hereinafter referred to as worker), this service can control the startup of the upper service of this node, closedown and detection;
2, leader election: by electing a leader between worker, and after this leader dies, can re-elect; Worker on all node only needs to set up tcp with leader and is connected, and does not need to set up extra communication connection between worker;
3, delivery of services: after electing leader, leader obtains the physical resource of all node, Service Source and physical attribute, and according to set rule distribution zookeeper service;
4, serve setup rule: zookeeper can be customized according to actual needs and serve setup rule, such as, formulate quantity that zookeeper service starts, zookeeper service starts and start requirement of physical attribute etc. to the requirement of physical resource and zookeeper service;
5, service starts: leader elects the node of startup according to rule, and the worker to this node sends the message that tcp starts zookeeper service, and worker starts to start zookeeper service, and the result started is fed back to leader;
6, service detection: worker starts zookeeper and serves the detection that can start zookeeper service successfully, once zookeeper service is died, will by tcp message report to leader, trigger leader and reselect node startup zookeeper service, realize the transfer of zookeeper service.
Above-mentioned parametric controller achieves the detection of accurate distribution that the zookeeper based on cluster serves, control that zookeeper service starts and zookeeper service state, but in the formulation of above-mentioned delivery of services, service setup rule, there is following shortcoming in prior art:
1) when when there being zookeeper more than half service, (server that such as zookeeper serves place delay machine) quits work because certain reason, these zookeeper services stopped will be transferred to other servers being not activated zookeeper service automatically and get on, but due to the service data of Zookeeper be stored in zookeeper to serve this locality of place server, after transfer, these data will be lost, and namely have zookeeper loss of data more than half to become 0; And want synchrodata between zookeeper services all in cluster, and the identical data of serving with zookeeper more than half is for foundation, the data of serving due to zookeeper more than half become 0, whole like this cluster will think data be 0 be only correct, data syn-chronization can be also 0 by the zookeeper service that other do not move, cause this company-data to be lost, cause disaster;
2) when whole cluster reboot, parametric controller is also the server that random selection starts zookeeper service, can not ensure that zookeeper service more than half is enabled in and originally has on the server of data, causes the risk of loss of data;
Based on this, prior art needs to be improved really.
Summary of the invention
For the deficiencies in the prior art, the invention provides the system and method that a kind of control zookeeper based on cluster serves, make when whole cluster reboot or zookeeper serve the server at place more than half delay machine time, the data of zookeeper service are not moved, and keep integrality and the correctness of data.
For realizing above object, the present invention is achieved by the following technical programs:
The invention provides a kind of method that control zookeeper based on cluster serves, comprise the following steps:
S1, in the cluster running n station server, select m station server wherein to start zookeeper service, m is the odd number being less than n;
S2, record described zookeeper respectively and serve the server at place, and record result is distributed on described n station server;
This record received is recorded in this locality by S3, described n station server in the form of a file;
S4, delay below the server half that described cluster all restarts or described m zookeeper serves place machine time, read local record file, and control more than half zookeeper service started zookeeper service server in last time starts, residue zookeeper service starts on the server being not activated zookeeper arbitrarily, and returns execution step S2.
Preferably, described step S4 comprises further:
When described m zookeeper serve the server at place more than half delay machine time, described in the zookeeper service of delaying on machine server do not transfer on other servers.
The present invention also provides a kind of control zookeeper based on cluster system of serving, and includes:
Zookeeper service starts module, and in the cluster running n station server, select m station server wherein to start zookeeper service, m is the odd number being less than n;
Distribution module, serves the server at place, and record result is distributed on described n station server for recording described zookeeper respectively;
Logging modle, makes described n station server that this record received is recorded in this locality in the form of a file;
Control zookeeper service module, for all restart when described cluster or delay below server half that described m zookeeper serves place machine time, read local record file, and control more than half zookeeper service started zookeeper service server in last time starts, residue zookeeper service starts on the server being not activated zookeeper arbitrarily.
Preferably, described control zookeeper service module be further used for when described m zookeeper serve the server at place more than half delay machine time, described in the zookeeper service of delaying on machine server do not transfer on other servers.
The system and method that a kind of control zookeeper based on cluster provided by the invention serves, can realize following beneficial effect:
1) as long as node quantity is greater than m, the zookeeper quantity of service started can just be ensured;
2) as long as the disposable number broken down of node starting zookeeper service is less than (m+1)/2, parametric controller just can continue to start zookeeper service on other node, and synchrodata, continue to provide identical fault-tolerant ability.
3) when cluster needs all to restart, still can ensure the data of (m+1)/2 zookeeper service be before partial data, be then synchronized to other zookeeper service, make data integrity correct.
Accompanying drawing explanation
Fig. 1 is the flow chart of one embodiment of the invention;
Fig. 2 is the system block diagram of one embodiment of the invention.
Embodiment
Below in conjunction with drawings and Examples, the specific embodiment of the present invention is described in further detail.Following examples for illustration of the present invention, but are not used for limiting the scope of the invention.
The method that a kind of control zookeeper based on cluster provided by the invention serves, it uses based on the parametric controller in background technology, as shown in Figure 1, comprises the following steps:
S1, in the cluster running n station server, select m station server wherein to start zookeeper service, m is the odd number being less than n;
S2, record described zookeeper respectively and serve the server at place, and record result is distributed on described n station server;
This record received is recorded in this locality by S3, described n station server in the form of a file;
The leader of parametric controller controls each zookeeper service and starts successfully, and can notify all servers (comprising leader oneself), which m station server zookeeper service is enabled on and is recorded in this locality in the form of a file by all servers;
S4, delay below the server half that described cluster all restarts or described m zookeeper serves place machine time, the leader of parametric controller reads zookeeper in local record file and serves the record started last time, control more than half zookeeper service started zookeeper service server in last time starts, that is: (m+1)/2; Residue m-(m+1)/2 zookeeper service starts on the server being not activated zookeeper arbitrarily, and return and perform step S2.
Wherein, if cluster disposes first time, then can start m zookeeper service according to the selection m station server that described parametric controller is random.
Preferably, described step S4 comprises further:
When described m zookeeper serve the server at place more than half delay machine time, prevent loss of data, leader does not start zookeeper service, until delay, the server of machine is added back in cluster, zookeeper service more than half starts on the server that last time starts zookeeper, described in the zookeeper service of delaying on machine server do not transfer on other servers.
As shown in Figure 2, the present invention also provides a kind of control zookeeper based on cluster system of serving, and includes:
Zookeeper service starts module, and in the cluster running n station server, select m station server wherein to start zookeeper service, m is the odd number being less than n;
Distribution module, serves the server at place, and record result is distributed on described n station server for recording described zookeeper respectively;
Logging modle, makes described n station server that this record received is recorded in this locality in the form of a file;
Control zookeeper service module, for all restart when described cluster or delay below server half that described m zookeeper serves place machine time, read local record file, and control more than half zookeeper service started zookeeper service server in last time starts, residue zookeeper service starts on the server being not activated zookeeper arbitrarily.
Preferably, described control zookeeper service module be further used for when described m zookeeper serve the server at place more than half delay machine time, described in the zookeeper service of delaying on machine server do not transfer on other servers.
The system and method that a kind of control zookeeper based on cluster provided by the invention serves, can realize following beneficial effect:
1) as long as node quantity is greater than m, the zookeeper quantity of service started can just be ensured;
2) as long as the disposable number broken down of node starting zookeeper service is less than (m+1)/2, parametric controller just can continue to start zookeeper service on other node, and synchrodata, continue to provide identical fault-tolerant ability.
3) when cluster needs all to restart, still can ensure the data of (m+1)/2 zookeeper service be before partial data, be then synchronized to other zookeeper service, make data integrity correct.
Above execution mode is only for illustration of the present invention; and be not limitation of the present invention; the those of ordinary skill of relevant technical field; without departing from the spirit and scope of the present invention; can also make a variety of changes and modification; therefore all equivalent technical schemes also belong to category of the present invention, and scope of patent protection of the present invention should be defined by the claims.

Claims (2)

1., based on the method that the control zookeeper of cluster serves, it is characterized in that, comprise the following steps:
S1, in the cluster running n station server, select m station server wherein to start zookeeper service, m is the odd number being less than n;
S2, record described zookeeper respectively and serve the server at place, and record result is distributed on described n station server;
This record received is recorded in this locality by S3, described n station server in the form of a file;
S4, delay below the server half that described cluster all restarts or described m zookeeper serves place machine time, read local record file, and control more than half zookeeper service started zookeeper service server in last time starts, residue zookeeper service starts on the server being not activated zookeeper arbitrarily, and returns execution step S2;
Described step S4 comprises further:
When described m zookeeper serve the server at place more than half delay machine time, described in the zookeeper service of delaying on machine server do not transfer on other servers.
2., based on the system that the control zookeeper of cluster serves, it is characterized in that, include:
Zookeeper service starts module, and in the cluster running n station server, select m station server wherein to start zookeeper service, m is the odd number being less than n;
Distribution module, serves the server at place, and record result is distributed on described n station server for recording described zookeeper respectively;
Logging modle, makes described n station server that this record received is recorded in this locality in the form of a file;
Control zookeeper service module, for all restart when described cluster or delay below server half that described m zookeeper serves place machine time, read local record file, and control more than half zookeeper service started zookeeper service server in last time starts, residue zookeeper service starts on the server being not activated zookeeper arbitrarily;
Described control zookeeper service module be further used for when described m zookeeper serve the server at place more than half delay machine time, described in the zookeeper service of delaying on machine server do not transfer on other servers.
CN201310184832.9A 2013-05-17 2013-05-17 Based on the system and method that the control zookeeper of cluster serves Expired - Fee Related CN103259863B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310184832.9A CN103259863B (en) 2013-05-17 2013-05-17 Based on the system and method that the control zookeeper of cluster serves

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310184832.9A CN103259863B (en) 2013-05-17 2013-05-17 Based on the system and method that the control zookeeper of cluster serves

Publications (2)

Publication Number Publication Date
CN103259863A CN103259863A (en) 2013-08-21
CN103259863B true CN103259863B (en) 2016-01-06

Family

ID=48963553

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310184832.9A Expired - Fee Related CN103259863B (en) 2013-05-17 2013-05-17 Based on the system and method that the control zookeeper of cluster serves

Country Status (1)

Country Link
CN (1) CN103259863B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103595781B (en) * 2013-11-11 2016-08-17 华为技术有限公司 A kind of service providing method based on zookeeper, first server and system
CN103747044B (en) * 2013-12-24 2017-04-19 汉柏科技有限公司 Service locking method and system
CN111506555B (en) * 2020-03-13 2023-05-23 平安科技(深圳)有限公司 Druid cluster migration method and device and computer equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101977124A (en) * 2010-11-05 2011-02-16 山东中创软件工程股份有限公司 Service clustering method and system based on ZooKeeper technology
EP2369825A2 (en) * 2003-01-03 2011-09-28 Nortel Networks Ltd. Distributed services based on presence technology

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2369825A2 (en) * 2003-01-03 2011-09-28 Nortel Networks Ltd. Distributed services based on presence technology
CN101977124A (en) * 2010-11-05 2011-02-16 山东中创软件工程股份有限公司 Service clustering method and system based on ZooKeeper technology

Also Published As

Publication number Publication date
CN103259863A (en) 2013-08-21

Similar Documents

Publication Publication Date Title
CN107087033B (en) Message pushing method and device, storage medium and computer equipment
CN102769667B (en) Method, equipment and system for generating ID
EP3493471A1 (en) Data disaster recovery method, apparatus and system
CN108712501B (en) Information sending method and device, computing equipment and storage medium
CN110309161B (en) Data synchronization method and device and server
CN108287751B (en) Task execution method and device and distributed system
CN105824846B (en) Data migration method and device
WO2021203979A1 (en) Operation and maintenance processing method and apparatus, and computer device
CN109361525B (en) Method, device, control terminal and medium for restarting distributed deployment of multiple services
CN110083651B (en) Data loading method and device
CN102609349A (en) Method and system for screen capture in server failure
CN107666493B (en) Database configuration method and equipment thereof
CN104965727A (en) Method and device for restarting server
WO2019057193A1 (en) Data deletion method and distributed storage system
CN107040576A (en) Information-pushing method and device, communication system
CN104252397A (en) Realizing method for supporting automatic backup of cloud platform user file
CN108140035B (en) Database replication method and device for distributed system
CN103259863B (en) Based on the system and method that the control zookeeper of cluster serves
CN106301840A (en) The sending method of two-way converting detection BFD message and device
CN104516744A (en) Software updating method and system
CN105453518B (en) Synchronization of metering networks
CN108241616B (en) Message pushing method and device
CN112835978A (en) Data storage method and device and computer equipment
CN110958287B (en) Operation object data synchronization method, device and system
CN104079663A (en) Distributed type real-time synchronizing network system and data annunciating method thereof

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
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: 20160106

Termination date: 20180517