Disclosure of Invention
The invention aims to overcome the defects of the prior art, provides a method and a system for protecting openstack cloud host data, and solves the problems that the traditional openstack data scheme does not support on-line cloud host snapshot, a complete non-invasive cloud host backup scheme is lacked, the backup efficiency is low, the equipment cost is high and the like.
In order to solve the technical problem, the invention provides an openstack cloud host data protection method which is characterized in that,
pre-installing a ceph client on a backup agent, wherein the ceph client is used for connecting an openstack cloud platform;
the backup agent machine acquires information parameters of a cloud host to be backed up in the openstack cloud platform;
calling the ceph api according to the information parameters to acquire a corresponding storage mirror image of the cloud host on the ceph back end, calling cephapi to perform snapshot operation on the storage mirror image, and exporting the snapshot as a data file;
and uploading the exported data file to a backup server for storage.
Further, the pre-installation process of the ceph client is as follows:
the backup agent machine accesses a storage network of the ceph to carry out file configuration, and writes storage pool configuration consistent with the cloud platform into the configuration file;
the file is configured to: and configuring the ip address, the authentication mode and the authentication key information of the ceph server.
Further, the process of acquiring the data file is as follows:
the backup agent machine calls an openstack api interface to acquire a cloud host id and a cloud host starting type to be backed up;
calling a script to acquire a storage mirror image of the cloud host in a ceph storage pool according to the cloud host id and the cloud host starting type;
and creating a snapshot of the storage image in the ceph storage pool and exporting the snapshot.
Further, the process of uploading the exported data file to the backup server for storage is as follows:
the backup server marks out a block of storage from the medium of the backup server and mounts the block of storage onto the backup agent machine;
the backup agent uploads the data file to the drawn medium on the backup server and saves metadata related to the backup file (the metadata refers to some information related to the backup cloud host, such as cloud host id, cloud host mirror id, network id used by the cloud host, Ip address, mac address, cpu used by the cloud host, and memory information).
An openstack cloud host data protection system comprises a pre-installation module, a parameter acquisition module, a data file export module and a storage module;
the pre-installation module is used for pre-installing a ceph client on the backup agent, and the ceph client is used for connecting an openstack cloud platform;
the parameter acquisition module is used for the backup agent machine to acquire information parameters of the cloud host to be backed up in the openstack cloud platform;
the data file export module is used for calling the ceph api according to the information parameters to acquire a corresponding storage mirror image of the cloud host on the ceph back end, calling the ceph api to perform snapshot operation on the storage mirror image, and exporting the snapshot as a data file;
and the storage module is used for uploading the exported data file to a backup server for storage.
Further, the preinstallation module comprises a configuration module, and the configuration module is used for enabling the backup agent to access a ceph storage network for file configuration and writing storage pool configuration consistent with the cloud platform into the configuration file; the file is configured to: and configuring the ip address, the authentication mode and the authentication key information of the ceph server.
Further, the data file export module comprises a first calling module, a second calling module and a snapshot module;
the first calling module is used for calling an openstack api interface by the backup agent to acquire a cloud host id and a cloud host starting type to be backed up;
the second calling module is used for calling the script to acquire a storage mirror image of the cloud host in the ceph storage pool according to the cloud host id and the cloud host starting type;
and the snapshot module is used for creating a snapshot for the storage image in the ceph storage pool and exporting the snapshot.
Further, the storage module comprises a mounting module and an uploading module;
the mounting module is used for the backup server to draw a block of storage from the medium of the backup server and mount the block of storage onto the backup agent machine;
the uploading module is used for uploading the data file to the marked medium on the backup server by the backup agent and storing the metadata related to the backup file.
The invention achieves the following beneficial effects:
the cloud host data protection method under the openstack cloud platform can realize online data protection of the openstack mirror image started cloud host and the cloud host started by the cloud hard disk only through simple configuration, does not need to modify cloud platform parameters, provides a complete non-invasive openstack cloud host protection scheme, improves the integral backup efficiency and reduces the operation and maintenance cost.
Detailed Description
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The technical scheme of the invention is further explained by the specific implementation mode in combination with the attached drawings.
As shown in fig. 1, a method for protecting data of a cloud host under an openstack cloud platform includes: the method comprises the following steps: backup proxy service, ceph client, and backup server.
The backup server is an independent machine, can be a physical machine or a virtual machine, calls an openstack cloud platform to perform api interaction, executes cloud platform authentication, obtains cloud platform parameters and the like.
The specific process is as follows:
1) installing a ceph client on a backup agent machine, wherein the client is used for connecting an openstack cloud platform for storage; a user configures information such as a ceph server ip address, an authentication mode, an authentication key and the like on a backup proxy server; and writing the storage pool configuration consistent with the cloud platform into the configuration file.
2) And the backup proxy service calls a cloud platform API interface to acquire parameters such as the starting type, the virtual machine id, the disk mounting information, the network information and the like of the cloud host to be backed up. According to the starting type and the previously configured cloud platform storage pool information, calling the ceph api to obtain a corresponding storage image of a cloud host (including the cloud host created by the image and the cloud host created by the cloud hard disk) on the ceph back end, and calling the ceph api to perform snapshot operation on the storage image and export the snapshot into a data file.
3) And uploading the exported data file to a backup server for storage.
The specific steps of installing the ceph client in the step 1) comprise:
(1) the backup proxy machine may access the storage network of ceph.
(2) Configuring information such as a ceph server ip address, an authentication mode, an authentication key and the like; and writing the storage pool configuration consistent with the cloud platform into the configuration file.
The cloud host data protection method under the openstack cloud platform is characterized in that: the specific step of calling the ceph api interface in the step 2) comprises the following steps:
(1) and the backup proxy service calls an openstack api interface to acquire the id of the cloud host to be backed up and the starting type of the cloud host.
(2) And calling the script to acquire the storage mirror image of the cloud host in the ceph storage pool by the backup proxy service according to the id and the starting type of the cloud host.
(3) And the backup proxy service creates a snapshot for the storage image in the ceph storage pool and exports the snapshot.
The specific steps of storing the data file in the step 3) comprise:
(1) the backup server has its own media for storing the backed up data.
(2) The backup server will scratch a block of storage from its own media to be mounted on the backup agent.
(3) The backup agent uploads the data files to the media on the backup server and saves metadata associated with the backup files.
Correspondingly, the invention provides an openstack cloud host data protection system which comprises a pre-installation module, a parameter acquisition module, a data file export module and a storage module, wherein the pre-installation module is used for storing data files;
the pre-installation module is used for pre-installing a ceph client on the backup agent, and the ceph client is used for connecting an openstack cloud platform;
the parameter acquisition module is used for the backup agent machine to acquire information parameters of the cloud host to be backed up in the openstack cloud platform;
the data file export module is used for calling the ceph api according to the information parameters to acquire a corresponding storage mirror image of the cloud host on the ceph back end, calling the ceph api to perform snapshot operation on the storage mirror image, and exporting the snapshot as a data file;
and the storage module is used for uploading the exported data file to a backup server for storage.
The pre-installation module comprises a configuration module, and is used for enabling the backup agent machine to access a ceph storage network for file configuration and writing storage pool configuration consistent with the cloud platform into a configuration file; the file is configured to: and configuring the ip address, the authentication mode and the authentication key information of the ceph server.
The data file export module comprises a first calling module, a second calling module and a snapshot module;
the first calling module is used for calling an openstack api interface by the backup agent to acquire a cloud host id and a cloud host starting type to be backed up;
the second calling module is used for calling the script to acquire a storage mirror image of the cloud host in the ceph storage pool according to the cloud host id and the cloud host starting type;
and the snapshot module is used for creating a snapshot for the storage image in the ceph storage pool and exporting the snapshot.
The storage module comprises a mounting module and an uploading module;
the mounting module is used for the backup server to draw a block of storage from the medium of the backup server and mount the block of storage onto the backup agent machine;
the uploading module is used for uploading data files to a drawn medium on the backup server by the backup agent, and storing metadata related to the backup files (the metadata refers to some information related to the backup cloud host, such as a cloud host id, a cloud host mirror image id, a network id used by the cloud host, an Ip address, a mac address, a cpu used by the cloud host, and memory information).
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.