A method, apparatus, device and medium for executing cluster instances
By extracting the cluster name from the command line and obtaining the Internet Protocol address and port number from the configuration file, the difficulty of executing cluster instances without entering the address and port number is solved, thus achieving correct cluster instance execution.
Patent Information
- Application Number
- CN202311114239.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-31
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2043-08-31
AI Technical Summary
Without entering the cluster node's Internet Protocol address and port number in the command line, the cluster instance cannot be explicitly executed, and there is a possibility of inputting incorrect information.
By extracting the pre-packaged cluster name from the command line, obtaining the Internet protocol address and port number from the cluster configuration file, and setting the target environment variable in the local configuration file, the command line is executed to associate and execute the correct cluster instance.
This reduces the amount of input required, lowers the possibility of input errors, and ensures that the correct cluster instance is executed without requiring the input of Internet Protocol addresses and port numbers.
Smart Images

Figure CN117176725B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device and medium for executing cluster instances. Background Technology
[0002] Currently, the command lines executed by clients generated based on distributed key-value storage software (ETCD, etc Distribute, where "etc" refers to the / etc directory in Linux / Unix operating systems and "Distribute" means distributed) typically include the Internet Protocol addresses and port numbers of each cluster node in the specified distributed key-value storage system cluster. For example, when querying the distributed key-value storage system cluster, the command line including the Internet Protocol addresses and port numbers of each cluster node would look like this: `etcdctl --endpoints=http: / / 192.168.7.12:2379,http: / / 192.168.7.13:2379,http: / / 192.168.7.14:2379,endpoint` The `status` command line includes the Internet Protocol addresses and port numbers of three cluster nodes: `http: / / 192.168.7.12:2379`, `http: / / 192.168.7.13:2379`, and `http: / / 192.168.7.14:2379`. If the command line does not include the Internet Protocol addresses and port numbers, the following problems arise: First, the cluster node executing the command line cannot be clearly identified, i.e., there is no explicit Internet Protocol address. Second, when a cluster node belongs to multiple distributed key-value storage system clusters, it is impossible to determine which distributed key-value storage system cluster the command line is based on, i.e., it is impossible to determine which port of that cluster node it is using. In summary, when the command line does not include the Internet Protocol addresses and port numbers, the cluster instance to be executed cannot be clearly identified. In this case, executing the command will display the execution result of one of the cluster instances.
[0003] However, when entering the Internet Protocol address and port number of each cluster node in the specified distributed key-value storage system cluster in the command line, the entered Internet Protocol address and port number may be incorrect.
[0004] In summary, this demonstrates how to execute a correct cluster instance in the command line without entering the cluster node's Internet Protocol address and port number. Summary of the Invention
[0005] In view of this, the purpose of this invention is to provide a cluster instance execution method, apparatus, device, and medium that can execute the correct cluster instance without inputting the Internet Protocol address and port number of the cluster node in the command line. The specific solution is as follows:
[0006] In a first aspect, this application discloses a cluster instance execution method, applied to a client generated based on distributed key-value storage software, comprising:
[0007] When the command line corresponding to the distributed key-value storage software is obtained, the cluster name of the pre-packaged target distributed key-value storage system cluster is extracted from the command line.
[0008] Based on the cluster name, the cluster configuration parameters of the target distributed key-value storage system cluster corresponding to the cluster name are obtained from the cluster configuration file; the cluster configuration parameters include the cluster name and the Internet Protocol address and port number of each cluster node in the target distributed key-value storage system cluster;
[0009] Based on the cluster configuration parameters, the target environment variable is set in the local client configuration file, and the command line is executed after the target environment variable takes effect. When the command line is executed, the cluster instance corresponding to the cluster configuration parameters is associated and executed to obtain the corresponding cluster instance execution result.
[0010] Optionally, the cluster instance execution method further includes:
[0011] Continuously determine the log content when executing the command line and the cluster instance, and store the log content in the cache corresponding to the target distributed key-value storage system cluster;
[0012] When all the log content stored in the cache reaches the preset transfer requirement, all the log content stored in the cache is transferred to the preset storage file corresponding to the target distributed key-value storage system cluster; the preset storage file is used to store the log content for a long time.
[0013] Delete all the log content stored in the cache, and proceed to the step of continuously determining the log content when executing the command line and the cluster instance.
[0014] Optionally, the step of transferring all the log content stored in the cache to a preset storage file corresponding to the target distributed key-value storage system cluster includes:
[0015] Based on the cluster name, obtain the file path parameters corresponding to the target distributed key-value storage system cluster from the cluster configuration file;
[0016] Based on the file path parameters, all the log content stored in the cache is transferred to the preset storage file corresponding to the target distributed key-value storage system cluster.
[0017] Optionally, the preset transfer requirement is that the first content quantity of all the log content stored in the cache is not less than the preset storage quantity, and / or, the storage time of the log content in the cache is not less than the preset keep-alive time.
[0018] Optionally, after transferring all the log content stored in the cache to a preset storage file corresponding to the target distributed key-value storage system cluster, the method further includes:
[0019] When all the log content stored in the preset storage file reaches the preset deletion requirement, the target percentage of the log content stored in the preset storage file is deleted in the order of storage.
[0020] Optionally, the preset deletion requirement is that the number of second contents of all the log contents stored in the preset storage file is not less than the preset storage quantity, and / or that the actual storage time of all the log contents stored in the preset storage file is not less than the preset storage time.
[0021] Optionally, setting the target environment variable in the local client configuration file based on the cluster configuration parameters includes:
[0022] If the original environment variable exists in the client configuration file, then determine whether the original environment variable is the environment variable corresponding to the cluster configuration parameter;
[0023] If the original environment variable is not the environment variable corresponding to the cluster configuration parameter, then the target environment variable is set in the local client configuration file based on the cluster configuration parameter;
[0024] If the original environment variable is the same as the environment variable corresponding to the cluster configuration parameters, then the original environment variable is directly set as the target environment variable.
[0025] Secondly, this application discloses a cluster instance execution device, applied to a client generated based on distributed key-value storage software, comprising:
[0026] The cluster name acquisition module is used to extract the pre-packaged cluster name of the target distributed key-value storage system cluster from the command line corresponding to the distributed key-value storage software when the command line is obtained.
[0027] The configuration parameter acquisition module is used to obtain the cluster configuration parameters of the target distributed key-value storage system cluster corresponding to the cluster name from the cluster configuration file based on the cluster name; the cluster configuration parameters include the cluster name and the Internet Protocol address and port number of each cluster node in the target distributed key-value storage system cluster;
[0028] The environment variable setting module is used to set target environment variables in the local client configuration file based on the cluster configuration parameters, execute the command line after the target environment variables take effect, and associate and execute the cluster instance corresponding to the cluster configuration parameters when the command line is executed to obtain the corresponding cluster instance execution result.
[0029] Thirdly, this application discloses an electronic device, including:
[0030] Memory, used to store computer programs;
[0031] A processor is used to execute the computer program to implement the aforementioned disclosed cluster instance execution method.
[0032] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned cluster instance execution method.
[0033] As can be seen, when this application obtains the command line corresponding to the distributed key-value storage software, it extracts the pre-encapsulated cluster name of the target distributed key-value storage system cluster from the command line; based on the cluster name, it obtains the cluster configuration parameters of the target distributed key-value storage system cluster corresponding to the cluster name from the cluster configuration file; the cluster configuration parameters include the cluster name and the Internet Protocol address and port number of each cluster node in the target distributed key-value storage system cluster; based on the cluster configuration parameters, it sets the target environment variable in the local client configuration file, and executes the command line after the target environment variable takes effect; and when the command line is executed, it associates and executes the cluster instance corresponding to the cluster configuration parameters to obtain the corresponding cluster instance execution result. Therefore, this application reduces the amount of input and the possibility of input errors by replacing the input of the Internet Protocol address and port number with the input of the cluster name in the command line; the required Internet Protocol address and port number can be found in the cluster configuration file based on the cluster name, thus identifying the correct cluster instance. Therefore, it can execute the correct cluster instance without inputting the Internet Protocol address and port number of the cluster nodes in the command line. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0035] Figure 1This is a flowchart of a cluster instance execution method disclosed in this application;
[0036] Figure 2 This is a flowchart of a specific cluster instance execution method disclosed in this application;
[0037] Figure 3 This is a schematic diagram of the structure of a cluster instance execution device disclosed in this application;
[0038] Figure 4 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0039] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0040] If the command line does not include an Internet Protocol address and port number, the following problems will occur: First, the cluster node on which the command line is executed cannot be clearly identified, i.e., there is no explicit Internet Protocol address; Second, when a cluster node belongs to multiple distributed key-value storage system clusters, it is impossible to determine which distributed key-value storage system cluster the command line is based on when it is executed on that cluster node, i.e., it is impossible to determine which port of that cluster node it is; In summary, when the command line does not include an Internet Protocol address and port number, the cluster instance to be executed cannot be clearly identified.
[0041] However, when entering the Internet Protocol address and port number of each cluster node in the specified distributed key-value storage system cluster in the command line, the entered Internet Protocol address and port number may be incorrect.
[0042] Therefore, this application proposes a cluster instance execution scheme that can execute the correct cluster instance without entering the Internet Protocol address and port number of the cluster node in the command line.
[0043] This application discloses a cluster instance execution method. See also Figure 1 As shown, the method, applied to a client generated based on distributed key-value storage software, includes:
[0044] Step S11: When the command line corresponding to the distributed key-value storage software is obtained, the cluster name of the pre-packaged target distributed key-value storage system cluster is extracted from the command line.
[0045] In this embodiment, the command line corresponding to the distributed key-value storage software pre-encapsulates the cluster name of the specified target distributed key-value storage system cluster.
[0046] It's important to note that ETCD is a distributed, consistent key-value (KV) storage system for shared configuration and service discovery. It's an excellent, highly available distributed key-value database. Internally, ETCD uses the Raft protocol (Replicated And Fault Tolerant) as its consistency algorithm and is implemented in Go. ETCD has an API (Application Programming Interface) based on HTTP (Hypertext Transfer Protocol) and JSON (JavaScript Object Notation), which can be easily used using the curl (CommandLine URL or CommandLine Uniform Resource Locator) command-line tool. It's relatively secure due to its SSL (Secure Sockets Layer) client authentication mechanism. Each instance supports 1,000 write operations per second, making writes relatively fast. ETCD uses the Raft protocol to maintain the consistency of the state of each node within the cluster. In short, an ETCD cluster is a distributed system composed of multiple nodes communicating with each other to provide external services. Each node stores complete data, and the Raft protocol ensures that the data maintained by each node is consistent. Each ETCD node maintains a state machine, and at any given time, there is at most one valid master node. The master node handles all write operations from clients, and the Raft protocol ensures that changes to the state machine made by write operations are reliably synchronized to other nodes. The core of ETCD's working principle lies in the use of the Raft protocol and the watch mechanism within the cluster.
[0047] A cluster typically consists of two or more servers, each acting as a node. Database clusters provide read and write capabilities, while management clusters offer management and fault recovery functions. For a cluster, the coordination and management of multiple nodes is crucial. The master node implements this coordination and management; its existence ensures the orderly operation of other nodes and the consistency of written data across all nodes in the database cluster. Consistency here means that the data is identical across all cluster nodes, with no discrepancies. Distributed election aims to elect a master node to coordinate and manage the other nodes, ensuring the orderly operation of the cluster and data consistency among nodes. The Raft algorithm is a typical majority voting algorithm, its core idea being "majority rules." In Raft, the node receiving the most votes becomes the master node. Using the Raft algorithm, cluster nodes have three roles: Leader (only one Leader exists at a time, responsible for coordinating and managing other nodes); Candidate (any node can become a Candidate, and only nodes in this role can be elected as the new Leader); and Follower (followers of the Leader, who cannot initiate elections). The Raft election process is as follows: During initialization, all nodes are in the Follower state. When leader election begins, all nodes change their state from Follower to Candidate and send election requests to other nodes. Other nodes respond to these requests in the order they are received, indicating whether they agree to become the leader. It's important to note that in each election round, a node can only cast one vote. If the node initiating the election request receives more than half the votes, it becomes the leader, and its state changes to Leader. Other nodes' states change from Candidate to Follower. The Leader and Follower nodes periodically send heartbeats to check if the leader is alive. When the leader's term expires (i.e., when other servers begin the next leader election cycle), the leader's state changes from Leader to Follower, and a new leader election cycle begins. In each election round, each node can only cast one vote. In the Raft algorithm, leader election is cyclical, consisting of two phases: leader election and appointment. The leader election phase corresponds to the voting phase, and the appointment phase corresponds to the node's term after becoming the leader. However, there are exceptions. If the master node fails, an election will be initiated immediately to elect a new master node.
[0048] Step S12: Obtain the cluster configuration parameters of the target distributed key-value storage system cluster corresponding to the cluster name from the cluster configuration file based on the cluster name; the cluster configuration parameters include the cluster name and the Internet Protocol address and port number of each cluster node in the target distributed key-value storage system cluster.
[0049] In this embodiment, the Internet Protocol address is also known as the IP (Internet Protocol) address.
[0050] In this embodiment, the cluster configuration file pre-stores the configuration files corresponding to each distributed key-value storage system cluster. Therefore, the cluster configuration parameters of the target distributed key-value storage system cluster corresponding to the cluster name can be obtained from the cluster configuration file based on the cluster name. That is, the configuration file corresponding to the cluster name is obtained from the cluster configuration file based on the cluster name, and then the cluster configuration parameters of the target distributed key-value storage system cluster are obtained from the configuration file corresponding to the cluster name.
[0051] It should be noted that when a cluster node belongs to multiple different distributed key-value storage system clusters, the cluster node uses different ports in different clusters.
[0052] In one specific embodiment, the configuration file / etc / etcd / conf.yml corresponding to the cluster name includes three cluster nodes, and the following cluster configuration information can be obtained:
[0053] Node 1: IP1: Port1;
[0054] Node 2: ip2:port2;
[0055] Node 3: IP3:Port3;
[0056] Cluster name: cluster_etcd.
[0057] Step S13: Set the target environment variable in the local client configuration file based on the cluster configuration parameters, and execute the command line after the target environment variable takes effect. When the command line is executed, associate and execute the cluster instance corresponding to the cluster configuration parameters to obtain the corresponding cluster instance execution result.
[0058] In this embodiment, setting the target environment variable in the local client configuration file based on the cluster configuration parameters includes: if the original environment variable exists in the client configuration file, determining whether the original environment variable is the environment variable corresponding to the cluster configuration parameters; if the original environment variable is not the environment variable corresponding to the cluster configuration parameters, setting the target environment variable in the local client configuration file based on the cluster configuration parameters; if the original environment variable is the environment variable corresponding to the cluster configuration parameters, directly setting the original environment variable as the target environment variable.
[0059] It should be noted that if there is insufficient storage space for environment variables, the original environment variable can be deleted if it is not the same as the environment variable corresponding to the cluster configuration parameters, and the target environment variable can be set in the local client configuration file based on the cluster configuration parameters; this solution can effectively save space.
[0060] In one specific embodiment, the client configuration file .bashrc is located in the local environment's home directory, and the target environment variables are set in the file, as shown below:
[0061] host1 = ip1:port1;
[0062] host2 = ip2:port2;
[0063] host3 = ip3:port3;
[0064] etcd_nm = cluster_etcd;
[0065] etcdpoint=${host1},${host2},${host3};
[0066] alias cli-${etcd_nm}="etcdctl--endpoints=${etcdpoint}".
[0067] Save the target environment variables and execute the command source.bashrc to make the environment variables effective. At this time, if the command line is executed to query the cluster status, the command line is already associated with the Internet protocol address and port of each node in the cluster, which is equivalent to executing etcdctl --endpoints=ip1:port1,ip2:port2,ip3:port3 endpoint status.
[0068] In summary, this application encapsulates the client command line and encapsulates the cluster name in the command line through system environment variables. When executing a command, it can be directly associated with the corresponding cluster instance and achieve the execution result of the corresponding cluster instance.
[0069] It should be noted that different simple cluster symbols can be set for different distributed key-value storage system clusters. The cluster configuration information also includes the cluster symbol, cluster name, Internet Protocol address and port number of each cluster node. The cluster symbol can then be directly encapsulated in the command line. Compared with the cluster name, the cluster symbol is simpler, which reduces the possibility of input errors.
[0070] As can be seen, when this application obtains the command line corresponding to the distributed key-value storage software, it extracts the pre-encapsulated cluster name of the target distributed key-value storage system cluster from the command line; based on the cluster name, it obtains the cluster configuration parameters of the target distributed key-value storage system cluster corresponding to the cluster name from the cluster configuration file; the cluster configuration parameters include the cluster name and the Internet Protocol address and port number of each cluster node in the target distributed key-value storage system cluster; based on the cluster configuration parameters, it sets the target environment variable in the local client configuration file, and executes the command line after the target environment variable takes effect; and when the command line is executed, it associates and executes the cluster instance corresponding to the cluster configuration parameters to obtain the corresponding cluster instance execution result. Therefore, this application reduces the amount of input and the possibility of input errors by replacing the input of the Internet Protocol address and port number with the input of the cluster name in the command line; the required Internet Protocol address and port number can be found in the cluster configuration file based on the cluster name, thus identifying the correct cluster instance. Therefore, it can execute the correct cluster instance without inputting the Internet Protocol address and port number of the cluster nodes in the command line.
[0071] This application discloses a specific cluster instance execution method, applied to a client generated based on distributed key-value storage software. Compared to the previous embodiment, this embodiment further explains and optimizes the technical solution. See also... Figure 2 As shown, it specifically includes:
[0072] Step S21: Continuously determine the log content when executing the command line and the cluster instance, and store the log content in the cache corresponding to the target distributed key-value storage system cluster.
[0073] In this embodiment, each target distributed key-value storage system cluster can have a corresponding cache for storing log content.
[0074] Step S22: When all the log content stored in the cache reaches the preset transfer requirement, all the log content stored in the cache is transferred to the preset storage file corresponding to the target distributed key-value storage system cluster; the preset storage file is used to store the log content for a long time.
[0075] In this embodiment, since the log content in the cache has certain keep-alive time and size limits, the cache is cleared after the keep-alive time is exceeded or the cache limit is reached. This also means that the original log is not written to the disk, but only a part of the content is saved or it will be automatically cleared after a certain period of time. In this case, it is inconvenient for users to query historical log content. Therefore, it is proposed to set up a file for long-term storage of log content, that is, a preset storage file. When all the log content stored in the cache reaches the preset transfer requirement, all the log content stored in the cache is transferred to the preset storage file corresponding to the target distributed key-value storage system cluster for long-term storage.
[0076] It should be noted that the log content in the cache will only be transferred after the preset transfer requirements are met. This is because if the log content is transferred to the preset storage file as soon as it is obtained from the cache, the CPU (Central Processing Unit) resource usage for IO (Input / Output) will be increased due to frequent file reading and writing, resulting in increased CPU load.
[0077] It should be noted that the preset transfer requirement is that the first content of all the log content stored in the cache is not less than the preset storage quantity, and / or the storage time of the log content in the cache is not less than the preset keep-alive time.
[0078] In this embodiment, when transferring log content to a preset storage file, it is necessary to know the file path parameters to be stored in the preset storage file. Therefore, the file path parameters can be obtained from the cluster configuration file, which pre-stores the file path parameters corresponding to the target distributed key-value storage system cluster. Specifically, as shown below: transferring all the log content stored in the cache to the preset storage file corresponding to the target distributed key-value storage system cluster includes: obtaining the file path parameters corresponding to the target distributed key-value storage system cluster from the cluster configuration file based on the cluster name; and transferring all the log content stored in the cache to the preset storage file corresponding to the target distributed key-value storage system cluster based on the file path parameters.
[0079] In this embodiment, if the preset storage file contains too much log content, it will consume a lot of space and affect CPU operation. Therefore, when the preset storage file contains too much log content, it needs to be deleted. Furthermore, the deleted log content needs to be older log content, not the most recently stored log content. Specifically, after transferring all the log content stored in the cache to the preset storage file corresponding to the target distributed key-value storage system cluster, the method further includes: when all the log content stored in the preset storage file reaches the preset deletion requirement, deleting the target proportion of the log content stored in the preset storage file according to the storage order. The preset deletion requirement is that the second content quantity of all the log content stored in the preset storage file is not less than the preset storage quantity, and / or, the actual storage time of all the log content stored in the preset storage file is not less than the preset storage time.
[0080] It should be noted that the target percentage is set according to the actual situation and is not specifically limited here.
[0081] It should be noted that, since the preset storage file is a long-term storage compared to the cache, the preset storage quantity is less than the preset storage quantity, and the preset keep-alive time is less than the preset storage time.
[0082] It should be noted that different preset storage times can be set in advance for different log content. Specifically, the preset storage times can be reduced from high to low according to the type and / or importance and / or other characteristics that distinguish the log content, and the highest and lowest preset storage times can be set. This solution can effectively distinguish the storage time of different log content, delete log content that does not need to be stored for a long time in a timely manner, which is beneficial to saving space and also to saving the necessary log content.
[0083] It's worth noting that the existence of a pre-defined storage file for long-term log content allows for querying log content from a previous period. This is highly beneficial for troubleshooting, tracking, and analyzing problems, improving system configuration and optimizing system usage to some extent. It also facilitates system maintenance and operation. Overall, it solves the following problems: Currently, viewing logs is inconvenient when there are exceptions or errors. The current method involves checking the service running status using `systemctl status etcd` or executing `journalctl -u etcd` to view the current logs, but historical logs are not available, making it difficult to find, analyze, and resolve problems.
[0084] Step S23: Delete all the log content stored in the cache, and jump to the step of continuously determining the log content when executing the command line and the cluster instance.
[0085] In summary, this application adds configuration parameters to the cluster configuration file to specify the log file path, so that the cached log content is output to the specified log file after the timeout period or storage limit is reached.
[0086] As can be seen, this application continuously determines the log content when executing the command line and the cluster instance, and stores the log content in the cache corresponding to the target distributed key-value storage system cluster; when all the log content stored in the cache reaches the preset transfer requirement, all the log content stored in the cache is transferred to the preset storage file corresponding to the target distributed key-value storage system cluster; the preset storage file is used to store the log content for a long time; all the log content stored in the cache is deleted, and the process jumps to the step of continuously determining the log content when executing the command line and the cluster instance. Therefore, this application transfers the log content that is about to be deleted from the cache to a preset storage file that can be stored for a long time, facilitating subsequent viewing of the log content; the preset storage file also has a corresponding preset storage quantity and preset storage time to prevent the preset storage file from having too much log content.
[0087] Accordingly, this application also discloses a cluster instance execution device, applied to a client generated based on distributed key-value storage software, see [link to relevant documentation]. Figure 3 As shown, the device includes:
[0088] The cluster name acquisition module 11 is used to extract the pre-packaged cluster name of the target distributed key-value storage system cluster from the command line corresponding to the distributed key-value storage software when the command line corresponding to the distributed key-value storage software is obtained.
[0089] The configuration parameter acquisition module 12 is used to obtain the cluster configuration parameters of the target distributed key-value storage system cluster corresponding to the cluster name from the cluster configuration file based on the cluster name; the cluster configuration parameters include the cluster name and the Internet Protocol address and port number of each cluster node in the target distributed key-value storage system cluster;
[0090] The environment variable setting module 13 is used to set target environment variables in the local client configuration file based on the cluster configuration parameters, execute the command line after the target environment variables take effect, and associate and execute the cluster instance corresponding to the cluster configuration parameters when the command line is executed to obtain the corresponding cluster instance execution result.
[0091] The more specific working process of each of the above modules can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0092] As can be seen, when this application obtains the command line corresponding to the distributed key-value storage software, it extracts the pre-encapsulated cluster name of the target distributed key-value storage system cluster from the command line; based on the cluster name, it obtains the cluster configuration parameters of the target distributed key-value storage system cluster corresponding to the cluster name from the cluster configuration file; the cluster configuration parameters include the cluster name and the Internet Protocol address and port number of each cluster node in the target distributed key-value storage system cluster; based on the cluster configuration parameters, it sets the target environment variable in the local client configuration file, and executes the command line after the target environment variable takes effect; and when the command line is executed, it associates and executes the cluster instance corresponding to the cluster configuration parameters to obtain the corresponding cluster instance execution result. Therefore, this application reduces the amount of input and the possibility of input errors by replacing the input of the Internet Protocol address and port number with the input of the cluster name in the command line; the required Internet Protocol address and port number can be found in the cluster configuration file based on the cluster name, thus identifying the correct cluster instance. Therefore, it can execute the correct cluster instance without inputting the Internet Protocol address and port number of the cluster nodes in the command line.
[0093] In one embodiment, the cluster instance execution device further includes:
[0094] The log content storage module is used to continuously determine the log content when executing the command line and the cluster instance, and store the log content in the cache corresponding to the target distributed key-value storage system cluster;
[0095] The log content transfer module is used to transfer all the log content stored in the cache to a preset storage file corresponding to the target distributed key-value storage system cluster when all the log content stored in the cache reaches the preset transfer requirement; the preset storage file is used to store the log content for a long time.
[0096] The first log content deletion module is used to delete all the log content stored in the cache and jump to the step of continuously determining the log content when executing the command line and the cluster instance.
[0097] In one embodiment, the log content transfer module includes:
[0098] The file path parameter acquisition unit is used to obtain the file path parameter corresponding to the target distributed key-value storage system cluster from the cluster configuration file based on the cluster name.
[0099] The log content transfer unit is used to transfer all the log content stored in the cache to a preset storage file corresponding to the target distributed key-value storage system cluster based on the file path parameter.
[0100] In one embodiment, the preset transfer requirement is that the first content quantity of all the log content stored in the cache is not less than a preset storage quantity, and / or, the storage time of the log content in the cache is not less than a preset keep-alive time.
[0101] In one embodiment, the cluster instance execution device further includes:
[0102] The second log content deletion module is used to delete the target percentage of log content among all the log content stored in the preset storage file according to the storage order when all the log content stored in the preset storage file reaches the preset deletion requirements.
[0103] In one embodiment, the preset deletion requirement is that the second content quantity of all the log content stored in the preset storage file is not less than a preset storage quantity, and / or that the actual storage time of all the log content stored in the preset storage file is not less than a preset storage time.
[0104] In one embodiment, the environment variable setting module 13 specifically includes:
[0105] The judgment unit is used to determine whether the original environment variable is the environment variable corresponding to the cluster configuration parameter if the original environment variable exists in the client configuration file.
[0106] The first environment variable setting unit is used to set the target environment variable in the local client configuration file based on the cluster configuration parameters if the original environment variable is not the environment variable corresponding to the cluster configuration parameters.
[0107] The second environment variable setting unit is used to directly set the original environment variable as the target environment variable if the original environment variable is the environment variable corresponding to the cluster configuration parameters.
[0108] Furthermore, embodiments of this application also provide an electronic device. Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0109] Figure 4This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a display screen 23, an input / output interface 24, a communication interface 25, a power supply 26, and a communication bus 27. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the cluster instance execution method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0110] In this embodiment, the power supply 26 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 25 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 24 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0111] Furthermore, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored thereon may include computer programs 221, and the storage method may be temporary storage or permanent storage. The computer programs 221 may include, in addition to computer programs capable of performing the cluster instance execution method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, computer programs capable of performing other specific tasks.
[0112] Furthermore, embodiments of this application also disclose a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned cluster instance execution method.
[0113] The specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0114] The various embodiments in this application are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. For the same or similar parts between the various embodiments, refer to each other. As for the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and relevant parts can be referred to in the method section.
[0115] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0116] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0117] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0118] The above provides a detailed description of a cluster instance execution method, apparatus, device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for executing cluster instances, characterized in that, Applied to clients generated based on distributed key-value storage software, including: When the command line corresponding to the distributed key-value storage software is obtained, the cluster name of the pre-packaged target distributed key-value storage system cluster is extracted from the command line. Based on the cluster name, the cluster configuration parameters of the target distributed key-value storage system cluster corresponding to the cluster name are obtained from the cluster configuration file; the cluster configuration parameters include the cluster name and the Internet Protocol address and port number of each cluster node in the target distributed key-value storage system cluster; Based on the cluster configuration parameters, the target environment variable is set in the local client configuration file, and the command line is executed after the target environment variable takes effect. When the command line is executed, the cluster instance corresponding to the cluster configuration parameters is associated and executed to obtain the corresponding cluster instance execution result.
2. The cluster instance execution method according to claim 1, characterized in that, Also includes: Continuously determine the log content when executing the command line and the cluster instance, and store the log content in the cache corresponding to the target distributed key-value storage system cluster; When all the log content stored in the cache reaches the preset transfer requirement, all the log content stored in the cache will be transferred to the preset storage file corresponding to the target distributed key-value storage system cluster. The preset storage file is used to store the log content for a long period of time; Delete all the log content stored in the cache, and proceed to the step of continuously determining the log content when executing the command line and the cluster instance.
3. The cluster instance execution method according to claim 2, characterized in that, The step of transferring all the log content stored in the cache to the preset storage file corresponding to the target distributed key-value storage system cluster includes: Based on the cluster name, obtain the file path parameters corresponding to the target distributed key-value storage system cluster from the cluster configuration file; Based on the file path parameters, all the log content stored in the cache is transferred to the preset storage file corresponding to the target distributed key-value storage system cluster.
4. The cluster instance execution method according to claim 2, characterized in that, The preset transfer requirement is that the first content quantity of all the log content stored in the cache is not less than the preset storage quantity, and / or, the storage time of the log content in the cache is not less than the preset keep-alive time.
5. The cluster instance execution method according to claim 2, characterized in that, After transferring all the log content stored in the cache to the preset storage file corresponding to the target distributed key-value storage system cluster, the method further includes: When all the log content stored in the preset storage file reaches the preset deletion requirement, the target percentage of the log content stored in the preset storage file is deleted in the order of storage.
6. The cluster instance execution method according to claim 5, characterized in that, The preset deletion requirement is that the number of second contents of all the log contents stored in the preset storage file is not less than the preset storage quantity, and / or that the actual storage time of all the log contents stored in the preset storage file is not less than the preset storage time.
7. The cluster instance execution method according to any one of claims 1 to 6, characterized in that, Setting the target environment variable in the local client configuration file based on the cluster configuration parameters includes: If the original environment variable exists in the client configuration file, then determine whether the original environment variable is the environment variable corresponding to the cluster configuration parameter; If the original environment variable is not the environment variable corresponding to the cluster configuration parameter, then the target environment variable is set in the local client configuration file based on the cluster configuration parameter; If the original environment variable is the same as the environment variable corresponding to the cluster configuration parameters, then the original environment variable is directly set as the target environment variable.
8. A cluster instance execution device, characterized in that, Applied to clients generated based on distributed key-value storage software, including: The cluster name acquisition module is used to extract the pre-packaged cluster name of the target distributed key-value storage system cluster from the command line corresponding to the distributed key-value storage software when the command line is obtained. The configuration parameter acquisition module is used to obtain the cluster configuration parameters of the target distributed key-value storage system cluster corresponding to the cluster name from the cluster configuration file based on the cluster name; the cluster configuration parameters include the cluster name and the Internet Protocol address and port number of each cluster node in the target distributed key-value storage system cluster; The environment variable setting module is used to set target environment variables in the local client configuration file based on the cluster configuration parameters, execute the command line after the target environment variables take effect, and associate and execute the cluster instance corresponding to the cluster configuration parameters when the command line is executed to obtain the corresponding cluster instance execution result.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the cluster instance execution method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer programs are executed by a processor, they implement the cluster instance execution method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
High-availability cluster software maintaining method, device and system
CN104468725A
Deployment system and deployment method of application program
CN105867955A
