达梦 DM8 数据库异机数据迁移测试
一、源库备份
源库DMOA,主机名:dm3 目标库 DMOA 主机名:db
在DMTEST模式里创建了T_EMP01、T_EMP02、T_EMP03、T_TESTPID、TEST等各类表,各类表包含约束主键等信息用于迁移测试。
通过DM8 manager管理工具实现对数据库全库备份,前提记得一定要开归档。
将全库备份文件及归档拷贝到目标db节点。
[dmdba@dm3 bak]$ tar cvf DBFULL.tar DB_DMOA_FULL_2022_09_27_08_27_24/
DB_DMOA_FULL_2022_09_27_08_27_24/
DB_DMOA_FULL_2022_09_27_08_27_24/DB_DMOA_FULL_2022_09_27_08_27_24.bak
DB_DMOA_FULL_2022_09_27_08_27_24/DB_DMOA_FULL_2022_09_27_08_27_24_1.bak
DB_DMOA_FULL_2022_09_27_08_27_24/DB_DMOA_FULL_2022_09_27_08_27_24.meta
[dmdba@dm3 dmoaarch]$ du -sh *
1.8M ARCHIVE_LOCAL1_0x20A1D2C4_EP0_2022-09-26_17-00-11.log
100M ARCHIVE_LOCAL1_0x20A1D2C4_EP0_2022-09-26_19-36-59.log
102M arch.tar
二、目标库创建
2.1、创建目标库与源库保持一致
[dmdba@db bin]$ ./dminit path=/dm8/data DB_NAME=DMOA instance_name=DMOASVR port_num=5238 LENGTH_IN_CHAR=y SYSDBA_PWD=Dameng123
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2023-07-20
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
log file path: /dm8/data/DMOA/DMOA01.log
log file path: /dm8/data/DMOA/DMOA02.log
write to dir [/dm8/data/DMOA].
create dm database success. 2022-09-27 08:37:30
[dmdba@db bin]$
2.2、新库注册服务
[root@db root]# ./dm_service_installer.sh -t dmserver -p DMOASVR -dm_ini /dm8/data/DMOA/dm.ini
Created symlink /etc/systemd/system/multi-user.target.wants/DmServiceDMOASVR.service → /usr/lib/systemd/system/DmServiceDMOASVR.service.
创建服务(DmServiceDMOASVR)完成
[root@db root]#
三、数据迁移恢复
执行恢复三部曲,restore、recover、update db_magic
RMAN> restore database '/dm8/data/DMOA/dm.ini' from backupset '/dm8/data/DMOA/bak/DB_DMOA_FULL_2022_09_27_08_27_24';
restore database '/dm8/data/DMOA/dm.ini' from backupset '/dm8/data/DMOA/bak/DB_DMOA_FULL_2022_09_27_08_27_24';
file dm.key not found, use default license!
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00]
restore successfully.
time used: 00:00:02.609
RMAN>
RMAN> recover database '/dm8/data/DMOA/dm.ini' with archivedir '/dm8/data/DMOA/dmoaarch';
recover database '/dm8/data/DMOA/dm.ini' with archivedir '/dm8/data/DMOA/dmoaarch';
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[132227], file_lsn[132227]
[Percent:100.00%][Speed:0.00PKG/s][Cost:00:00:00][Remaining:00:00:00]
recover successfully!
time used: 496.213(ms)
RMAN>
RMAN> recover database '/dm8/data/DMOA/dm.ini' update db_magic;
recover database '/dm8/data/DMOA/dm.ini' update db_magic;
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[132741], file_lsn[132741]
recover successfully!
time used: 00:00:01.062
RMAN>
启动数据库
[dmdba@db ~]$ DmServiceDMOASVR start
Starting DmServiceDMOASVR: [ OK ]
[dmdba@db ~]$
在目标库端通过manager工具查验数据完整性,迁移成功。