Disclosure of Invention
Aiming at the problems that in the prior art, workers manually install and configure MongoDB when a MongoDB cluster is deployed, the operation steps are complex, and manpower consumption is huge, the MongoDB cluster deployment method and the system based on Python are provided, and are used for solving the problems that in the prior art, when the MongoDB cluster is deployed, the operation steps are complex, and the manpower consumption is huge to a certain extent.
The above object of the present application is achieved by the following technical solutions:
in a first aspect, an embodiment of the present application provides a Python-based montgodb cluster deployment method, including:
acquiring cluster type information and database version information;
distributing servers in a preset host pool based on the cluster type information and the database version information, and downloading an installation package to a specified directory of the servers; wherein the number of the servers is at least one;
pre-checking each server and judging whether each server is available; the pre-checking comprises checking whether the network connection of the server is normal or not and checking whether the resource configuration of the server meets the installation requirement or not;
and after the servers pass the pre-inspection and are confirmed to be available, respectively installing installation packages according to the preset node role information of each server, and modifying the relevant configuration files to finish the cluster deployment.
Optionally, the method further includes:
performing initialization setting on the cluster; the initialization setting comprises the steps of generating a management account and recording the management account into a database list.
Optionally, after the initializing and setting of the cluster is completed, the method further includes:
verifying the cluster information; the cluster information comprises a cluster state, account number authority and a database list.
Optionally, the method further includes:
and recording the state information of each node server in the deployment process to generate a log file.
Optionally, the method further includes:
when each server is subjected to pre-inspection, if the server is judged to be unavailable, a prompt is sent, and the server is distributed from a preset host pool again;
and when the cluster information is verified, if abnormal verification is found, sending a prompt and deploying again.
In a second aspect, an embodiment of the present application further provides a Python-based montgodb cluster deployment system, including:
the deployment module is used for distributing the servers from a preset host pool based on the mongodb cluster type information and the database version information and downloading the installation packages to the server designated directory; wherein the number of the servers is at least one;
the pre-checking module is used for pre-checking the configuration and resources of the server and judging whether the server is available; the pre-checking comprises checking whether the network connection of the server is normal or not and checking whether the resource configuration of the server meets the installation requirement or not;
the installation module is used for installing an installation package of the MongoDB on the server;
the configuration module is used for configuring the cluster after the installation is finished; the configuration comprises account configuration, security authentication and addition monitoring;
and the checking module is used for checking the state of the cluster after the deployment is finished, and checking whether the operating state of the mongodb node and the checking configuration are correct or not.
The technical scheme provided by the embodiment of the application can have the following beneficial effects:
in the technical scheme provided by the embodiment of the application, cluster type information and database version information are obtained through a preset system; distributing servers in a preset host pool based on the cluster type information and the database version information, and downloading an installation package to a specified directory of the servers; wherein the number of the servers is at least one; then, pre-checking each server to judge whether each server is available; the pre-checking comprises checking whether the network connection of the server is normal or not and checking whether the resource configuration of the server meets the installation requirement or not; and after the servers pass the pre-inspection and are confirmed to be available, respectively installing installation packages according to the preset node role information of each server, and modifying the relevant configuration files to finish the cluster deployment. Therefore, one-button mongodb cluster deployment can be achieved through the preset system, pre-detection can be conducted before deployment, abnormal installation of the node servers is reduced, and the success rate of deployment is improved. And the deployment process information is recorded and the deployment result is checked through a preset system, so that the later-stage use and maintenance are facilitated.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
In the prior art, the cluster deployment mode is manually installed, and then each mongodb node is configured, when a fragmented cluster is deployed, the configuration of each node is greatly different, so that deployment failure is easily caused by configuration errors, a large amount of time is consumed for redeployment, and delivery delay may be caused. Each node has no uniform installation standard, and the nodes need to be manually added to a monitoring and maintaining list and the like, so that the maintenance of a database at the later stage is not facilitated.
Example (b):
fig. 1 is a schematic flowchart of a Python-based montgodb cluster deployment method shown in an embodiment of the present application, and as shown in fig. 1, the Python-based montgodb cluster deployment method provided in the embodiment of the present application includes:
s101, acquiring cluster type information and database version information;
before MongoDB cluster deployment, cluster type information and database version information are firstly acquired through a preset system, and the information can be acquired from preset equipment or can be pre-stored in the system and used as a basis for downloading a related installation package.
S102, distributing servers in a preset host pool based on the cluster type information and the database version information, and downloading an installation package to a designated directory of the servers; wherein the number of the servers is at least one;
specifically, the mongodb cluster type and the database version are determined based on the mongodb cluster type and the database version information, then, the server is automatically distributed from the host pool through a preset system according to the cluster type, and the related installation package is downloaded from a remote software warehouse according to the database version and is sent to the assigned directory of the distributed server.
S103, pre-checking each server, and judging whether each server is available; the pre-checking comprises checking whether the network connection of the server is normal or not and checking whether the resource configuration of the server meets the installation requirement or not;
in particular, because the servers for installing the installation packages are required to be deployed in the MongoDB cluster, that is, the servers distributed from the host pool by the above-mentioned preset system, the number of the servers is generally large, and if the sharded cluster may be deployed, dozens of servers are required to be used as the MongoDB nodes. After the servers are distributed, the preset system, namely the deployment system, is actively connected to each server node to perform pre-check, and whether the servers are available or not, whether the resource configuration meets the installation requirements and the like, including network connectivity, disk space and the like, are checked, and if the check fails, the servers need to be reconfigured according to the prompt of the failure reason until the pre-check passes. Through the pre-inspection, the problem of abnormal installation in the deployment process can be effectively avoided, and the accuracy of the mongodb cluster deployment is guaranteed.
And S104, after the servers pass the pre-inspection and are confirmed to be available, respectively installing installation packages according to the preset node role information of each server, and modifying the relevant configuration files to complete cluster deployment.
Specifically, after the checking is passed, that is, after the server is determined to be available and the configuration meets the installation condition, the installation of the cluster is started. And installing different database installation packages and modifying related configuration files according to the configured node role information at each node. In addition, after the node installation is completed, the deployment system can check the node state and confirm that the node database is successfully installed; and when the state of each node is normal, namely the node database is successfully installed, deploying the cluster.
It should be noted that, the installation process is to install the montodb, including installation of a single machine, a copy set, and a fragmented cluster, and a user can install different types of clusters according to the needs of the user; the configuration process is the configuration of the cluster after installation, and comprises account configuration, security authentication, addition monitoring and the like, so that the maintenance of the database at the later stage is facilitated.
In practical application, in the process of deploying the cluster, the node information of the cluster is recorded in a database list, so that the node information is convenient to view and maintain. And after the cluster installation is finished, initializing the cluster, generating a management account and recording the management account into a database list.
Further, the Python-based montgodb cluster deployment method provided in the embodiment of the present application, after the initialization setting of the cluster is completed, further includes: verifying the cluster information; the cluster information comprises a cluster state, account number authority and a database list.
Specifically, the verification process is verification check for the state after the cluster deployment is completed. After the cluster configuration is completed, the deployment system checks cluster states such as operating states of mongodb nodes, account number authorities, database lists, whether the configuration is correct or not, and the like, and confirms that the cluster states are normal and the configuration is correct; if the cluster deployment installation is abnormal, the cluster deployment installation is required to be redeployed after modification according to the abnormal prompt, so that the accuracy of the cluster deployment installation is ensured.
It should be noted that, in the deployment process, the preset system, that is, the deployment system, may also record the deployment details in a log file, so as to facilitate viewing of the operation log and the exception log.
A Python-based montgodb cluster deployment method provided in the present application is described below with a specific implementation flow, and fig. 2 is a schematic flow chart of the Python-based montgodb cluster deployment method shown in another embodiment of the present application, and as shown in fig. 2, the Python-based montgodb cluster deployment method includes:
after selecting the MongoDB cluster type and the database version through the MongoDB cluster deployment system, automatically distributing the servers from the host pool according to the cluster type, downloading the related installation packages from a remote software warehouse according to the database version, and sending the related installation packages to the assigned directory of the distributed servers; then, node pre-inspection is carried out, namely, pre-inspection is carried out on each server node to determine whether the server is available; after the server is determined to be available, cluster installation is carried out, namely different databases are installed according to the configured node roles and the steps; after the installation is finished, cluster configuration is carried out to finish deployment; finally, cluster verification is carried out on the state and the information of the cluster nodes, and the accuracy of cluster deployment is ensured; in addition, in the whole process, information such as node information of the cluster and management account numbers generated in the cluster configuration process is recorded in a database list, and deployment details are recorded in a log file, so that operation logs and abnormal logs can be conveniently checked, and later-stage use and maintenance are facilitated.
Fig. 3 is a schematic structural diagram of a Python-based MongoDB cluster deployment system according to an embodiment of the present application. As shown in fig. 3, the Python-based montgodb cluster deployment system provided in the embodiment of the present application includes:
the deployment module is used for distributing the servers from a preset host pool based on the mongodb cluster type and the database version information and downloading the installation packages to the server designated directory; wherein the number of the servers is at least one;
the pre-checking module is used for pre-checking the server configuration and resources and judging whether the server is available; the pre-checking comprises checking whether the network communication of the server is normal and checking whether the resource configuration of the server meets the installation requirements, wherein the checking comprises checking the network communication, the disk space and the like, so that the abnormal installation condition in the deployment process is avoided, and the correctness of the deployment of the mongodb cluster is ensured.
The installation module is used for installing an installation package of the MongoDB on the server; the method comprises the installation of a single machine, a copy set and a fragment cluster, and in practical application, users can install different types of clusters according to own requirements.
The configuration module is used for configuring the cluster after the installation is finished; the configuration comprises account configuration, security authentication, addition monitoring and the like, and the maintenance of a database at the later stage is facilitated.
And the checking module is used for checking the state of the cluster after the cluster deployment is finished, including checking the operating state of the mongodb node and checking whether the configuration is correct or not, so that the accuracy of the cluster deployment and installation is ensured.
The Python-based MongoDB cluster deployment system provided by the embodiment of the application is a multi-module cluster deployment system realized based on Python, can automatically allocate cluster node servers, pre-check the node servers before installation, start installing MongoDB and configuring after the check is passed, and check the cluster state after the installation and configuration are finished; the MongoDB cluster one-key installation and deployment can be realized, the installation power is improved through pre-inspection, and meanwhile, the deployment accuracy can be ensured through recording and verifying the installation and deployment process information. In practical application, the system can be installed and deployed by one key and the deployment result can be verified only by filling the information of each node into the system by related personnel before deployment, and the installation and deployment can be quickly and efficiently realized aiming at the deployment of various types of clusters such as a fragment cluster, a copy cluster and the like, so that a large amount of time is saved for a user, and the working efficiency is improved.
It is understood that the same or similar parts in the above embodiments may be mutually referred to, and the same or similar parts in other embodiments may be referred to for the content which is not described in detail in some embodiments.
It should be noted that, in the description of the present application, the terms "first", "second", etc. are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. Further, in the description of the present application, the meaning of "a plurality" means at least two unless otherwise specified.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and the scope of the preferred embodiments of the present application includes other implementations in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present application.
It should be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present application may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc.
In the description herein, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
Although embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present application, and that variations, modifications, substitutions and alterations may be made to the above embodiments by those of ordinary skill in the art within the scope of the present application.