CN111124797A - Method and device for testing Redis component - Google Patents

Method and device for testing Redis component Download PDF

Info

Publication number
CN111124797A
CN111124797A CN201911083360.1A CN201911083360A CN111124797A CN 111124797 A CN111124797 A CN 111124797A CN 201911083360 A CN201911083360 A CN 201911083360A CN 111124797 A CN111124797 A CN 111124797A
Authority
CN
China
Prior art keywords
redis
node
cluster
master node
original
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.)
Withdrawn
Application number
CN201911083360.1A
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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent 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 Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN201911083360.1A priority Critical patent/CN111124797A/en
Publication of CN111124797A publication Critical patent/CN111124797A/en
Withdrawn legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3006Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is distributed, e.g. networked systems, clusters, multiprocessor systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing arrangements

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mathematical Physics (AREA)
  • Computer Hardware Design (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a method and a device for testing a Redis component, wherein the method comprises the following steps: creating a Redis cluster; deleting the process of a first main node in the Redis cluster; detecting the state of a first slave node corresponding to the first master node; responding to the change of the first slave node into a new first master node, and starting the process of the original first master node; and in response to the original first master node becoming a new first slave node, judging that the availability of the Redis component is stable. By using the method and the equipment, the high availability of the Insight platform Redis component cluster can be verified, the testing efficiency is improved, the human resources are saved, and the guarantee and the basis are provided for the Redis high availability cluster function test of the cluster.

Description

Method and device for testing Redis component
Technical Field
The field relates to the field of computers, and more particularly to a method and apparatus for Redis component testing.
Background
There are many ways to implement the Redis component in high availability, but in the cloud platform, the Redis Cluster scheme is commonly used. The Redis cluster is a distributed and fault-tolerant (fault-tolerant) Redis memory K/V service. The nodes in the Redis cluster are divided into a master node (master) and a slave node (slave), wherein the master node is used for processing a slot, the slave node is used for copying a certain master node, and when the copied master node goes offline, the slave node replaces the offline master node to continue processing a command request. High availability testing of the Redis component is important.
Disclosure of Invention
In view of this, an object of the embodiments of the present invention is to provide a method and a device for testing a Redis component, which can verify the high availability of a Redis component cluster of an Insight platform, improve testing efficiency, save human resources, and provide guarantee and basis for a Redis high availability cluster function test of the cluster.
In view of the above object, an aspect of an embodiment of the present invention provides a method for testing a Redis component, including the steps of:
creating a Redis cluster;
deleting the process of a first main node in the Redis cluster;
detecting the state of a first slave node corresponding to the first master node;
responding to the change of the first slave node into a new first master node, and starting the process of the original first master node;
and in response to the original first master node becoming a new first slave node, judging that the availability of the Redis component is stable.
According to one embodiment of the invention, creating a Redis cluster comprises: a three-master three-slave Redis cluster is created in a cloud sea Insight platform.
According to one embodiment of the present invention, the deleting the process of the first master node in the Redis cluster comprises: and acquiring the process of the Redis server of the first main node, and killing the process through a kill-9 command.
According to one embodiment of the present invention, detecting a state of a first slave node corresponding to a first master node comprises: the set k1 HelloWorld cluster command is used to verify that the Redis cluster function is normal.
According to an embodiment of the present invention, the process of starting the original primary master node includes: and after finding the corresponding conf configuration file under the installation path of the original first main node, starting the original first main node.
In another aspect of the embodiments of the present invention, there is also provided a device for testing a Redis component, where the device includes:
at least one processor; and
a memory storing program code executable by the processor, the program code when executed by the processor performing the steps of:
creating a Redis cluster;
deleting the process of a first main node in the Redis cluster;
detecting the state of a first slave node corresponding to the first master node;
responding to the change of the first slave node into a new first master node, and starting the process of the original first master node;
and in response to the original first master node becoming a new first slave node, judging that the availability of the Redis component is stable.
According to one embodiment of the invention, creating a Redis cluster comprises: a three-master three-slave Redis cluster is created in a cloud sea Insight platform.
According to one embodiment of the present invention, the deleting the process of the first master node in the Redis cluster comprises: and acquiring the process of the Redis server of the first main node, and killing the process through a kill-9 command.
According to one embodiment of the present invention, detecting a state of a first slave node corresponding to a first master node comprises: the set k1 HelloWorld cluster command is used to verify that the Redis cluster function is normal.
According to an embodiment of the present invention, the process of starting the original primary master node includes: and after finding the corresponding conf configuration file under the installation path of the original first main node, starting the original first main node.
The invention has the following beneficial technical effects: the Redis component testing method provided by the embodiment of the invention comprises the steps of establishing a Redis cluster; deleting the process of a first main node in the Redis cluster; detecting the state of a first slave node corresponding to the first master node; responding to the change of the first slave node into a new first master node, and starting the process of the original first master node; the technical scheme of judging the stable availability of the Redis component in response to the fact that the original first master node is changed into a new first slave node can verify the high availability of the Insight platform Redis component cluster, so that the test efficiency is improved, the human resources are saved, guarantee and basis are provided for the Redis high availability cluster function test of the cluster, and the product competitiveness is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
FIG. 1 is a schematic flow diagram of a method of Redis component testing according to one embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
In view of the above objects, a first aspect of embodiments of the present invention proposes an embodiment of a method of Redis component testing. Fig. 1 shows a schematic flow diagram of the method.
As shown in fig. 1, the method may include the steps of:
s1, testing a Redis component;
s2, deleting the process of the first master node in the Redis cluster;
s3, detecting the state of a first slave node corresponding to the first master node;
s4, responding to the change of the first slave node into a new first master node, starting the process of the original first master node;
s5, in response to the original first master node becoming the new first slave node, determining that the Redis component availability is stable.
The method can realize automatic testing in a script mode, the script uses Shell script as a development language to realize automatic testing of Redis master-slave node switching, the method mainly adopts operation commands such as simulation process faults and Redis service starting to verify the high availability of the Redis, meanwhile, the Redis operation commands carried by Hadoop are selected to verify that the Redis function is not affected after master-slave switching of a cluster, and logs in the testing process are reserved and execution records can be retroactively analyzed.
Through the technical scheme, the high availability of the Insight platform Redis component cluster can be verified, the testing efficiency is improved, the human resources are saved, the guarantee and the basis are provided for the Redis high availability cluster function test of the cluster, and the product competitiveness is improved.
In a preferred embodiment of the present invention, creating a Redis cluster comprises: a three-master three-slave Redis cluster is created in a cloud sea Insight platform. Two Redis servers are installed in an interface of a cloud sea Insight platform, after the installation is successful, a CreateRediscuster button is clicked on an operation interface, and a Redis cluster with three masters and three slaves can be automatically generated by the system.
In a preferred embodiment of the present invention, the deleting the process of the first master node in the Redis cluster includes: and acquiring the process of the Redis server of the first main node, and killing the process through a kill-9 command. The process of Redis-server of the first host node (assuming the port number of the first host node is 7001) is first acquired and killed by the kill-9 command. Therefore, the situation that the main node fails to work is simulated, and whether the first slave node corresponding to the first main node can be automatically changed into a new first main node or not is checked. The following is one example of this process:
# procedure for forced killing of Master node 1
ps-ef|grep 7001|grep-v grep|awk'{print$2}'|xargs kill-9
# see if the slave node 1 status is already master
echo“cluster nodes”|Redis-cli–h$host–p$port–c
Wherein: the $ host and $ port may be any node that is not the first master node.
In a preferred embodiment of the present invention, detecting the state of the first slave node corresponding to the first master node comprises: the set k1 HelloWorld cluster command is used to verify that the Redis cluster function is normal. After the first master node is hung up due to a fault, whether the cluster function is normal or not is verified by executing a Redis cluster command, such as set k1 HelloWorld. If the first master node fails and can not work normally, the first slave node automatically becomes a new first master node and can work normally, the high availability of the cluster is stable, and the process is to verify that the slave node can be automatically switched to the corresponding master node. The following is one example of this process:
# run Cluster execution Command
echo“set k1 HelloWorld”|Redis-cli–h$host–p$port–c
Wherein: the $ host and $ port may be any node that is not the first master node.
In a preferred embodiment of the present invention, the process of starting the original primary master node includes: and after finding the corresponding conf configuration file under the installation path of the original first main node, starting the original first main node. Finding the conf configuration file of the corresponding node, such as Redis _7001.conf, under the installation path of the original first main node, and then starting the original first main node. And after the original first main node is restarted, a cluster detection command carried by Redis is executed, and a cluster nodes command is operated to check the state of each node of the cluster. The process is to verify whether the restarted original first master node can become a corresponding new first slave node instead of knocking the new first master node down, and if the restarted original first master node can become a corresponding first slave node, the high availability of the cluster is stable. The following is one example of this process:
# into Redis installation configuration File Path
cd/usr/hdp/3.0.1.0-111/Redis/Redis_7001/conf
# boot failure Master node
Redis-server./Redis_7001.conf
# View Cluster nodes Master-slave status
echo“cluster nodes”|Redis-cli–h$host–p$port–c
Through the technical scheme, the high availability of the Insight platform Redis component cluster can be verified, the testing efficiency is improved, the human resources are saved, the guarantee and the basis are provided for the Redis high availability cluster function test of the cluster, and the product competitiveness is improved.
It should be noted that, as will be understood by those skilled in the art, all or part of the processes in the methods of the above embodiments may be implemented by instructing relevant hardware through a computer program, and the above programs may be stored in a computer-readable storage medium, and when executed, the programs may include the processes of the embodiments of the methods as described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like. The embodiments of the computer program may achieve the same or similar effects as any of the above-described method embodiments.
Furthermore, the method disclosed according to an embodiment of the present invention may also be implemented as a computer program executed by a CPU, and the computer program may be stored in a computer-readable storage medium. The computer program, when executed by the CPU, performs the above-described functions defined in the method disclosed in the embodiments of the present invention.
In view of the above object, a second aspect of the embodiments of the present invention provides an apparatus for testing a Redis component, the apparatus comprising:
at least one processor; and
a memory storing program code executable by the processor, the program code when executed by the processor performing the steps of:
creating a Redis cluster;
deleting the process of a first main node in the Redis cluster;
detecting the state of a first slave node corresponding to the first master node;
responding to the change of the first slave node into a new first master node, and starting the process of the original first master node;
and in response to the original first master node becoming a new first slave node, judging that the availability of the Redis component is stable.
In a preferred embodiment of the present invention, creating a Redis cluster comprises: a three-master three-slave Redis cluster is created in a cloud sea Insight platform. Two Redis servers are installed in an interface of a cloud sea Insight platform, after the installation is successful, a CreateRediscuster button is clicked on an operation interface, and a Redis cluster with three masters and three slaves can be automatically generated by the system.
In a preferred embodiment of the present invention, the deleting the process of the first master node in the Redis cluster includes: and acquiring the process of the Redis server of the first main node, and killing the process through a kill-9 command. The process of Redis-server of the first host node (assuming the port number of the first host node is 7001) is first acquired and killed by the kill-9 command. Therefore, the situation that the main node fails to work is simulated, and whether the first slave node corresponding to the first main node can be automatically changed into a new first main node or not is checked.
In a preferred embodiment of the present invention, detecting the state of the first slave node corresponding to the first master node comprises: the set k1 HelloWorld cluster command is used to verify that the Redis cluster function is normal. After the first master node is hung up due to a fault, whether the cluster function is normal or not is verified by executing a Redis cluster command, such as set k1 HelloWorld. If the first master node fails and can not work normally, the first slave node automatically becomes a new first master node and can work normally, the high availability of the cluster is stable, and the process is to verify that the slave node can be automatically switched to the corresponding master node.
In a preferred embodiment of the present invention, the process of starting the original primary master node includes: and after finding the corresponding conf configuration file under the installation path of the original first main node, starting the first main node. Finding the conf configuration file of the corresponding node, such as Redis _7001.conf, under the installation path of the original first main node, and then starting the original first main node. And after the original first main node is restarted, a cluster detection command carried by Redis is executed, and a cluster nodes command is operated to check the state of each node of the cluster. The process is to verify whether the restarted original first master node can become the corresponding first slave node instead of knocking off a new first master node, and if the restarted original first master node can become the corresponding first slave node, the high availability of the cluster is stable.
It should be particularly noted that the embodiment of the system described above employs the embodiment of the method described above to specifically describe the working process of each module, and those skilled in the art can easily think that the modules are applied to other embodiments of the method described above.
Further, the above-described method steps and system elements or modules may also be implemented using a controller and a computer-readable storage medium for storing a computer program for causing the controller to implement the functions of the above-described steps or elements or modules.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments of the present invention.
The embodiments described above, particularly any "preferred" embodiments, are possible examples of implementations and are presented merely to clearly understand the principles of the invention. Many variations and modifications may be made to the above-described embodiments without departing from the spirit and principles of the technology described herein. All such modifications are intended to be included within the scope of this disclosure and protected by the following claims.

Claims (10)

1. A method of Redis component testing, comprising the steps of:
creating a Redis cluster;
deleting the process of the first main node in the Redis cluster;
detecting the state of a first slave node corresponding to the first master node;
responding to the change of the first slave node into a new first master node, and starting the process of the original first master node;
and in response to the original first master node becoming a new first slave node, determining that the Redis component availability is stable.
2. The method of claim 1, wherein creating a Redis cluster comprises: creating the Redis cluster of three masters and three slaves in a cloud Insight platform.
3. The method of claim 1, wherein deleting the process of the first master node in the Redis cluster comprises: and acquiring the process of the Redis server of the first main node, and killing the process through a kill-9 command.
4. The method of claim 1, wherein detecting the state of the first slave node corresponding to the first master node comprises: and verifying whether the Redis cluster functions normally or not by using a set k1 HelloWorld cluster command.
5. The method of claim 1, wherein initiating the process of the original primary master node comprises: and after finding the corresponding conf configuration file under the installation path of the original first main node, starting the original first main node.
6. An apparatus for Redis component testing, the apparatus comprising:
at least one processor; and
a memory storing program code executable by the processor, the program code, when executed by the processor, performing the steps of:
creating a Redis cluster;
deleting the process of the first main node in the Redis cluster;
detecting the state of a first slave node corresponding to the first master node;
responding to the change of the first slave node into a new first master node, and starting the process of the original first master node;
and in response to the original first master node becoming a new first slave node, determining that the Redis component availability is stable.
7. The apparatus of claim 6, wherein creating a Redis cluster comprises: creating the Redis cluster of three masters and three slaves in a cloud Insight platform.
8. The apparatus of claim 6, wherein the deleting the process of the first master node in the Redis cluster comprises: and acquiring the process of the Redis server of the first main node, and killing the process through a kill-9 command.
9. The device of claim 6, wherein detecting the state of a first slave node corresponding to the first master node comprises: and verifying whether the Redis cluster functions normally or not by using a set k1 HelloWorld cluster command.
10. The apparatus of claim 6, wherein the process of initiating the original primary master node comprises: and after finding the corresponding conf configuration file under the installation path of the original first main node, starting the original first main node.
CN201911083360.1A 2019-11-07 2019-11-07 Method and device for testing Redis component Withdrawn CN111124797A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911083360.1A CN111124797A (en) 2019-11-07 2019-11-07 Method and device for testing Redis component

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911083360.1A CN111124797A (en) 2019-11-07 2019-11-07 Method and device for testing Redis component

Publications (1)

Publication Number Publication Date
CN111124797A true CN111124797A (en) 2020-05-08

Family

ID=70495760

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911083360.1A Withdrawn CN111124797A (en) 2019-11-07 2019-11-07 Method and device for testing Redis component

Country Status (1)

Country Link
CN (1) CN111124797A (en)

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
冰河: "Redis之——Redis集群的高可用测试与集群重建", 《HTTPS://BINGHE.BLOG.CSDN.NET/ARTICLE/DETAILS》 *

Similar Documents

Publication Publication Date Title
US9396200B2 (en) Auto-snapshot manager analysis tool
US8910172B2 (en) Application resource switchover systems and methods
US8225142B2 (en) Method and system for tracepoint-based fault diagnosis and recovery
US7984332B2 (en) Distributed system checker
JP6788178B2 (en) Setting support program, setting support method and setting support device
CN111858321B (en) Automatic test method based on Xdotool
CN108959045B (en) Method and system for testing fault switching performance of NAS cluster
US10795793B1 (en) Method and system for simulating system failures using domain-specific language constructs
CN107506295A (en) Method of testing, equipment and the computer-readable recording medium of virtual machine backup
US7373542B2 (en) Automatic startup of a cluster system after occurrence of a recoverable error
US10860411B2 (en) Automatically detecting time-of-fault bugs in cloud systems
CN111124797A (en) Method and device for testing Redis component
CN111355775B (en) Method, device, equipment and storage medium for judging state of CloudStack cluster sub-server
CN114996955A (en) Target range environment construction method and device for cloud-originated chaotic engineering experiment
CN114090211A (en) Method and device for coordinating single-task master-slave program and related multi-server system
US7539839B1 (en) Method to test error recovery with selective memory allocation error injection
CN110287066B (en) Server partition migration method and related device
CN110471767B (en) Equipment scheduling method
CN109510867B (en) Data request processing method and device, storage medium and electronic equipment
JP6818654B2 (en) Test automation equipment, test methods, and programs
CN106354602A (en) Service monitoring method and equipment
CN113032260A (en) Fault injection simulation test method and system based on componentized distributed system
CN112068935A (en) Method, device and equipment for monitoring deployment of kubernets program
US8533331B1 (en) Method and apparatus for preventing concurrency violation among resources
CN111338871A (en) Distributed file system Qzone high availability test method, system, equipment and storage medium

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
WW01 Invention patent application withdrawn after publication
WW01 Invention patent application withdrawn after publication

Application publication date: 20200508