由于本人喜欢DM迁移DM使用备份还原的方式进行全库迁移,所遇到的问题进行分析。
问题描述:使用脱机备份B数据库,在A数据上进行还原。还原后登录数据库提示用户名/密码错误。
达梦数据库可通过联机备份(热)或脱机备份(冷)的备份集进行全库还原。通过全库还原有两种方法:一种是备份数据库实例物理文件方法进行恢复,一种是通过达梦自带的脱机还原工具(dmrman工具和console工具)进行备份恢复。
数据库 | 操作系统版本 | 数据库安装包版本 | IP地址 |
---|---|---|---|
数据库A | NeoKylin Liux General Server 6.0 (Dhaulagiri) | dm8_setup_rh6_64_ent_8.1 | 192.168.1.20 |
数据库B | CentOS Linux release 7.7.1908 (Core) | dm8_setup_rh7_64_ent_8.1 | 192.168.1.60 |
1、停止数据库服务
[dmdba@localhost bin]$ cd /home/dmdba/dmdbms/bin
[dmdba@localhost bin]$ ./DmServiceDMSERVER stop
Stopping DmServiceDMSERVER: [ OK ]
[dmdba@localhost bin]$
2、通过dmrman工具备份数据库备份集在/home/dmdba/dmdbms/data/DAMENG/bak路径下
[dmdba@localhost bin]$ ./dmrman
dmrman V8
RMAN> BACKUP DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini'FULL;
BACKUP DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini' FULL;
file dm.key not found, use default license!
Database mode = 0, oguid = 0
EP[0]'s cur_lsn[46015]
BACKUP DATABASE [DAMENG],execute......
CMD CHECK LSN......
BACKUP DATABASE [DAMENG],collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
total 6 packages processed...
DBF BACKUP MAIN......
BACKUPSET [/home/dmdba/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20200909_120148_000394] END, CODE [0]......
META GENERATING......
total 10 packages processed...
total 10 packages processed...
total 10 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 00:00:01.187
RMAN>
3、通过SCP命令发送备份集到B服务器上
[dmdba@localhost ~]$ cd dmdbms/data/DAMENG/bak
[dmdba@localhost bak]$ ll
总用量 4
drwxr-xr-x 2 dmdba dminstall 4096 9月 9 12:28 DB_DAMENG_FULL_20200909_122802_975951
[dmdba@localhost bak]$ scp -r DB_DAMENG_FULL_20200909_122802_975951/ [email protected]:/home/dmdba/dmdbms/data/DAMENG/bak
The authenticity of host '192.168.1.21 (192.168.1.21)' can't be established.
RSA key fingerprint is 7d:96:94:45:6a:61:a4:be:5f:fb:83:f9:01:a7:61:89.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.21' (RSA) to the list of known hosts.
[email protected]'s password:
DB_DAMENG_FULL_20200909_122802_975951.meta 100% 73KB 72.5KB/s 00:00
DB_DAMENG_FULL_20200909_122802_975951.bak 100% 5990KB 5.9MB/s 00:00
[dmdba@localhost bak]$
4、登录B服务进行查看备份集并进行还原。
[C:\~]$ ssh 192.168.1.60
Connecting to 192.168.1.60:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Wed Sep 9 10:26:34 2020 from 192.168.1.163
[dmdba@localhost ~]$
[dmdba@localhost ~]$
[dmdba@localhost ~]$
[dmdba@localhost ~]$ cd /home/dmdba/dmdbms/data/DAMENG/bak
[dmdba@localhost bak]$ ll
总用量 4
drwxr-xr-x 2 dmdba dminstall 4096 9月 9 12:02 DB_DAMENG_FULL_20200909_122802_975951
[dmdba@localhost bak]$
[dmdba@localhost bin]$ cd /etc/init.d/
[dmdba@localhost init.d]$ ./DmServiceDMSERVER stop
Stopping DmServiceDMSERVER: [ OK ]
[dmdba@localhost init.d]$ cd /home/dmdba/dmdbms/bin
[dmdba@localhost bin]$ ./dmrman
dmrman V8
RMAN> RESTORE DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini' FROM BACKUPSET'/home/dmdba/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20200909_122802_975951';
RESTORE DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini' FROM BACKUPSET '/home/dmdba/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20200909_122802_975951';
file dm.key not found, use default license!
RESTORE DATABASE CHECK......
RESTORE DATABASE,dbf collect......
RESTORE DATABASE,dbf refresh ......
RESTORE BACKUPSET [/home/dmdba/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20200909_122802_975951] START......
total 3 packages processed...
total 7 packages processed...
RESTORE DATABASE,UPDATE ctl file......
RESTORE DATABASE,REBUILD key file......
RESTORE DATABASE,CHECK db info......
RESTORE DATABASE,UPDATE db info......
total 7 packages processed...
total 7 packages processed!
CMD END.CODE:[0]
restore successfully.
time used: 284.771(ms)
5、对数据库进行恢复
RMAN> RECOVER DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini' FROM BACKUPSET'/home/dmdba/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20200909_122802_975951';
RECOVER DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini' FROM BACKUPSET '/home/dmdba/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20200909_122802_975951';
Database mode = 0, oguid = 0
EP[0]'s cur_lsn[34896]
RESTORE RLOG CHECK......
CMD END.CODE:[603],DESC:[备份集[/home/dmdba/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20200909_122802_975951]备份过程中未产生日志]
备份集[/home/dmdba/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20200909_122802_975951]备份过程中未产生日志
recover successfully!
time used: 233.906(ms)
6、更新DB_MAGIC值
RMAN> RECOVER DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini' UPDATE DB_MAGIC;
RECOVER DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini' UPDATE DB_MAGIC;
Database mode = 0, oguid = 0
EP[0]'s cur_lsn[34896]
EP[0]'s apply_lsn[34896] >= end_lsn[34896]
recover successfully!
time used: 990.579(ms)
RMAN>
7、启动达梦数据库数据库实例服务
[dmdba@localhost bin]$ ./DmServiceDMSERVER start
Starting DmServiceDMSERVER: [ FAILED ]
file dm.key not found, use default license!
version info: develop
Use normal os_malloc instead of HugeTLB
Use normal os_malloc instead of HugeTLB
DM Database Server x64 V8 1-1-45-19.11.21-116030-ENT startup...
Database mode = 0, oguid = 0
License will expire on 2020-11-21
file lsn: 34896
ndct db load finished
ndct fill fast pool finished
iid page's trxid[3006]
NEXT TRX ID = 3007
pseg_collect_items, collect 0 active_trxs, 0 cmt_trxs, 0 pre_cmt_trxs, 0 active_pages, 0 cmt_pages, 0 pre_cmt_pages
pseg_process_collect_items end, 0 active trx, 0 active pages, 0 committed trx, 0 committed pages
total 0 active crash trx, pseg_crash_trx_rollback begin ...
pseg_crash_trx_rollback end
purg2_crash_cmt_trx end, total 0 page purged
set EP[0]'s pseg state to inactive
pseg recv finished
nsvr_startup end.
aud sys init success.
aud rt sys init success.
systables desc init success.
ndct_db_load_info success.
nsvr_process_before_open begin.
Server DM7_DCT_VERSION mismatch, version of data is 7, server version is 5.
Server DM8_DCT_VERSION mismatch, version of data is 18, server version is 16.
Please use the correct version of server or set the CHECK_SVR_VERSION=0 in dm.ini
[dmdba@localhost bin]$
发现数据库服务无法启动。提示服务器版本不对,需要修改CHECK_SVR_VERSION=0
vi /home/dmdba/dmdbms/data/DAMENG/dm.ini
CHECK_SVR_VERSION = 0 #Whether to check server version
再去启动数据库实例服务
[dmdba@localhost bin]$ ./DmServiceDMSERVER start
Starting DmServiceDMSERVER: [ OK ]
[dmdba@localhost bin]$
发现服务启动成功。现在开始登录数据库看是否正常。
[dmdba@localhost bin]$ ./disql
disql V8
用户名:
密码:
[-2501]:用户名或密码错误.
用户名:
本地登录,数据库账号密码错误。经过一些列的检查,发现两个数据库的小版本不对。
发现192.168.1.60使用的达梦数据库版本是:dm8_setup_rh7_64_ent_8.1.1.45_20191121.iso
发现192.168.1.21使用的达梦数据库版本是:dm8_setup_rh6_64_ent_8.1.1.88_20200629.iso
这次把备份集拷贝到本地windows数据库上进行恢复。本地数据版本是:dm8_setup_win64_ent_8.1.1.88_20200708.iso
windows使用dmrman工具最好使用管理员运行。
启动实例服务,查看数据库是否正常。
数据库正常。
总结:如果使用备份还原方式进行迁移库的话,最好使用相同版本,小版本必须要一样。
192.168.1.60使用的达梦数据库版本是:dm8_setup_rh7_64_ent_8.1.1.45_20191121.iso
192.168.1.21使用的达梦数据库版本是:dm8_setup_rh6_64_ent_8.1.1.88_20200629.iso
192.168.1.163使用的达梦数据库版本是:dm8_setup_win64_ent_8.1.1.88_20200708.iso