CN117785560A - Method and system for realizing nexus master and slave based on Kubernetes - Google Patents

Method and system for realizing nexus master and slave based on Kubernetes Download PDF

Info

Publication number
CN117785560A
CN117785560A CN202311835513.XA CN202311835513A CN117785560A CN 117785560 A CN117785560 A CN 117785560A CN 202311835513 A CN202311835513 A CN 202311835513A CN 117785560 A CN117785560 A CN 117785560A
Authority
CN
China
Prior art keywords
instance
nexus
master
kubernetes
main
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.)
Pending
Application number
CN202311835513.XA
Other languages
Chinese (zh)
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.)
Hangzhou Harmonycloud Technology Co Ltd
Original Assignee
Hangzhou Harmonycloud 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 Hangzhou Harmonycloud Technology Co Ltd filed Critical Hangzhou Harmonycloud Technology Co Ltd
Priority to CN202311835513.XA priority Critical patent/CN117785560A/en
Publication of CN117785560A publication Critical patent/CN117785560A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method for realizing a master and slave of nexus based on Kubernetes, belonging to the field of computers; the method comprises the following steps: deploying a nexus in kubernetes clusters; the nexus database comprises a main instance and a standby instance; creating a service of a main instance in a kubernetes cluster; kubernetes cluster imports traffic to the master instance through service services; monitoring file changes in the main instance and synchronizing to the standby instance; and monitoring the state of the main instance, and switching the standby instance into the main instance when the state of the main instance is unavailable. The invention also provides a nexus master and slave implementation system based on the Kubernetes. The invention synchronizes the data of the Nexus in real time, can switch the standby instance and provide service to the outside when the Nexus main instance fails.

Description

Method and system for realizing nexus master and slave based on Kubernetes
Technical Field
The invention relates to the technical field of computers, in particular to a method and a system for realizing a nexus master and slave based on Kubernetes.
Background
As enterprise-level applications increase and demand increases, developers increasingly need reliable storage libraries to store and share components. The nexus is used as a popular storage library manager for managing and distributing components, provides a convenient package management mode for developers, facilitates collaborative development among departments, and is one of essential component software essential for the DevOps. Since community version nexus does not provide high availability capability, services once failed can affect the whole application development, testing, and online flow of the enterprise. The high availability capability of nexus is very important.
In addition, as kubernetes helps enterprises to rapidly deploy and manage containerized application programs in cloud-on-enterprise processes, the effect of improving the reliability, portability and expandability of the application programs is more and more prominent, and more enterprises deploy various application programs on kubernetus, wherein the application programs also comprise nexus. How to guarantee the high availability of nexus in kubernetes scene also needs to be solved.
The conventional nexus suffers from the following disadvantages:
1) Traditional nexus usually operates in a single instance state, data backup is mainly performed by cold backup, and when a nexus node fails and cannot be recovered, the backup data cannot be used for pulling up a new instance and providing services to the outside.
2) The data cold standby cannot be automatically realized, and the script is generally written manually. And the cold standby is generally executed at regular time, so that the real-time performance of the data cannot be ensured.
3) The cold standby is also typically full-capacity cold standby, which is time consuming for a large amount of data of nexus.
4) The manual pulling of the nexus instance by the backup data also requires an external load balancing related policy to implement the instance switch of the nexus or the manual switch to implement the traffic importation onto the new nexus instance.
Disclosure of Invention
The invention aims to provide a method and a system for realizing a nexus master and slave based on Kubernetes.
In order to solve the technical problems, the invention provides a method for realizing a nexus master and slave based on Kubernetes, which comprises the following steps:
deploying a nexus in kubernetes clusters; the nexus database comprises a main instance and a standby instance;
creating a service of a main instance in a kubernetes cluster;
kubernetes cluster imports traffic to the master instance through service services;
monitoring file changes in the main instance and synchronizing to the standby instance;
and monitoring the state of the main instance, and switching the standby instance into the main instance when the state of the main instance is unavailable.
Preferably, the method for deploying the nexus in the kubernetes cluster specifically comprises the following steps:
the nexus is deployed in kubernetes clusters in the form of stateful deployment statefulset.
Preferably, a master=true tag is marked on the main instance;
the master=false label is marked on the standby example.
Preferably, the kubernetes cluster imports traffic to the main instance through a service, specifically comprising the following steps:
the traffic of the user accessing the service is imported to the main instance of the label master=true through the service exposure mechanism of kubernetes.
Preferably, the method monitors file changes in the main instance, and specifically comprises the following steps:
file changes in the master instance are monitored using an inotify tool.
Preferably, the synchronization to the standby instance specifically comprises the following steps:
when the files in the main instance change, the rsync tool is used for carrying out real-time incremental synchronization to the standby instance, and the standby instance and the main instance data are kept consistent.
Preferably, the standby instance is switched to the main instance, and the method specifically comprises the following steps:
the original standby instance is marked with a label of master=true, and the original main instance is marked with a label of master=false.
The invention also provides a nexus master and slave implementation system based on Kubernetes, which comprises:
a nexus deployment module for deploying nexus in kubernetes clusters; the nexus database comprises a main instance and a standby instance;
a service creation service module for creating a service of a main instance in the kubernetes cluster;
the importing module is used for importing the flow to the main instance by the kubernetes cluster through the service;
the backup module is used for monitoring file changes in the main instance and synchronizing to the backup instance;
and the switching module is used for monitoring the state of the main instance, and switching the standby instance into the main instance when the state of the main instance is unavailable.
Compared with the prior art, the invention has the beneficial effects that:
when the nexus node fails and cannot be recovered, the backup data can be used for pulling up a new instance and providing service to the outside;
the invention can backup data in real time, and ensures the real-time property of the data;
the invention does not need to fully backup data, thereby saving time;
the invention synchronizes the data of the Nexus in real time, can switch the standby instance and provide service to the outside when the Nexus main instance fails.
Drawings
The following describes the embodiments of the present invention in further detail with reference to the accompanying drawings.
FIG. 1 is a schematic flow chart of a method for implementing a nexus master/slave based on Kubernetes;
fig. 2 is a schematic diagram of switching a standby instance to a primary instance.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. The present invention may be embodied in many other forms than those herein described, and those skilled in the art will readily appreciate that the present invention may be similarly embodied without departing from the spirit or essential characteristics thereof, and therefore the present invention is not limited to the specific embodiments disclosed below.
The terminology used in the one or more embodiments of the specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the specification. As used in this specification, one or more embodiments and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present description refers to any or all possible combinations including one or more of the associated listed items.
It should be understood that, although the terms first, second, etc. may be used in one or more embodiments of this specification to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first may also be referred to as a second, and similarly, a second may also be referred to as a first, without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
The invention is described in further detail below with reference to the attached drawing figures:
the invention provides a method for realizing a nexus master and slave based on Kubernetes, which is shown in figure 1 and comprises the following steps:
deploying a nexus in kubernetes clusters; the nexus database comprises a main instance and a standby instance;
creating a service of a main instance in a kubernetes cluster;
kubernetes cluster imports traffic to the master instance through service services;
monitoring file changes in the main instance and synchronizing to the standby instance;
and monitoring the state of the main instance, and switching the standby instance into the main instance when the state of the main instance is unavailable.
Preferably, the method for deploying the nexus in the kubernetes cluster specifically comprises the following steps:
the nexus is deployed in kubernetes clusters in the form of stateful deployment statefulset.
Preferably, a master=true tag is marked on the main instance;
the master=false label is marked on the standby example.
Preferably, the kubernetes cluster imports traffic to the main instance through a service, specifically comprising the following steps:
and importing the traffic of the user actor to access the service to the main instance of the mark master=true tag through a service exposure mechanism of kubernetes.
Preferably, the method monitors file changes in the main instance, and specifically comprises the following steps:
file changes in the master instance are monitored using an inotify tool.
Preferably, the synchronization to the standby instance specifically comprises the following steps:
when the files in the main instance change, the rsync tool is used for carrying out real-time incremental synchronization to the standby instance, and the standby instance and the main instance data are kept consistent.
Preferably, the standby instance is switched to the main instance, and the method specifically comprises the following steps:
the original standby instance is marked with a label of master=true, and the original main instance is marked with a label of master=false.
The invention also provides a nexus master and slave implementation system based on Kubernetes, which comprises:
a nexus deployment module for deploying nexus in kubernetes clusters; the nexus database comprises a main instance and a standby instance;
a service creation service module for creating a service of a main instance in the kubernetes cluster;
the importing module is used for importing the flow to the main instance by the kubernetes cluster through the service;
the backup module is used for monitoring file changes in the main instance and synchronizing to the backup instance;
and the switching module is used for monitoring the state of the main instance, and switching the standby instance into the main instance when the state of the main instance is unavailable.
In order to better illustrate the technical effects of the present invention, the present invention provides the following specific embodiments to illustrate the above technical flow:
embodiment 1, a method for implementing a nexus master and slave based on Kubernetes, as shown in fig. 2, includes the following steps:
1) The nexus is deployed in kubernetes clusters in the form of stateful deployment statefulset, running two instances, nexus-0 and nexus-1. And meanwhile, the control device is also deployed in the kubernetes cluster.
2) The control device monitors two nexus examples, marks a label of master=true on any example, and takes the label as a main example; another example marks master=label label of false as an example.
3) The control device creates a service with a master=true label as a selector in the cluster, so that the traffic of a user accessing the service is imported to the instance of the master=true through a service exposure mechanism of kubernetes.
4) And the control device monitors file change in the current main instance by using an inotify tool, and once the file change occurs, the control device uses an rsync tool to perform real-time incremental synchronization to the standby instance, so as to keep the data of the standby instance and the main instance consistent.
5) And the control device monitors the state of the main instance, if the service state is unavailable, the original standby instance is marked as a master=true label, and the original main instance is marked as a master=false label. At this time, by the mechanism of kubernetes, the traffic can enter the master=true instance, so that the switching of the primary instance and the standby instance is realized. And the control device can convert the data synchronization direction into the current main instance to the standby instance, so that the data of the standby instance always keeps consistent with the main instance.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and the division of modules, or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units, modules, or components may be combined or integrated into another apparatus, or some features may be omitted, or not performed.
The units may or may not be physically separate, and the components shown as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such embodiments, the computer program may be downloaded and installed from a network via a communication portion, and/or installed from a removable medium. The above-described functions defined in the method of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU). The computer readable medium of the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The foregoing is merely illustrative of specific embodiments of the present invention, and the scope of the present invention is not limited thereto, but any changes or substitutions within the technical scope of the present invention should be covered by the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (8)

1. The method for realizing the nexus master and slave based on the Kubernetes is characterized by comprising the following steps of:
deploying a nexus in kubernetes clusters; the nexus database comprises a main instance and a standby instance;
creating a service of a main instance in a kubernetes cluster;
kubernetes cluster imports traffic to the master instance through service services;
monitoring file changes in the main instance and synchronizing to the standby instance;
and monitoring the state of the main instance, and switching the standby instance into the main instance when the state of the main instance is unavailable.
2. The method for realizing the nexus master and slave based on Kubernetes according to claim 1, wherein the method for arranging the nexus in Kubernetes cluster specifically comprises the following steps:
the nexus is deployed in kubernetes clusters in the form of stateful deployment statefulset.
3. The method for realizing the nexus master and slave based on Kubernetes according to claim 2, which is characterized in that:
marking master=true labels on the main instance;
the master=false label is marked on the standby example.
4. The method for implementing a Kubernetes-based nexus master and slave according to claim 3, wherein Kubernetes cluster imports traffic to a master instance through a service, specifically comprising the following steps:
the traffic of the user accessing the service is imported to the main instance of the label master=true through the service exposure mechanism of kubernetes.
5. The method for implementing the nexus master and slave based on Kubernetes according to claim 4, wherein the method for monitoring file changes in the master instance specifically comprises the following steps:
file changes in the master instance are monitored using an inotify tool.
6. The method for realizing the nexus master and slave based on Kubernetes according to claim 5, wherein the method for synchronizing to the slave instance specifically comprises the following steps:
when the files in the main instance change, the rsync tool is used for carrying out real-time incremental synchronization to the standby instance, and the standby instance and the main instance data are kept consistent.
7. The method for realizing the nexus master and slave based on Kubernetes according to claim 6, wherein the method for switching the slave instance to the master instance specifically comprises the following steps:
the original standby instance is marked with a label of master=true, and the original main instance is marked with a label of master=false.
8. A Kubernetes-based nexus master-slave implementation system for implementing a Kubernetes-based nexus master-slave implementation method according to any one of claims 1-7, comprising:
a nexus deployment module for deploying nexus in kubernetes clusters; the nexus database comprises a main instance and a standby instance;
a service creation service module for creating a service of a main instance in the kubernetes cluster;
the traffic import module is used for importing traffic to the main instance by the kubernetes cluster through the service;
the backup module is used for monitoring file changes in the main instance and synchronizing to the backup instance;
and the switching module is used for monitoring the state of the main instance, and switching the standby instance into the main instance when the state of the main instance is unavailable.
CN202311835513.XA 2023-12-27 2023-12-27 Method and system for realizing nexus master and slave based on Kubernetes Pending CN117785560A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311835513.XA CN117785560A (en) 2023-12-27 2023-12-27 Method and system for realizing nexus master and slave based on Kubernetes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311835513.XA CN117785560A (en) 2023-12-27 2023-12-27 Method and system for realizing nexus master and slave based on Kubernetes

Publications (1)

Publication Number Publication Date
CN117785560A true CN117785560A (en) 2024-03-29

Family

ID=90392437

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311835513.XA Pending CN117785560A (en) 2023-12-27 2023-12-27 Method and system for realizing nexus master and slave based on Kubernetes

Country Status (1)

Country Link
CN (1) CN117785560A (en)

Similar Documents

Publication Publication Date Title
CN109885316B (en) Hdfs-hbase deployment method and device based on kubernetes
CN101589371B (en) Method and system for transparent backup to a hierarchical storage system
CN112069265B (en) Synchronization method of configuration data, business data system, computer system and medium
US20220027249A1 (en) Automated methods and systems for troubleshooting problems in a distributed computing system
CN102981931A (en) Backup method and device for virtual machine
US10726042B2 (en) Replication control using eventually consistent meta-data
CN110795503A (en) Multi-cluster data synchronization method and related device of distributed storage system
US11055182B2 (en) Tagging data for automatic transfer during backups
CN112527310A (en) Multi-tenant data isolation method and device, computer equipment and storage medium
CN102646064A (en) Incremental virtual machine backup supporting migration
US9887889B1 (en) State reconciliation using event tracking and polling
US10055309B1 (en) Parallel restoration of a virtual machine's virtual machine disks
CN103036986A (en) Update notification provided on distributed application object
US20190266016A1 (en) Intelligent scheduling of backups
US6161135A (en) Method and apparatus for software features synchronization between software systems
US20080263079A1 (en) Data recovery in an enterprise data storage system
US20220261318A1 (en) Instant recovery of databases
CN117785560A (en) Method and system for realizing nexus master and slave based on Kubernetes
US10110502B1 (en) Autonomous host deployment in managed deployment systems
CN105468446A (en) Linux based method for realizing high availability of HPC job scheduling
CN109766235A (en) Configuration file detection method, system, equipment and medium based on software supervision
US20210334396A1 (en) Creating vendor-neutral data protection operations for vendors' application resources
US20230161733A1 (en) Change block tracking for transfer of data for backups
CN109995560A (en) Cloud resource pond management system and method
US11520668B2 (en) Vendor-neutral models of vendors' application resources

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination