CN103259863A - System and method for controlling zookeeper services based on clusters - Google Patents

System and method for controlling zookeeper services based on clusters Download PDF

Info

Publication number
CN103259863A
CN103259863A CN2013101848329A CN201310184832A CN103259863A CN 103259863 A CN103259863 A CN 103259863A CN 2013101848329 A CN2013101848329 A CN 2013101848329A CN 201310184832 A CN201310184832 A CN 201310184832A CN 103259863 A CN103259863 A CN 103259863A
Authority
CN
China
Prior art keywords
zookeeper
server
service
zookeeper service
cluster
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN2013101848329A
Other languages
Chinese (zh)
Other versions
CN103259863B (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

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a method for controlling zookeeper services based on clusters. The method comprises the following steps: m servers are selected from the clusters where n servers are in operation, and the zookeeper services of the m servers are started, wherein the m is an odd number which is less than n; the servers where the zookeeper services are in operation are recorded respectively, and recorded results are distributed in the clusters; when all the clusters are started again or less than a half number of the m servers where the zookeeper services are in operation are delayed, more than a half number of the zookeeper services are controlled to be started on the servers where the zookeeper services are started last time, and the remaining zookeeper services are started on any of the servers where the zookeeper services are not started. By means of the method for controlling the zookeeper services based on the clusters, when all the clusters are restarted or more than a half number of the servers where the zookeeper services are in operation are delayed, data of the zookeeper services do not migrate, and therefore integrity and correctness of the data are maintained.

Description

System and method based on the control zookeeper of cluster service
Technical field
The present invention relates to distributed system Clustering field, particularly a kind of system and method for serving based on the control zookeeper of cluster.
Background technology
In the prior art, the zookeeper service based on cluster utilizes following control platform to be started usually:
1, basis: each server (node) in the cluster starts a management service (hereinafter referred to as worker), and this service can be controlled the last startup of serving of this node, close and detect;
2, leader election: by electing a leader, and after this leader dies, can re-elect between the worker; Worker on all node only need set up tcp with leader and be connected, and does not need to set up extra communicating to connect between the worker;
3, delivery of services: after electing leader, leader obtains physical resource, Service Source and the physical attribute of all node, and according to set rule distribution zookeeper service;
4, service starts regular: can customize the zookeeper service according to actual needs and start rule, quantity, the zookeeper service of for example formulating zookeeper service startup start the requirement of physical resource and zookeeper service are started requirement to physical attribute etc.;
5, service starts: leader elects the node of startup according to rule, sends the message that tcp starts the zookeeper service to the worker of this node, and worker begins to start the zookeeper service, and a result who starts is fed back to leader;
6, after serving successfully, service detection: worker startup zookeeper can start the detection of zookeeper service, in case the zookeeper service is died, will give leader by the tcp message report, trigger leader and reselect node startup zookeeper service, realize the transfer of zookeeper service.
Above-mentioned control platform has been realized based on the accurate distribution of the zookeeper service of cluster, the control of zookeeper service startup and the detection of zookeeper service state, but there is following shortcoming in the formulation in above-mentioned delivery of services, service startup rule in the prior art:
1) as zookeeper more than half service because certain reason (for example the server at zookeeper service place delay machine) when quitting work, the zookeeper service that these stop will to be transferred to other servers that are not activated the zookeeper service automatically and get on, yet because the service data of Zookeeper is this locality that is stored in zookeeper service place server, shifting these data of back will lose, and namely has zookeeper loss of data more than half to become 0; And all zookeeper want synchrodata between serving in the cluster, and the identical data with zookeeper services more than half is foundation, because the data of zookeeper more than half service become 0, whole like this cluster will think data be 0 be only correct, other do not have the zookeeper service of migration can be 0 with data sync also, cause this cluster loss of data, cause disaster;
2) when whole cluster reboot, the control platform also is the server of selection startup zookeeper service at random, can not guarantee that zookeeper service more than half is enabled on the server that data are arranged originally, causes the risk of loss of data;
Based on this, prior art awaits improving really.
Summary of the invention
At the deficiencies in the prior art, the invention provides a kind of system and method for serving based on the control zookeeper of cluster, make that the server at place is more than half delays during machine when whole cluster reboot or zookeeper serve, the data of zookeeper service are not moved, and keep integrality and the correctness of data.
For realizing above purpose, the present invention is achieved by the following technical programs:
The invention provides a kind of control zookeeper service method based on cluster, may further comprise the steps:
S1, in the cluster of operation n station server, select m station server wherein to start the zookeeper service, m is the odd number less than n;
S2, record the server at described zookeeper service place respectively, and will record the result and be distributed on the described n station server;
This record that S3, described n station server will receive is recorded in this locality with the form of file;
S4, when described cluster all restarts or delays machine below the server half at described m zookeeper service place, read the local record file, and control the server that more than half zookeeper service started the zookeeper service in last time and start, residue zookeeper service starts at the server that is not activated zookeeper arbitrarily, and returns execution in step S2.
Preferably, described step S4 further comprises:
When the server at described m zookeeper service place is more than half when delaying machine, the zookeeper service on the described machine server of delaying is not transferred on other servers.
The present invention also provides a kind of system that serves based on the control zookeeper of cluster, includes:
The zookeeper service starts module, is used for the cluster at operation n station server, selects m station server wherein to start the zookeeper service, and m is the odd number less than n;
Distribution module is used for recording respectively the server at described zookeeper service place, and will record the result and be distributed on the described n station server;
Logging modle makes this record that described n station server will receive be recorded in this locality with the form of file;
Control zookeeper service module, be used for all restarting or described m zookeeper serves when delaying machine below the server half at place when described cluster, read the local record file, and control the server that more than half zookeeper service started the zookeeper service in last time and start, residue zookeeper service starts at the server that is not activated zookeeper arbitrarily.
Preferably, described control zookeeper service module is further used for that the server at place is more than half delays during machine when described m zookeeper serves, and the zookeeper on the described machine server of delaying serves and do not transfer on other servers.
A kind of system and method for serving based on the control zookeeper of cluster provided by the invention, can realize following beneficial effect:
1) as long as node quantity greater than m, just can guarantee the zookeeper quantity of service that starts;
2) be less than (m+1)/2 as long as start the disposable number that breaks down of node of zookeeper service, the control platform just can continue to start the zookeeper service at other node, and synchrodata, continues the fault-tolerant ability that provides identical.
3) when cluster need all be restarted, can guarantee that still the data of (m+1)/2 a zookeeper service are partial datas before, give other zookeeper service then synchronously, make data integrity correct.
Description of drawings
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 are used for explanation the present invention, but are not used for limiting the scope of the invention.
A kind of control zookeeper service method based on cluster provided by the invention, it uses based on the control platform in the background technology, as shown in Figure 1, may further comprise the steps:
S1, in the cluster of operation n station server, select m station server wherein to start the zookeeper service, m is the odd number less than n;
S2, record the server at described zookeeper service place respectively, and will record the result and be distributed on the described n station server;
This record that S3, described n station server will receive is recorded in this locality with the form of file;
After the leader of control platform controls each zookeeper service and starts successfully, can notify all servers (comprising leader oneself), all servers serve to be enabled in the form with file is recorded in this locality on which m station server with zookeeper;
S4, when described cluster all restarts or delays machine below the server half at described m zookeeper service place, the leader of control platform reads the record of zookeeper service startup last time in the local record file, control the server that more than half zookeeper service started the zookeeper service in last time and start, that is: (m+1)/2; Residue m-(m+1)/2 zookeeper service starts at the server that is not activated zookeeper arbitrarily, and returns execution in step S2.
Wherein, if cluster is to dispose for the first time, then can start m zookeeper service according to described control platform selection m station server at random.
Preferably, described step S4 further comprises:
When the server at described m zookeeper service place is more than half when delaying machine, prevent loss of data, leader does not start the zookeeper service, server up to the machine of delaying is added back in the cluster, the server that zookeeper service more than half had started zookeeper in last time starts, and the zookeeper service on the described machine server of delaying is not transferred on other servers.
As shown in Figure 2, the present invention also provides a kind of system that serves based on the control zookeeper of cluster, includes:
The zookeeper service starts module, is used for the cluster at operation n station server, selects m station server wherein to start the zookeeper service, and m is the odd number less than n;
Distribution module is used for recording respectively the server at described zookeeper service place, and will record the result and be distributed on the described n station server;
Logging modle makes this record that described n station server will receive be recorded in this locality with the form of file;
Control zookeeper service module, be used for all restarting or described m zookeeper serves when delaying machine below the server half at place when described cluster, read the local record file, and control the server that more than half zookeeper service started the zookeeper service in last time and start, residue zookeeper service starts at the server that is not activated zookeeper arbitrarily.
Preferably, described control zookeeper service module is further used for that the server at place is more than half delays during machine when described m zookeeper serves, and the zookeeper on the described machine server of delaying serves and do not transfer on other servers.
A kind of system and method for serving based on the control zookeeper of cluster provided by the invention, can realize following beneficial effect:
1) as long as node quantity greater than m, just can guarantee the zookeeper quantity of service that starts;
2) be less than (m+1)/2 as long as start the disposable number that breaks down of node of zookeeper service, the control platform just can continue to start the zookeeper service at other node, and synchrodata, continues the fault-tolerant ability that provides identical.
3) when cluster need all be restarted, can guarantee that still the data of (m+1)/2 a zookeeper service are partial datas before, give other zookeeper service then synchronously, make data integrity correct.
Above execution mode only is used for explanation the present invention; and be not limitation of the present invention; the those of ordinary skill in relevant technologies field; under the situation that does not break away from the spirit and scope of the present invention; can also make a variety of changes and modification; therefore all technical schemes that are equal to also belong to category of the present invention, and scope of patent protection of the present invention should be defined by the claims.

Claims (4)

1. the control zookeeper service method based on cluster is characterized in that, may further comprise the steps:
S1, in the cluster of operation n station server, select m station server wherein to start the zookeeper service, m is the odd number less than n;
S2, record the server at described zookeeper service place respectively, and will record the result and be distributed on the described n station server;
This record that S3, described n station server will receive is recorded in this locality with the form of file;
S4, when described cluster all restarts or delays machine below the server half at described m zookeeper service place, read the local record file, and control the server that more than half zookeeper service started the zookeeper service in last time and start, residue zookeeper service starts at the server that is not activated zookeeper arbitrarily, and returns execution in step S2.
2. the method for claim 1 is characterized in that, described step S4 further comprises:
When the server at described m zookeeper service place is more than half when delaying machine, the zookeeper service on the described machine server of delaying is not transferred on other servers.
3. the system based on the control zookeeper service of cluster is characterized in that, includes:
The zookeeper service starts module, is used for the cluster at operation n station server, selects m station server wherein to start the zookeeper service, and m is the odd number less than n;
Distribution module is used for recording respectively the server at described zookeeper service place, and will record the result and be distributed on the described n station server;
Logging modle makes this record that described n station server will receive be recorded in this locality with the form of file;
Control zookeeper service module, be used for all restarting or described m zookeeper serves when delaying machine below the server half at place when described cluster, read the local record file, and control the server that more than half zookeeper service started the zookeeper service in last time and start, residue zookeeper service starts at the server that is not activated zookeeper arbitrarily.
4. system as claimed in claim 3, it is characterized in that, described control zookeeper service module is further used for that the server at place is more than half delays during machine when described m zookeeper serves, and the zookeeper on the described machine server of delaying serves and 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 true CN103259863A (en) 2013-08-21
CN103259863B 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)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103595781A (en) * 2013-11-11 2014-02-19 华为技术有限公司 Service providing method, first server and system based on zookeeper
CN103747044A (en) * 2013-12-24 2014-04-23 汉柏科技有限公司 Service locking method and system
WO2021179584A1 (en) * 2020-03-13 2021-09-16 平安科技(深圳)有限公司 Method and apparatus for migrating druid cluster, computer device and storage medium

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

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103595781A (en) * 2013-11-11 2014-02-19 华为技术有限公司 Service providing method, first server and system based on zookeeper
CN103595781B (en) * 2013-11-11 2016-08-17 华为技术有限公司 A kind of service providing method based on zookeeper, first server and system
CN103747044A (en) * 2013-12-24 2014-04-23 汉柏科技有限公司 Service locking method and system
CN103747044B (en) * 2013-12-24 2017-04-19 汉柏科技有限公司 Service locking method and system
WO2021179584A1 (en) * 2020-03-13 2021-09-16 平安科技(深圳)有限公司 Method and apparatus for migrating druid cluster, computer device and storage medium

Also Published As

Publication number Publication date
CN103259863B (en) 2016-01-06

Similar Documents

Publication Publication Date Title
CN110311831B (en) Container cloud-based system resource monitoring method and related equipment
US10331625B2 (en) Managing sequential data store
US9367410B2 (en) Failover mechanism in a distributed computing system
CN111314479B (en) Data processing method and equipment
EP2648114B1 (en) Method, system, token conreoller and memory database for implementing distribute-type main memory database system
CN106354583B (en) A kind of heat backup method and system of MySQL database
CN110309161B (en) Data synchronization method and device and server
CN105824846B (en) Data migration method and device
CN109361525B (en) Method, device, control terminal and medium for restarting distributed deployment of multiple services
WO2019057193A1 (en) Data deletion method and distributed storage system
CN105069152B (en) data processing method and device
CN109173270B (en) Game service system and implementation method
CN110099084B (en) Method, system and computer readable medium for ensuring storage service availability
CN104965727A (en) Method and device for restarting server
CN107040576A (en) Information-pushing method and device, communication system
CN108140035B (en) Database replication method and device for distributed system
CN105208060A (en) Service data synchronization method, service data synchronization device and service data synchronization system
CN105208058A (en) Information exchange system based on web session sharing
CN103997525A (en) Distributed data synchronization method and system
CN111726388A (en) Cross-cluster high-availability implementation method, device, system and equipment
CN106372160A (en) Distributive database and management method
CN103259863B (en) Based on the system and method that the control zookeeper of cluster serves
CN107943615B (en) Data processing method and system based on distributed cluster
US10853892B2 (en) Social networking relationships processing method, system, and storage medium
US10637748B2 (en) Method and apparatus for establishing interface between VNFMS, and system

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

Granted publication date: 20160106

Termination date: 20180517

CF01 Termination of patent right due to non-payment of annual fee