CN116166204A - 一种多版本加密存储的迁移方法 - Google Patents
一种多版本加密存储的迁移方法 Download PDFInfo
- Publication number
- CN116166204A CN116166204A CN202310420691.XA CN202310420691A CN116166204A CN 116166204 A CN116166204 A CN 116166204A CN 202310420691 A CN202310420691 A CN 202310420691A CN 116166204 A CN116166204 A CN 116166204A
- Authority
- CN
- China
- Prior art keywords
- storage
- name
- statement
- destination
- mirror
- 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.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0626—Reducing size or complexity of storage systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/064—Management of blocks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/0643—Management of files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0646—Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
- G06F3/0647—Migration mechanisms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0646—Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
- G06F3/065—Replication mechanisms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/067—Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明涉及分布式存储技术领域,具体是一种多版本加密存储的迁移方法,包括以下步骤:步骤1、在源命名空间里找到存储声明对应的存储卷及存储卷对应的镜像名,并存储;步骤2、找到目的命名空间里存储声明对应的存储卷及存储卷对应的镜像名,并存储;步骤3、将两边得到的结果分别导出为文件;步骤4、将标记好的文件名和目的命令空间存储声明进行对比,找到目的空间的存储声明导出的镜像名,并进行还原操作,完成迁移,本发明能够满足现今生产上常用数据加密迁移需求,且该多版本加密存储的迁移方法支持openshift\kubernetes及其它常用的容器编排平台而不需要修改代码,使得多版本加密存储的迁移更加高效、便捷。
Description
技术领域
本发明涉及分布式存储技术领域,具体是一种多版本加密存储的迁移方法。
背景技术
数据迁移是指将数据从一个位置转移到另一个位置,从一种格式转换为另一种格式,或从一个应用程序移动到另一个应用程序的过程,数据迁移通常是为数据引入新系统或位置的结果,业务驱动因素通常是应用程序迁移或整合,在这种迁移或整合中,原有系统会被共享同一数据集的新应用程序所取代或增强,如今,随着企业从内部基础架构和应用程序迁移到基于云的存储和应用程序以优化或转变公司,数据迁移即开始。
块存储(CephBlock Device),块是字节序列(通常为512),基于块的存储接口是在HDD、SSD、CD、软盘甚至磁带等介质上存储数据的一种成熟且常用的方法,块设备接口的普遍存在非常适合与包括Ceph在内的海量数据存储进行交互;
Ceph块设备是精简配置的、可调整大小的,并且存储数据分布在多个OSD上,Ceph块设备利用RADOS功能,包括快照、复制和强一致性,Ceph块存储客户端通过内核模块或librbd库与Ceph集群通信;
Ceph的块设备为内核模块或QEMU等KVM以及依赖libvirt和QEMU与Ceph块设备集成的基于云的计算系统(如OpenStack和CloudStack)提供高性能和巨大的可扩展性,您可以使用同一个集群同时操作Ceph RADOS网关、Ceph文件系统和Ceph块设备。
那么在容器编排平台实际使用块设备时,时常会有对数据迁移的需求,由其现在许多企业是将命名空间充当了企业空间的角色,那么当企业需要重新整或者重新创建,那么初始数据或者原始数据则需要被迁移到新的命名空间中,在企业使用容器时间,经常会创建大量的容器,那么在发生数据需要迁移时,工作量的巨大是难以想象的。
发明内容
本发明的目的在于提供一种多版本加密存储的迁移方法,以解决上述背景技术中提出的问题。
本发明的技术方案是:一种多版本加密存储的迁移方法,包括以下步骤:
步骤1、在源命名空间里找到存储声明对应的存储卷及存储卷对应的镜像名,并存储;
步骤2、找到目的命名空间里存储声明对应的存储卷及存储卷对应的镜像名,并存储;
步骤3、将两边得到的结果分别导出为文件;
步骤4、将标记好的文件名和目的命令空间存储声明进行对比,找到目的空间的存储声明导出的镜像名,并进行还原操作,完成迁移。
优选的,步骤1包括,在源命名空间里,找到对应的存储卷及与存储卷对应的镜像名使用的对应链都是唯一值,具体步骤包括:
步骤101、获取命名空间里的存储声明函数;
步骤102、获取存储卷函数;
步骤103、获取镜像列表函数。
优选的,步骤2还包括,如不存在目的存储声明需要先创建,具体步骤包括:
步骤201、事先创建同名存储声明;
步骤202、组装存储声明对象详细信息;
步骤203、存储声明实际创建;
步骤204、获取目的命名空间的存储声明列表;
步骤205、获取新增的存储卷的列表;
步骤206、组装源命名空间的存储、存储卷、镜像名。
优选的,步骤3包括,将源命名空间的镜像导出后,以同存储声明为匹配条件,将导出的文件还原到目的命名空间对应的镜像中,步骤3中进行导出导入方法具体为:
步骤301、从源命名空间获取到的镜像名称列表;
步骤302、对导出的命名进行组装;
步骤303、等待当前的镜像文件导出完成;
步骤304、正式启动命令导出镜像文件。
优选的,步骤4包括将源命名空间的镜像导出后,以同存储声明为匹配条件,将导出的文件还原到目的命名空间对应的镜像中,步骤4中进行导出导入方法具体为:
步骤401、从目的命名空间获取到的镜像名称列表;
步骤402、将源命名空间的存储声明与目的命名空间获取到的存储声明做匹配;
步骤403、对导出的命名进行组装;
步骤404、等待当前的镜像文件导出完成;
步骤405、正式启动命令,在顺利执行了代码功能后即可返回true给调用端。
本发明通过改进在此提供一种多版本加密存储的迁移方法,与现有技术相比,具有如下改进及优点:
本发明使用该多版本加密存储的迁移方法,能够满足现今生产上常用数据加密迁移需求,且该多版本加密存储的迁移方法支持openshift\kubernetes及其它常用的容器编排平台而不需要修改代码,使得多版本加密存储的迁移更加高效、便捷。
附图说明
下面结合附图和实施例对本发明作进一步解释:
图1是本发明的整体方法步骤图;
图2是本发明存在目的存储声明时的详细方法步骤图;
图3是本发明步骤2存在或不存在目的存储声明的运行步骤图;
图4是本发明的工作流程图。
具体实施方式
下面对本发明进行详细说明,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
本发明通过改进在此提供一种多版本加密存储的迁移方法,本发明的技术方案是:
如图1-图4所示,一种多版本加密存储的迁移方法,包括以下步骤:
步骤1、在源命名空间里找到存储声明对应的存储卷及存储卷对应的镜像名,并存储,找到对应的存储卷及与存储卷对应的镜像名使用的对应链都是唯一值,具体步骤包括:
步骤101、获取命名空间里的存储声明函数;
步骤102、获取存储卷函数;
步骤103、获取镜像列表函数;
优选以下代码实现该方法:
/* 获取命名空间里的存储声明函数 */
func GetPVCList(namespace,host, user, password string) *corev1.PersistentVolumeClaimList {
pvc :=model.NewPVC(namespace, host, user, password)
option :=metav1.ListOptions{}
pvclist, err:= pvc.List(option)
if err != nil{
panic(err)
}
return pvclist
}
/* 获取存储卷函数 */
func GetPVCADetail(pvcalist*corev1.PersistentVolumeClaimList) []model.PVCDetail {
var pvcdetail= model.PVCDetail{}
varpvcsAdetail []model.PVCDetail
for _, pvc :=range pvcalist.Items {
// if pvc.Name != "migrate-test" {
// continue
// }
fmt.Printf("get pvc:%s from cluster A \n", pvc.Name)
pvcdetail.PVCName = pvc.Name
pvcdetail.PVCSize = pvc.Spec.Resources.Requests.Storage().String()
pvcsAdetail = append(pvcsAdetail, pvcdetail)
}
fmt.Printf("getpvc list detail in cluster A:%#v\n", pvcsAdetail)
returnpvcsAdetail
}
/* 获取镜像列表函数 */
func GetPVList(namespace,host, user, password string) *corev1.PersistentVolumeList {
pv :=model.NewPv(namespace, host, user, password)
pvlist, err :=pv.List()
if err != nil{
panic(err)
}
for _, v :=range pvlist.Items {
if v.Spec.RBD == nil {
continue
}
fmt.Printf("get pv list from cluster A pvname: %s, pvimagename:%s\n",v.Name, v.Spec.RBD.RBDImage)
}
return pvlist
}
func表示语言关键字,表示声明一个方法,GetPVCList()表示该方法的方法名,pvclist表示从corev1包里引用了PersistentVolumeClaimList里的值交将该值赋值给了pvclist,namespace表示根据限制命名空间存储声明,host表示容器编排平台(如openshift、kubernetes)的集群标识,user表示在与集群交互时使用的用户名,password表示在与集群交互时使用的密码;pvcalist表示从源命名空间获取的pvc列表,model.PVCDetail表示获取重新组装后的信息,GetPVList()表示该方法的方法名,model.NewPv表示获取的pv列表,pvlist表示将处理后的结果返回给调用端;
步骤2、找到目的命名空间里存储声明对应的存储卷及存储卷对应的镜像名,并存储,如不存在目的存储声明需要先创建,具体步骤包括:
步骤201、事先创建同名存储声明;
步骤202、组装存储声明对象详细信息;
步骤203、存储声明实际创建;
步骤204、获取目的命名空间的存储声明列表;
步骤205、获取新增的存储卷的列表;
步骤206、组装源命名空间的存储、存储卷、镜像名;
优选以下代码实现该方法:
/* 事先创建同名存储声明 */
func NewPVC(namespace, host,user, pass string) *PVC {
opclient :=NewOPClient(host, user, pass)
return&PVC{
OPClient: opclient,
Pvc:&corev1.PersistentVolumeClaim{},
Namespace: namespace,
}
}
其中, func表示语言关键字,表示声明一个方法,NewPVC ()表示为此方法的名称,本方法用于创建与源命名空间创建同样的存储声明对象。
/* 组装存储声明对象详细信息 */
for _, pvca := rangepvcadetail {
p :=&model.PVCCREATE{
Name: pvca.PVCName,
StorageSize: pvca.PVCSize,
StorageType: "ceph-rbd",
StorageProvisioner: "kubernetes.io/rbd",
AccessMode:"ReadWriteOnce",
}
pvcb, err := pvcB.Create(p)
//to make sure the pv for cluster b is created
fmt.Printf("pvc:%s in cluster b is created\n", pvcb.Name)
// time.Sleep(10 * time.Second)
if err != nil {
fmt.Printf("create pvc:%s in cluster B err:%#v\n",pvcb.Name, err)
continue
}
fmt.Printf("create pvc %s success in cluster b with storage %spvvolume:%s\n", pvcb.Name, pvca.PVCSize, pvcb.Spec.VolumeName)
}
其中,for表示语言关键字,表示对后面的代码进行循环,&model.PVCCREATE表示声明了一个对象,该对象被传递给下面的方法进行处理后获取返回值。
/* 存储声明实际创建 */
func (m *PVC) Create(p*PVCCREATE) (pvc *corev1.PersistentVolumeClaim,err error) {
m.SetImageTypeMeta()
meta :=&metav1.ObjectMeta{
Name: p.Name,
Namespace: m.Namespace,
Annotations: map[string]string{
"description":"由技术中台创建",
"pv.kubernetes.io/bound-by-controller":"yes",
"volume.beta.kubernetes.io/storage-provisioner":p.StorageProvisioner,
},
}
m.SetImageObjectMeta(meta)
qty, err :=resource.ParseQuantity(p.StorageSize)
if err != nil{
return
}
m.Pvc.Spec =corev1.PersistentVolumeClaimSpec{
AccessModes:[]corev1.PersistentVolumeAccessMode{corev1.PersistentVolumeAccessMode(p.AccessMode)},
//VolumeName: dev.DevName,
Resources: corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
corev1.ResourceStorage: qty,
},
},
StorageClassName:&p.StorageType,
}
option :=metav1.CreateOptions{}
returnm.OPClient.CoreClient.PersistentVolumeClaims(m.Namespace).Create(context.Background(),m.Pvc, option)
}
其中,Create()表示方法名,用于实现创建存储声明的实际功能代码,&metav1.ObjectMeta表示创建的存储声明的元信息,corev1.PersistentVolumeClaimSpec表示创建的存储声明的详细信息,包括读写模式、申请的资源大小及使用的存储类,最后返回创建好的对象给调用端。
/* 获取目的命名空间的存储声明列表 */
func GetPVCList(namespace,host, user, password string) *corev1.PersistentVolumeClaimList {
pvc :=model.NewPVC(namespace, host, user, password)
option :=metav1.ListOptions{}
pvclist, err:= pvc.List(option)
if err != nil{
panic(err)
}
return pvclist
}
其中,GetPVCList()表示为该方法的方法名,在目的命名空间的存储声明创建完成之后,需要获取目的命名空间存储声明的列表,用于与源命名空间的存储声明相对应,便于后面镜像导出导入的数据匹配。corev1.PersistentVolumeClaimList表示构建了一个corev1包当中的PersistentVolumeClaimList对象,并将其返回给调用端
/* 获取新增的存储卷的列表 *
func GetPVList(namespace,host, user, password string) *corev1.PersistentVolumeList {
pv :=model.NewPv(namespace, host, user, password)
pvlist, err :=pv.List()
if err != nil{
panic(err)
}
for _, v :=range pvlist.Items {
if v.Spec.RBD == nil {
continue
}
fmt.Printf("get pv list from cluster A pvname: %s, pvimagename:%s\n",v.Name, v.Spec.RBD.RBDImage)
}
return pvlist
}
其中,for为语言关键字,GetPVList()表示该方法的方法名,用于实现根据存储声明获取存储卷及对应的镜像名称,并将其返回调用端。
/* 组装源命名空间的存储、存储卷、镜像名 */
func GetResults(pvclist*corev1.PersistentVolumeClaimList, pvlist *corev1.PersistentVolumeList)(pvcimages []model.PVCImage) {
for _, pvc :=range pvclist.Items {
for _, pv := range pvlist.Items {
// if pv.Spec.RBD == nil&&pv.Spec.RBD.RBDImage !="kubernetes-dynamic-pvc-f8432d11-74e6-11ec-be60-00163e13230f" {
if pv.Spec.RBD == nil {
continue
}
if pvc.Spec.VolumeName == pv.Name {
pvcimage := model.PVCImage{
PvcName: pvc.Name,
ImageName: pv.Spec.RBD.RBDImage,
}
pvcimages = append(pvcimages, pvcimage)
}
}
}
return
}
其中,GetResults()表示该方法的方法名,本方法用于将得到的源命名空间的存储声明、存储卷以及对应的镜像名进行重新的组装,并将生成的结果返回给调用端。pvclist.Items表示的是在GetPVCList()获取到结果详细信息,pvlist.Items()表示的是方法GetPVList()获取的详细信息,将两个结果进行重新匹配得到存储声明、存储卷以及镜像名一一对应的关系。同理,可以获取目的命名空间的存储声明、存储卷以及镜像名的对应关系,这里不再赘述;
步骤3、将两边得到的结果分别导出为文件,将源命名空间的镜像导出后,以同存储声明为匹配条件,将导出的文件还原到目的命名空间对应的镜像中,步骤3中进行导出导入方法具体为:
步骤301、从源命名空间获取到的镜像名称列表;
步骤302、对导出的命名进行组装;
步骤303、等待当前的镜像文件导出完成;
步骤304、正式启动命令导出镜像文件;
优选以下代码实现该方法:
/* 导出镜像文件功能*/
func StartSync(resultsa[]model.PVCImage) bool {
// exportersnapshot to a file
for _, resulta:= range resultsa {
imageASnapshot := resulta.ImageName + config.ImageSuffix
// fmt.Printf("EXPORT PVC:%s IMAGE:%s SNAPSHOT:%s", resulta.PvcName,resulta.ImageName, imageASnapshot)
commander := exec.Command(
"rbd", "export-diff",resulta.ImageName+"@"+imageASnapshot,"/data/"+resulta.PvcName)
outinfo := bytes.Buffer{}
commander.Stdout =&outinfo
err := commander.Start()
if err != nil {
fmt.Println("++++++++", err.Error())
return false
}
if err = commander.Wait(); err != nil {
fmt.Println("---------", err.Error())
return false
} else {
fmt.Printf("export pvc:%s image:%s snapshot:%s success\n",resulta.PvcName, resulta.ImageName, imageASnapshot)
}
}
return true
}
其中, func表示语言关键字,表示声明一个方法,StartSync ()表示为此方法的名称,resultsa表示从源命名空间获取到的镜像名称列表,exec.Command表示对导出的命名进行组装,commander.Wait()表示等待当前的镜像文件导出完成,commander.Start()表示正式启动命令,在顺利执行了代码功能后即可返回true给调用端;
步骤4、将标记好的文件名和目的命令空间存储声明进行对比,找到目的空间的存储声明导出的镜像名,并进行还原操作,完成迁移,将源命名空间的镜像导出后,以同存储声明为匹配条件,将导出的文件还原到目的命名空间对应的镜像中,步骤4中进行导出导入方法具体为:
步骤401、从目的命名空间获取到的镜像名称列表;
步骤402、将源命名空间的存储声明与目的命名空间获取到的存储声明做匹配;
步骤403、对导出的命名进行组装;
步骤404、等待当前的镜像文件导出完成;
步骤405、正式启动命令,在顺利执行了代码功能后即可返回true给调用端;
优选以下代码实现该方法:
/* 导入镜像文件功能*/
func StartRestore(results,resultA []model.PVCImage) bool {
// restoredata from local backup file
for _, resultb:= range results {
//imageBSnapshot := resultb.ImageName + config.ImageSuffix
for _, resulta := range resultA {
if resultb.PvcName != resulta.PvcName {
continue
}
fmt.Printf("rbd import-diff /data/%s %s will beexcuted\n",resultb.PvcName, resultb.ImageName)
commander := exec.Command(
"rbd", "import-diff","/data/"+resultb.PvcName, resultb.ImageName)
outinfo := bytes.Buffer{}
commander.Stdout =&outinfo
err := commander.Start()
if err != nil {
fmt.Println(err.Error())
return false
}
if err = commander.Wait(); err != nil {
fmt.Println(err.Error())
return false
} else {
fmt.Printf("restore to image:%s frombackupfile:%s success\n",resultb.ImageName, resultb.PvcName)
}
}
}
return true
}
其中, func表示语言关键字,表示声明一个方法,StartRestore ()表示为此方法的名称,本方法返回值为true表示导出成功,resultsb表示从目的命名空间获取到的镜像名称列表,resultA表示从源使空间获取到的信息,因为要与源命名空间的存储声明相一致才可以还原到正确的镜像名,做到数据迁移,所以源命名空间里的信息也是必要信息,exec.Command表示对导出的命名进行组装,commander.Wait()表示等待当前的镜像文件导出完成commander.Start()表示正式启动命令,在顺利执行了代码功能后即可返回true给调用端。
需要说明的是,在进行步骤1前需首先运行启动相关的容器镜像:
运行容器
docker run -d -v/etc/ceph:/etc/ceph --name qycloud_migratorhub.qycloud.com.cn/dev/rbd-migrator-centos:7.7
进入容器运行命令启动同步
ceph-pvc-migrator start。
基于上述方法,使用该多版本加密存储的迁移方法,能够满足现今生产上常用数据加密迁移需求,且该多版本加密存储的迁移方法支持openshift\kubernetes及其它常用的容器编排平台而不需要修改代码,使得多版本加密存储的迁移更加高效、便捷。
实施例2
与实施例1的区别在于,作为本发明的一种优选实施方式,步骤3和步骤4都可以使用导出的文件进行导出和还原操作,进行导出和还原操作的方法具体为:
/* 导出文件 */
func StartSync(resultsa[]model.PVCImage) bool {
// exportersnapshot to a file
for _, resulta:= range resultsa {
imageASnapshot := resulta.ImageName + config.ImageSuffix
commander := exec.Command(
"rbd", "export-diff",resulta.ImageName+"@"+imageASnapshot,"/data/"+resulta.PvcName)
outinfo := bytes.Buffer{}
commander.Stdout =&outinfo
err := commander.Start()
if err != nil {
fmt.Println("++++++++", err.Error())
return false
}
if err = commander.Wait(); err != nil {
fmt.Println("---------", err.Error())
return false
} else {
fmt.Printf("export pvc:%s image:%s snapshot:%ssuccess\n",resulta.PvcName, resulta.ImageName, imageASnapshot)
}
}
return true
}
其中, func表示语言关键字,表示声明一个方法,StartSync()表示为此方法的名称, resultsa表示从源命名空间获取到的镜像名称列表,exec.Command表示对导出的命名进行组装, commander.Start()表示正式启动命令,commander.Wait()表示等待当前的镜像文件导出完成,在顺利执行了代码功能后即可返回true给调用端。
/* 导入镜像文件功能*/
func StartRestore(results,resultA []model.PVCImage) bool {
// restoredata from local backup file
for _, resultb:= range results {
//imageBSnapshot := resultb.ImageName + config.ImageSuffix
for _,resulta := range resultA {
if resultb.PvcName != resulta.PvcName {
continue
}
fmt.Printf("rbd import-diff /data/%s %s will beexcuted\n",resultb.PvcName, resultb.ImageName)
commander := exec.Command(
"rbd", "import-diff","/data/"+resultb.PvcName, resultb.ImageName)
outinfo := bytes.Buffer{}
commander.Stdout =&outinfo
err := commander.Start()
if err != nil {
fmt.Println(err.Error())
return false
}
if err = commander.Wait(); err != nil {
fmt.Println(err.Error())
return false
} else {
fmt.Printf("restore to image:%s frombackupfile:%s success\n",resultb.ImageName, resultb.PvcName)
}
}
}
return true
}
其中, func表示语言关键字,表示声明一个方法,StartRestore ()表示为此方法的名称,本方法返回值为true表示导出成功,resultsb表示从目的命名空间获取到的镜像名称列表,resultA表示从源使空间获取到的信息,因为要与源命名空间的存储声明相一致才可以还原到正确的镜像名,做到数据迁移,所以源命名空间里的信息也是必要信息,exec.Command表示对导出的命名进行组装,commander.Wait()表示等待当前的镜像文件导出完成commander.Start()表示正式启动命令,在顺利执行了代码功能后即可返回true给调用端。
上述说明,使本领域专业技术人员能够实现或使用本发明。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。
Claims (5)
1.一种多版本加密存储的迁移方法,其特征在于:包括以下步骤:
步骤1、在源命名空间里找到存储声明对应的存储卷及存储卷对应的镜像名,并存储;
步骤2、找到目的命名空间里存储声明对应的存储卷及存储卷对应的镜像名,并存储;
步骤3、将两边得到的结果分别导出为文件;
步骤4、将标记好的文件名和目的命令空间存储声明进行对比,找到目的空间的存储声明导出的镜像名,并进行还原操作,完成迁移。
2.根据权利要求1所述的一种多版本加密存储的迁移方法,其特征在于:所述步骤1包括,在源命名空间里,找到对应的存储卷及与存储卷对应的镜像名使用的对应链都是唯一值,具体步骤包括:
步骤101、获取命名空间里的存储声明函数;
步骤102、获取存储卷函数;
步骤103、获取镜像列表函数。
3.根据权利要求1所述的一种多版本加密存储的迁移方法,其特征在于:所述步骤2还包括,如不存在目的存储声明需要先创建,具体步骤包括:
步骤201、事先创建同名存储声明;
步骤202、组装存储声明对象详细信息;
步骤203、存储声明实际创建;
步骤204、获取目的命名空间的存储声明列表;
步骤205、获取新增的存储卷的列表;
步骤206、组装源命名空间的存储、存储卷、镜像名。
4.根据权利要求1所述的一种多版本加密存储的迁移方法,其特征在于:所述步骤3包括,将源命名空间的镜像导出后,以同存储声明为匹配条件,将导出的文件还原到目的命名空间对应的镜像中,步骤3中进行导出导入方法具体为:
步骤301、从源命名空间获取到的镜像名称列表;
步骤302、对导出的命名进行组装;
步骤303、等待当前的镜像文件导出完成;
步骤304、正式启动命令导出镜像文件。
5.根据权利要求4所述的一种多版本加密存储的迁移方法,其特征在于:所述步骤4包括将源命名空间的镜像导出后,以同存储声明为匹配条件,将导出的文件还原到目的命名空间对应的镜像中,步骤4中进行导出导入方法具体为:
步骤401、从目的命名空间获取到的镜像名称列表;
步骤402、将源命名空间的存储声明与目的命名空间获取到的存储声明做匹配;
步骤403、对导出的命名进行组装;
步骤404、等待当前的镜像文件导出完成;
步骤405、正式启动命令,在顺利执行了代码功能后即可返回true给调用端。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310420691.XA CN116166204B (zh) | 2023-04-19 | 2023-04-19 | 一种多版本加密存储的迁移方法 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310420691.XA CN116166204B (zh) | 2023-04-19 | 2023-04-19 | 一种多版本加密存储的迁移方法 |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116166204A true CN116166204A (zh) | 2023-05-26 |
CN116166204B CN116166204B (zh) | 2023-07-07 |
Family
ID=86411729
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310420691.XA Active CN116166204B (zh) | 2023-04-19 | 2023-04-19 | 一种多版本加密存储的迁移方法 |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116166204B (zh) |
Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060161746A1 (en) * | 2004-04-23 | 2006-07-20 | Wong Chi M | Directory and file mirroring for migration, snapshot, and replication |
US20140330787A1 (en) * | 2013-05-01 | 2014-11-06 | Netapp, Inc. | Namespace mirroring in an expandable storage volume |
CN107526626A (zh) * | 2017-08-24 | 2017-12-29 | 武汉大学 | 一种基于CRIU的Docker容器热迁移方法及系统 |
CN112035062A (zh) * | 2020-08-19 | 2020-12-04 | 星环信息科技(上海)有限公司 | 云计算的本地存储的迁移方法、计算机设备及存储介质 |
CN112445570A (zh) * | 2019-09-03 | 2021-03-05 | 中移(苏州)软件技术有限公司 | 一种云平台资源迁移方法及其装置、存储介质 |
CN114090179A (zh) * | 2021-11-23 | 2022-02-25 | 北京金山云网络技术有限公司 | 有状态服务的迁移方法、装置及服务器 |
CN114356504A (zh) * | 2022-01-04 | 2022-04-15 | 北京金山云网络技术有限公司 | 集群中数据迁移方法、装置、电子设备和存储介质 |
CN114706919A (zh) * | 2022-06-06 | 2022-07-05 | 南京安元科技有限公司 | 一种布式存储数据存储兼容方法及系统 |
CN115146286A (zh) * | 2021-03-30 | 2022-10-04 | 中移(苏州)软件技术有限公司 | 加密系统卷的创建方法、装置、电子设备和存储介质 |
CN115617744A (zh) * | 2022-09-30 | 2023-01-17 | 超聚变数字技术有限公司 | 镜像仓库访问方法、系统及设备 |
-
2023
- 2023-04-19 CN CN202310420691.XA patent/CN116166204B/zh active Active
Patent Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060161746A1 (en) * | 2004-04-23 | 2006-07-20 | Wong Chi M | Directory and file mirroring for migration, snapshot, and replication |
US20140330787A1 (en) * | 2013-05-01 | 2014-11-06 | Netapp, Inc. | Namespace mirroring in an expandable storage volume |
CN107526626A (zh) * | 2017-08-24 | 2017-12-29 | 武汉大学 | 一种基于CRIU的Docker容器热迁移方法及系统 |
CN112445570A (zh) * | 2019-09-03 | 2021-03-05 | 中移(苏州)软件技术有限公司 | 一种云平台资源迁移方法及其装置、存储介质 |
CN112035062A (zh) * | 2020-08-19 | 2020-12-04 | 星环信息科技(上海)有限公司 | 云计算的本地存储的迁移方法、计算机设备及存储介质 |
CN115146286A (zh) * | 2021-03-30 | 2022-10-04 | 中移(苏州)软件技术有限公司 | 加密系统卷的创建方法、装置、电子设备和存储介质 |
CN114090179A (zh) * | 2021-11-23 | 2022-02-25 | 北京金山云网络技术有限公司 | 有状态服务的迁移方法、装置及服务器 |
CN114356504A (zh) * | 2022-01-04 | 2022-04-15 | 北京金山云网络技术有限公司 | 集群中数据迁移方法、装置、电子设备和存储介质 |
CN114706919A (zh) * | 2022-06-06 | 2022-07-05 | 南京安元科技有限公司 | 一种布式存储数据存储兼容方法及系统 |
CN115617744A (zh) * | 2022-09-30 | 2023-01-17 | 超聚变数字技术有限公司 | 镜像仓库访问方法、系统及设备 |
Also Published As
Publication number | Publication date |
---|---|
CN116166204B (zh) | 2023-07-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20220043830A1 (en) | Versioned hierarchical data structures in a distributed data store | |
US9069800B2 (en) | Parallel database backup and restore | |
US11016932B2 (en) | Systems, methods, and apparatuses for simplifying filesystem operations utilizing a key-value storage system | |
US11550763B2 (en) | Versioning schemas for hierarchical data structures | |
US9792306B1 (en) | Data transfer between dissimilar deduplication systems | |
US7257257B2 (en) | Method and apparatus for differential, bandwidth-efficient and storage-efficient backups | |
CN111324610A (zh) | 一种数据同步的方法及装置 | |
US8832492B1 (en) | Systems and methods for managing applications | |
US10248736B1 (en) | Data loader and mapper tool | |
CN111736762B (zh) | 数据存储网络的同步更新方法、装置、设备及存储介质 | |
US11741144B2 (en) | Direct storage loading for adding data to a database | |
KR102392880B1 (ko) | 계층화 문서를 관리하는 방법 및 이를 이용한 장치 | |
CN116166204B (zh) | 一种多版本加密存储的迁移方法 | |
CN115586872A (zh) | 一种容器镜像管理方法、装置、设备及存储介质 | |
CN117112072B (zh) | 一种跨平台虚拟机驱动替换方法、系统及存储介质 | |
US11010361B1 (en) | Executing code associated with objects in a hierarchial data structure | |
CN109002343B (zh) | 一种实现虚拟机批量创建的方法及装置 | |
CN113553329B (zh) | 数据集成系统和方法 | |
CN113282551B (zh) | 数据处理方法、系统及设备 | |
US11656950B2 (en) | Method, electronic device and computer program product for storage management | |
WO2024108994A1 (zh) | 一种数据库对象的验证方法及相关设备 | |
CN110419026B (zh) | 存储器内搜索技术 | |
Zhou et al. | Multi-agent Based Container Microservices for Remote File Storage System | |
CN115481198A (zh) | 数据表同步方法、装置、计算机设备、存储介质 | |
CN114168532A (zh) | 迁移脚本构建方法、装置、计算机设备及可读存储介质 |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |