Containerized Redis, database system and disaster prevention method

Through containerized Redis solution and Kubernetes orchestration tools, combined with Sentinel and Cluster deployment modes, Redis deployment complexity and high availability problems are solved, and Redis's efficient, automated deployment and computer room-level disaster recovery capabilities are achieved to meet the enterprise-level production environment. need.

CN118964095APending Publication Date: 2024-11-15CHINA EVERBRIGHT BANK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411135099.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

The deployment process of Redis in the prior art is complex and difficult to combine with container technology, and cannot meet the high availability and disaster recovery needs of enterprise-level production environments.

Method used

Adopting a containerized Redis solution, each instance in the Redis cluster is deployed in a container, combining Sentinel deployment mode and Cluster deployment mode, using container orchestration tools such as Kubernetes to achieve automated operation and maintenance, and achieving high deployment through master-slave instances across computer rooms. Availability and disaster recovery capabilities.

Benefits of technology

It realizes the simple and lightweight deployment of Redis, improves the degree of deployment automation, has high availability in both container and service dimensions, and can cope with computer room-level failure recovery, ensuring the reliability and stability of Redis services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118964095A_ABST
    Figure CN118964095A_ABST
Patent Text Reader

Abstract

According to the containerized Redis provided by the invention, based on the characteristics of the container, simple and lightweight deployment can be realized, and the automation degree of deployment can be improved. The containerized Redis-based database system not only has high availability of two dimensions of container and service, but also has a perfect containerized Redis instance monitoring alarm mechanism. The disaster prevention method based on containerized Redis can cope with fault recovery of a machine room (center) level, and master and slave instances are deployed across machine rooms to keep high availability of the machine room level.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of electronic information, and in particular to a containerized Redis, a database system, and a disaster prevention method. Background Art

[0002] Remote Dictionary Server (Redis) is an open source data structure storage system in memory. It can be used as a database, cache, and message middleware.

[0003] Container technology can be understood as effectively dividing the resources of a single operating system into isolated groups so as to better balance conflicting resource usage requirements between isolated groups.

[0004] Currently, there is no solution to combine Redis with container technology. Summary of the invention

[0005] The present application provides a containerized Redis, a database system, and a disaster prevention method, the purpose of which is to at least solve the problem of how to combine Redis with container technology.

[0006] In order to achieve the above objectives, this application provides the following technical solutions:

[0007] In a first aspect, the present application provides a containerized Redis, including:

[0008] Redis clusters and containers;

[0009] Each Redis instance in the Redis cluster is deployed in one of the containers.

[0010] Optionally, any Redis cluster using the Sentinel deployment mode includes:

[0011] Sentinel instance and Redis instance;

[0012] The Sentinel instance is decoupled from the Redis instance for deployment;

[0013] One Sentinel instance monitors multiple Redis instances.

[0014] Optionally, any Redis cluster adopting the cluster deployment mode includes: multiple shards;

[0015] Any of the shards includes: a Redis master instance and a Redis slave instance;

[0016] The Redis master instances in different shards are deployed on different machines, and different instances in the same shard are deployed on different machines.

[0017] A second aspect of the present application provides a database system, including:

[0018] Application module and log module;

[0019] The application module includes a Redis cluster and a container, and each Redis instance in the Redis cluster is deployed in one of the containers;

[0020] The application module is used to receive cache data of the service;

[0021] The log module is used to receive and store the logs of the application modules.

[0022] Optionally, the database system further includes:

[0023] The monitoring module is used to collect parameters of the Redis cluster.

[0024] Optionally, any Redis cluster using the Sentinel deployment mode includes:

[0025] Sentinel instance and Redis instance;

[0026] The Sentinel instance is decoupled from the Redis instance for deployment;

[0027] One Sentinel instance monitors multiple Redis instances.

[0028] Optionally, any Redis cluster adopting the cluster deployment mode includes: multiple shards;

[0029] Any of the shards includes: a Redis master instance and a Redis slave instance;

[0030] The Redis master instances in different shards are deployed on different machines, and different instances in the same shard are deployed on different machines.

[0031] A third aspect of the present application provides a disaster prevention method, which is applied to switch from a containerized Redis deployed in a main computer room to a containerized Redis deployed in a backup computer room, wherein the containerized Redis includes a Redis cluster and a container, and each Redis instance in the Redis cluster is deployed in one of the containers, and the method includes:

[0032] Synchronize the data of the Redis clusters of the main computer room and the backup computer room;

[0033] After data synchronization is completed, the Redis cluster in the main computer room is triggered to stop running;

[0034] A Redis master instance is elected from the Redis instances in the standby computer room.

[0035] Optionally, any Redis cluster adopting the Sentinel deployment mode includes a Sentinel instance and a Redis instance, the Sentinel instance is deployed decoupled from the Redis instance, and one Sentinel instance monitors multiple Redis instances;

[0036] The method further comprises:

[0037] Triggering the Sentinel instance in the computer room to stop running;

[0038] Optionally, any Redis cluster adopting the cluster deployment mode includes multiple shards, and any shard includes a Redis master instance and a Redis slave instance. The Redis master instances in different shards are deployed on different machines, and different instances in the same shard are deployed on different machines.

[0039] The triggering of stopping the Redis cluster in the main computer room includes:

[0040] Triggering each shard of the main computer room to stop running in turn;

[0041] The step of selecting a Redis master instance from the Redis instances in the standby computer room includes:

[0042] Select a Redis master instance from the Redis instances in each shard of the standby computer room;

[0043] The method further comprises:

[0044] Triggering an update of the cluster status file after a certain period of time.

[0045] The containerized Redis provided in this application, based on the characteristics of containers, can achieve simple and lightweight deployment, and can improve the degree of automation of deployment. The database system based on containerized Redis not only has high availability in both container and service dimensions, but also has a complete containerized Redis instance monitoring and alarm mechanism. The disaster prevention method based on containerized Redis can cope with fault recovery at the computer room (center) level, and the master-slave instance deployment across computer rooms maintains high availability at the computer room level. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0047] Figure 1 A containerized Redis example diagram provided for an embodiment of the present application;

[0048] Figure 2 This is an example diagram of a deployment structure of a Redis cluster in a containerized Redis disclosed in an embodiment of the present application;

[0049] Figure 3 This is another example diagram of a deployment structure of a Redis cluster in a containerized Redis disclosed in an embodiment of the present application;

[0050] Figure 4 An example diagram of a database system disclosed in an embodiment of the present application;

[0051] Figure 5 A flow chart of a disaster prevention method disclosed in an embodiment of the present application;

[0052] Figure 6 This is a flow chart of another disaster prevention method disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0053] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0054] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0055] The terms "first", "second" etc. in the full text of the application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable in appropriate circumstances, and this is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0056] The inventor found in the process of research that the current use of Redis (Remote Dictionary Server, remote dictionary service) is still mainly based on physical or virtual machine deployment, and a database system based on this is formed. However, when deploying the entire Redis cluster in this way, the process is often tedious and complicated, and when horizontal expansion is required, the deployment process needs to be repeated.

[0057] During the research, the inventors also found that, combined with containerization technology, all you need to do is package Redis and the required file directories into an image, and then publish and run it to complete all deployment tasks. The process is simpler and the service is lightweight. When you need to scale out instances, you only need to increase the number of copies of the containerized Redis application service. Most importantly, with the help of container orchestration and scheduling tools such as Kubernetes (a portable, scalable open source platform for managing containerized workloads and services that facilitates declarative configuration and automation), you can achieve automated operation and maintenance of Redis containers and avoid excessive manual intervention.

[0058] Therefore, it is necessary to combine Redis with container technology.

[0059] Figure 1 A containerized Redis provided for an embodiment of the present application includes: a Redis cluster and a container, wherein each Redis instance in the Redis cluster is deployed in a container. It is understandable that different containers are isolated from each other, and the specific isolation method is not repeated. The number of containers can be configured as needed.

[0060] In this application, Kubernetes, a container orchestration and scheduling tool, is used to implement the solution of Redis containerized deployment. Based on the service domain name resolution mechanism within the Kubernetes cluster, each instance in the Redis cluster communicates through a specific domain name. In a possible implementation, the instances in the Redis cluster communicate through pods (the smallest deployment unit of Kubernetes, a pod can run multiple containers and share pod resources) long domain names (because the container instance pod is not fixed and will be reallocated as the container starts), which can be achieved by relying on the DNS (Domain Name System) service within the Kubernetes cluster. This application does not elaborate on the communication process between the instances in the Redis cluster.

[0061] Among them, the Redis instance can resolve long domain names and communicate through a direct connection to the pod IP. Even if the pod IP changes dynamically, it will not be affected, ensuring the stability and efficiency of communication.

[0062] In actual applications, for the deployment modes supported by Redis, since the singleton and master-slave deployment modes are rarely selected as the enterprise production environment, even through Kubernetes container orchestration, it is impossible to transform it into a high-availability Redis service with performance that meets business requirements because it does not have automatic failover capabilities, and cannot meet the disaster recovery needs of enterprise-level production environments. Therefore, each Redis cluster in this application can adopt the Sentinel deployment mode or the Cluster deployment mode to improve the rationality of the architecture and meet high availability requirements. The following will be Figure 1 This deployment mode of any Redis cluster is described in detail. Figure 2 , is the Redis architecture using the Sentinel deployment mode proposed in the embodiment of the present application, Figure 2 The structure shown can be understood as an improved Sentinel deployment mode. Any Redis cluster deployed in this way can include: Sentinel instance and Redis instance. Sentinel instance is deployed separately, that is, it is decoupled from Redis instance in deployment.

[0063] In the embodiment of the present application, a Sentinel instance can be deployed on each machine (such as a VM (Virtual Manufacturing, virtual manufacturing technology) server / host, also known as a virtual machine), and a master and two slave Redis instances can be deployed on some of the machines. The Redis master instance can be recorded as Master, and the Redis slave instance can be recorded as Slave. Figure 2 As shown in the figure, a Sentinel instance is deployed on each machine where one master and two slave Redis instances are deployed, and a Sentinel instance is still deployed on other machines where no Redis instances are deployed. It should be noted that one Sentinel instance monitors multiple Redis instances, forming a public reused Sentinel monitoring cluster.

[0064] For example, in the Redis architecture of the Sentinel deployment mode, the same Sentinel cluster can be deployed in the main computer room and the backup computer room, such as Figure 2 In the application scenario shown, a Sentinel instance can be deployed on each of the five machines in the master / slave computer room. These five machines can be recorded as VM-0, VM-1, VM-2, VM-3 and VM-4, and the Sentinel instances deployed on the corresponding machines can be recorded as Sentinel 0, Sentinel 1, Sentinel 2, Sentinel 3 and Sentinel 4. Of course, in other scenarios, the Sentinel cluster can also include other numbers of Sentinel instances. Figure 2The following is an example of deploying five Sentinel instances.

[0065] After that, you can deploy three Redis instances in a master-slave relationship in the backup computer room, such as Figure 2 As shown in the figure, the Sentinel instances deployed on the Redis master instance (Master) machine, such as Sentinel 0 deployed on VM-0, can monitor the Redis instances deployed on each machine. Since the Sentinel instances in the Sentinel cluster communicate with each other to form a public multiplexed Sentinel monitoring cluster, other Sentinels deployed in the computer room can also monitor each Redis instance. Of course, the Redis master instance (Master) can also monitor the Redis slave instance (Slave) to dynamically elect a new Master after the Master fails.

[0066] Preferably, the three Redis instances deployed in the standby computer room of the present application can all serve as slaves of the Master deployed in the main computer room, so that the Master deployed in the main computer room can monitor other Redis instances (Slaves) deployed in the main and standby computer rooms. And the Sentinel cluster deployed in the standby computer room can also monitor the Master in the main computer room, which can be achieved through the Redis startup script, and the communication between the main computer room and the standby computer room can be achieved by using the DNS service to meet the monitoring function described in this preferred embodiment.

[0067] In this preferred implementation, the standby computer room can synchronize the data of the main computer room, so that after the main computer room fails, the standby computer room can be started in time to meet business needs. Of course, if the election priority of the Redis instance in the main and standby computer rooms is pre-configured when the Redis instance deployed in the standby computer room is started: the Redis instance deployed in the standby computer room takes precedence over the Redis instance deployed in the main computer room, after the standby computer room has synchronized the data of the main computer room, the Redis application in the main computer room can be directly "stopped". In this way, after the Master in the main computer room goes offline, a fault migration will occur, and a new Master will be elected from the three Redis instances deployed in the standby computer room. This application does not elaborate on the method for implementing the election of the Master. After that, the Sentinel application deployed in the main computer room can continue to be "stopped". After the main computer room application is stopped, the switch is completed. The whole process is smooth and the business is not perceived, which improves the efficiency and reliability of business processing.

[0068] It can be seen that in adopting Figure 2The Redis architecture of the structure shown can, on the one hand, prevent the voting mechanism of the Sentinel instance from being affected and causing abnormal failover function when the common carrier of the Redis and Sentinel instances "goes down". On the other hand, it can reuse the Sentinel instances, reduce the deployment of the Sentinel cluster, and make service deployment and operation lighter.

[0069] When there is a multi-center environment within the enterprise, the Redis cluster can maintain high availability at the computer room level through master-slave instance deployment across computer rooms. The Redis master-slave instance uses a synchronization mechanism to transmit data between different centers (such as the two center environments consisting of the main computer room and the backup computer room) (equivalent to hot standby). When a computer room-level failure occurs in any center, if the Redis in that center is a slave instance, the state of the Redis cluster does not change and the service is not affected; if Redis is the master instance, a failover will occur, and a new master instance will be voted out from the remaining instances to continue to provide services to the outside world. Therefore, no matter which computer room is offline, the Redis service will not be affected, which improves the reliability and stability of the Redis service.

[0070] In some embodiments, the Redis cluster can also adopt the Cluster deployment mode, such as Figure 3 As shown, this is the Redis architecture using the Cluster deployment mode proposed in the embodiment of the present application. Figure 3 The structure shown in can be understood as an improved Cluster deployment mode. In order to rationally utilize resources, any Redis cluster in this deployment mode (such as Figure 3 A Reids cluster node shown in the figure can include: multiple shards. Each shard includes a Redis master instance (remembered as Master) and a Redis slave instance (remembered as Slave). In addition, in order to make more reasonable use of resources, instances of different shards in the Cluster are cross-deployed, that is, the Redis master instances in different shards are deployed on different machines, and different instances in the same shard are deployed on different machines. Figure 3 This is just an example of an optional scenario for deploying Redis Cluster based on this, and is not limited to Figure 3 The number of shards shown and what each shard contains.

[0071] Take the scenario of deploying a Redis cluster with three shards as an example. Each shard includes a Redis master instance and a Redis slave instance. The machines deployed in each shard are marked as VM-0, VM-1, and VM-2, respectively. The Redis master instances deployed in the corresponding shards are represented as Master0, Master1, and Master2, and the Redis slave instances are represented as Slave0, Slave1, and Slave2. In this way, only three machines are needed to deploy six Redis instances. Instead of six machines, only . In this case, when any half or less of the shards fail, the Redis cluster can continue to provide services.

[0072] Of course, in another scenario where three shards are deployed, Figure 3 As shown in the figure, each shard can also deploy a Redis master instance and two Redis slave instances. The corresponding monitored slaves deployed by the Master in each shard are deployed in other shards. For example, VM-1 deploys Master1, Slave0 and Slave2, and Slave1 is deployed in VM-0 and VM-2; similarly, VM-0 deploys Master0, Slave1 and Slave2, and Slave0 is deployed in VM-1 and VM-2, VM-2 deploys Master2, Slave0 and Slave1, and Slave2 is deployed in VM-0 and VM-1. This cross-deployment method can effectively improve the utilization of underlying resources.

[0073] In addition, since each Redis instance can forward client requests, that is, forward read requests to the instance that stores the corresponding data, and forward write requests to the instance with the most suitable slot (shard), deployment Figure 3 The client of the structure shown directly connects to Redis instead of the Proxy mode (a design pattern that allows access to another object to be controlled through a proxy or intermediary to implement control logic such as access control, logging, caching, etc.), which indirectly improves the performance of processing client requests.

[0074] It is understandable that in the containerized Redis proposed in this application, the Sentinel deployment mode and Cluster deployment mode adopted are both deployment modes with high availability and can provide high performance. Figure 2 as well as Figure 3 The improved Sentinel deployment mode and the improved Cluster deployment mode have other advantages based on high availability.

[0075] Figure 1The containerized Redis shown has high availability in both container and service dimensions.

[0076] For Figure 1 The deployment method of the containerized Redis shown in the figure may include: packaging the Redis installation package and the required configuration file directory into an image, and then publishing and running to complete all deployment tasks, which is simpler and the service is lightweight. When you need to expand the instance, you only need to increase the number of copies of the containerized Redis application service.

[0077] In some implementations, with the help of container orchestration and scheduling tools such as Kubernetes, the automatic operation and maintenance of Redis containers can be achieved to avoid excessive manual intervention. In addition, native Redis provides high-availability deployment modes with failover functions: Sentinel deployment mode and Cluster deployment mode, which can ensure that when an existing master instance fails, a new master instance can be voted from the current slave instances to continue to maintain service availability. However, for old instances that have gone offline, they cannot be automatically restored and rejoined the cluster. By using the Kubernetes replica controller mechanism, the offline Redis container can be "pulled up" again, so that the number of instances of the entire Redis cluster remains constant, without the need for manual intervention to restart the service.

[0078] Based on the containerized Redis described in the above text application embodiment, the present application embodiment also provides a database system, such as Figure 4 As shown, the database system may include: an application module 410 , a log module 420 and a monitoring module 430 .

[0079] The application module 410 may be a containerized Redis proposed in the embodiment of the present application. The specific structure can be found in Figure 2 or Figure 3 As shown, no further details are given here. The application module 410 can be used to receive cached data of the business. In some implementations, the application module turns on the persistence function and can adopt the Redis disk drop mechanism, i.e., the persistence mechanism, such as RDB (RedisDataBase, a data persistence method, which realizes data persistence by periodically creating snapshots of the memory data set, i.e., writing the snapshots of the data set in the memory to the disk within a specified time interval through the Snapshot snapshot method) or AOF (Append only File, an append log file, which records each write operation in the log file in the form of a log), then the cached data is dropped to the storage volume in the form of aof or rdb.

[0080] The log module 420 is used to receive and store the logs of the application module. In some implementations, the ES (Elasticsearch, data search and analysis engine) log center is connected to store the logs of the application module 410 in the ES log center, and the logs can be searched and / or analyzed in the ES log center to facilitate problem location.

[0081] The monitoring module 430 can be used to connect to the UMP platform (Unified Management Platform) to collect monitoring indicator information such as CPU, memory, and / or storage of the Redis cluster, and use open source monitoring and visualization tools such as Prometheus and Grafana to display the usage in a graphical manner. If the indicator in the Redis cluster exceeds the preset threshold, an alarm is triggered to the relevant personnel. This application does not elaborate on the monitoring implementation process.

[0082] It can be seen that Figure 4 The database system shown not only has high availability in both container and service dimensions, but also has a complete containerized Redis instance monitoring and alarm mechanism to ensure that the service operation status can be monitored and alarms can be issued in case of abnormalities.

[0083] Based on the containerized Redis proposed in this application, the embodiment of this application also provides a disaster prevention method. It is understandable that the disaster prevention method can be applied to but not limited to the cross-computer room switching application scenarios caused by the following scenarios:

[0084] An example of a scenario is: the switching of Redis clusters across computer rooms (i.e., centers) due to certain reasons (such as equipment failure or upgrades in computer rooms). Combined with the above analysis, this application can use the data synchronization mechanism between Redis master and slave instances to perform hot backup of data across computer rooms, and then smoothly go offline to cope with computer room-level fault drills and fault recovery. Another example of an application scenario to which this solution is applicable is: vertical expansion of Redis clusters. Vertical expansion can be understood as expanding the resource quota of Redis instances, which requires stopping the existing container and restarting the new container.

[0085] Different Redis cluster structures use different disaster prevention processes. The following will focus on Figure 2 and Figure 3 The structures shown are explained separately.

[0086] exist Figure 2 In the Redis architecture in the improved Sentinel deployment mode shown in FIG. 1 , combined with the description of the corresponding part of the above embodiment, the Redis cluster deployed in the main computer room is as follows: Figure 2 As shown in the figure, the standby computer room and the main computer room deploy the same Redis cluster in the improved Sentinel deployment mode, that is, Figure 2 As shown. In this embodiment, take the deployment of three Redis instances in the standby computer room (such as a one-master-two-slave structure) as an example. After deployment, the three Redis instances in the standby computer room all become Redis slave instances (Slave) of the Redis master instance (Master) in the main computer room, and the Sentinel cluster in the standby computer room also monitors the Master in the main computer room (implemented through the Redis startup script). The election priority of the Redis instance in the standby computer room is configured to be higher than the election priority of the Redis instance in the main computer room.

[0087] The process of the disaster prevention method based on the above deployment is as follows Figure 5 As shown, the following steps are included:

[0088] S11. Synchronize the Redis cluster data between the main computer room and the backup computer room.

[0089] S12. After completing data synchronization, trigger the Redis instance in the main computer room to stop running.

[0090] It is understandable that the Redis instance in the main computer room stops running, triggering the failover process, which executes the following steps:

[0091] S13. Elect a new Redis master instance (Master) from the Redis instances in the backup computer room.

[0092] S14. Trigger the Sentinel instance in the main computer room to stop running.

[0093] It is understandable that the process ends after the Sentinel cluster in the main computer room stops running. The entire process is smooth and the business is not aware of it.

[0094] exist Figure 3 In the Redis architecture under the improved Cluster deployment mode shown in the figure, the Redis cluster deployed in the main computer room is as follows Figure 3 As shown in the figure, the standby computer room and the main computer room are deployed with the same improved Cluster deployment mode Redis cluster, still with Figure 3 The scenario of deploying 3 shards and 9 instances is used as an example. The backup room is deployed with the same number of Redis instances as the main room (such as 9 instances). The cross-deployment structure can refer to Figure 3 The description of the corresponding parts shown in the figure will not be repeated in this embodiment. After the deployment is successful, the Redis instances deployed in the standby computer room become slave instances of the three shards in the main computer room respectively.

[0095] S21. Synchronize the data of the Redis clusters in the main computer room and the backup computer room.

[0096] S22. After completing data synchronization, trigger the first shard in the main computer room to stop running.

[0097] Since each instance is a separate SatefulSet (stateful replica set), the offline operation of the shard is achieved by reducing the replicas to 0. In some implementations, the slave instance of the first shard can be offline first, and then the master instance of the first shard can be offline after the completion.

[0098] S23. Elect a new Master from the Redis instance in the first shard in the standby computer room. S24. Trigger the second and third shards in the main computer room to stop running.

[0099] S25. Elect new Masters from the Redis instances in the second and third shards in the backup computer room.

[0100] Following the above analysis, after the offline operation of the first shard in the main computer room is completed, a new Master, that is, the Redis master instance, can be elected from the backup computer room. After that, the above operation is repeated for the second and third shards of the main computer room. It can be seen that after each shard in the main computer room is offline, a Master can be elected from each shard in the backup computer room to continue the Redis service.

[0101] S26. After a certain period of time, trigger the update of information of the node.conf cluster status file and clean up the old instance information.

[0102] In the embodiment of the present application, the above-mentioned duration is used as the threshold for triggering the information update of the node.conf cluster status file, which can be configured according to actual needs. For example, a fault drill needs to be completed within 30 minutes to successfully trigger the cleanup of information. The duration can be set to 30 minutes, but is not limited to this. The old instance can be understood as an instance in the equipment in the main computer room, and can also be understood as an instance in the equipment in the backup computer room before the disaster prevention process. The node.conf cluster status file is an important configuration file in the Redis cluster, which records the status information of each instance in the Redis cluster, and implements the configuration and management of each instance based on this.

[0103] For the Redis architecture described in the above embodiments, the network communication mode for implementing the Redis service can provide external access through the "DNS+LB" method. In the Redis clusters of the two computer rooms, each load balancing LB (LoadBalance) can be configured. The Sentinel deployment mode can only configure the sentinel cluster, and the client obtains the current redis master instance through the sentinel cluster; the Cluster deployment mode requires the configuration of the LB of the entire cluster, such as Figure 3As shown, each shard deploys the same number of redis instances. Then, configure DNS resolution for the two LBs in the dual computer rooms, so that the business system can access the currently surviving Redis service through the DNS domain name. This application does not elaborate on the DNS communication between the two computer rooms to achieve data synchronization / shared storage.

[0104] For Figure 5 and Figure 6 It provides containerized cross-computer room (center) switching and disaster prevention solutions, which can cope with computer room (center) level fault recovery. When a computer room level fault occurs in any computer room, if the Redis in the center is a slave instance, the state of the Redis cluster does not change, and the service is not affected; if Redis is the master instance, the fault switching is implemented according to the method described above, and a new master instance is voted out from the remaining instances to continue to provide services to the outside world. Therefore, no matter which computer room is offline, the Redis service will not be affected. In addition, this application also provides a complete containerized Redis instance monitoring and alarm mechanism to ensure that the service operation status can be monitored and alarms can be issued in case of abnormalities, so that fault switching can be implemented in a timely manner to ensure the reliability and stability of the Redis service.

[0105] It can be seen that compared with the deployment, expansion, and operation and maintenance processes in non-containerized solutions, they are more complicated and require too much manual intervention, as well as unreasonable selection and incomplete solution design in traditional containerized solutions, resulting in service availability and performance failing to meet enterprise-level production needs. The embodiment of the present application uses containerization and Kubernetes engine orchestration and scheduling to simplify and automate the deployment, expansion, and operation and maintenance processes of Redis, and the service is more lightweight. By selecting the improved Sentinel and Cluster high-availability deployment mode, combined with the high availability of the Kubernetes controller scheduling containers, disaster recovery and switching designs are made across computer rooms, and a special monitoring and alarm mechanism is integrated to form a complete and efficient enterprise-level production solution.

[0106] The embodiment of the present application adopts a single-center high-availability, dual-center disaster recovery deployment architecture, which is a trade-off solution made under the condition that there is no multi-center (more than two) environment. The architectural design is still based on high availability and scalability, and combined with the existing environment, an architecture that meets the disaster recovery level of containers, host machines, computer rooms, etc. is designed, that is, cluster container instances are separately deployed on different machines to meet disaster recovery requirements, and cluster clusters are cross-deployed to provide resource utilization. When there is a multi-center environment, the Redis cluster can maintain high availability at the computer room level through the deployment of master-slave instances across computer rooms, as described above, to meet the actual business system requirements.

[0107] Also provided in an embodiment of the present application is a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device (such as a server), the electronic device implements any disaster prevention method provided in an embodiment of the present application.

[0108] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any disaster prevention method provided in the embodiment of the present application.

[0109] If the functions described in the method of the embodiment of the present application are implemented in the form of a software functional unit and sold or used as an independent product, they can be stored in a storage medium readable by a computing device. Based on this understanding, the part of the embodiment of the present application that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computing device (which can be a personal computer, server, mobile computing device or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0110] The various embodiments in this specification are described in a progressive or parallel manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0111] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A containerized Redis, characterized in that: The containerized Redis includes: Redis clusters and containers; Each Redis instance in the Redis cluster is deployed in one of the containers.

2. The containerized Redis according to claim 1, characterized in that: Any Redis cluster using the Sentinel deployment mode includes: Sentinel instance and Redis instance; The Sentinel instance is decoupled from the Redis instance for deployment; One Sentinel instance monitors multiple Redis instances.

3. The containerized Redis according to claim 1, characterized in that: Any Redis cluster using the cluster deployment mode includes: multiple shards; Any of the shards includes: a Redis master instance and a Redis slave instance; The Redis master instances in different shards are deployed on different machines, and different instances in the same shard are deployed on different machines.

4. A database system, characterized in that: The database system comprises: Application module and log module; The application module includes a Redis cluster and a container, and each Redis instance in the Redis cluster is deployed in one of the containers; The application module is used to receive cache data of the service; The log module is used to receive and store the logs of the application modules.

5. The database system according to claim 4, characterized in that: The database system also includes: The monitoring module is used to collect parameters of the Redis cluster.

6. The database system according to claim 4 or 5, characterized in that: Any Redis cluster using the Sentinel deployment mode includes: Sentinel instance and Redis instance; The Sentinel instance is decoupled from the Redis instance for deployment; One Sentinel instance monitors multiple Redis instances.

7. The database system according to claim 4 or 5, characterized in that: Any Redis cluster using the cluster deployment mode includes: multiple shards; Any of the shards includes: a Redis master instance and a Redis slave instance; The Redis master instances in different shards are deployed on different machines, and different instances in the same shard are deployed on different machines.

8. A disaster prevention method, characterized in that: Applied to switching from a containerized Redis deployed in a main computer room to a containerized Redis deployed in a backup computer room, the containerized Redis includes a Redis cluster and a container, each Redis instance in the Redis cluster is deployed in one of the containers, and the disaster prevention method includes: Synchronize the data of the Redis clusters of the main computer room and the backup computer room; After data synchronization is completed, the Redis cluster in the main computer room is triggered to stop running; A Redis master instance is elected from the Redis instances in the standby computer room.

9. The disaster prevention method according to claim 8, characterized in that: Any Redis cluster adopting the Sentinel deployment mode includes a Sentinel instance and a Redis instance, the Sentinel instance is deployed decoupled from the Redis instance, and one Sentinel instance monitors multiple Redis instances; The disaster prevention method also includes: Trigger the Sentinel instance in the computer room to stop running.

10. The disaster prevention method according to claim 8, characterized in that: Any Redis cluster using the cluster deployment mode includes multiple shards, and any shard includes a Redis master instance and a Redis slave instance. The Redis master instances in different shards are deployed on different machines, and different instances in the same shard are deployed on different machines. The triggering of stopping the Redis cluster in the main computer room includes: Triggering each shard of the main computer room to stop running in turn; The step of selecting a Redis master instance from the Redis instances in the standby computer room includes: Select a Redis master instance from the Redis instances in each shard of the standby computer room; The disaster prevention method also includes: Triggering an update of the cluster status file after a certain period of time.