dm8 备份与恢复

dm8 备份与恢复

sql 复制代码
基础环境
操作系统:Red Hat Enterprise Linux Server release 7.9 (Maipo)
数据库版本:DM Database Server 64 V8
架构:单实例

1 设置bak_path路径

sql 复制代码
--创建备份文件存放目录
su - dmdba
mkdir -p /dm8/backup

--修改dm.ini 文件
BAK_PATH                        = /dm8/backup                      #backup file path


[dmdba@test1 dm8]$ disql sysdba/Dameng123@localhost:5237

服务器[localhost:5237]:处于普通打开状态
登录使用时间 : 3.937(ms)
disql V8
SQL> select name,value,sys_value,file_value from v$parameter where name='BAK_PATH';

行号     NAME     VALUE              SYS_VALUE          FILE_VALUE 
---------- -------- ------------------ ------------------ -----------
1          BAK_PATH /dm8/data/PROD/bak /dm8/data/PROD/bak /dm8/backup

已用时间: 4.748(毫秒). 执行号:1000.
SQL> exit

--重启实例
[root@test1 arch]# systemctl restart DmServiceTEST.service 

[dmdba@test1 dm8]$ disql sysdba/Dameng123@localhost:5237

服务器[localhost:5237]:处于普通打开状态
登录使用时间 : 3.611(ms)
disql V8
SQL> select name,value,sys_value,file_value from v$parameter where name='BAK_PATH';

行号     NAME     VALUE       SYS_VALUE   FILE_VALUE 
---------- -------- ----------- ----------- -----------
1          BAK_PATH /dm8/backup /dm8/backup /dm8/backup

已用时间: 5.328(毫秒). 执行号:500.
SQL>

2 全库备份

2.1 文本方式

sql 复制代码
[dmdba@test1 ~]$ disql sysdba/Dameng123@localhost:5237

服务器[localhost:5237]:处于普通打开状态
登录使用时间 : 3.724(ms)
disql V8
SQL> backup database full to "20230729_bak" backupset '20230729_bak';
操作已执行
已用时间: 00:00:03.084. 执行号:600.
SQL> select backup_name,backup_path from v$backupset;

行号     BACKUP_NAME  BACKUP_PATH             
---------- ------------ ------------------------
1          20230729_bak /dm8/backup/20230729_bak

已用时间: 16.554(毫秒). 执行号:601.

2.2 图形界面

sql 复制代码
[dmdba@test1 ~]$ manager

3 数据文件恢复

3.1 模拟报错

sql 复制代码
模拟报错
2023-07-28 19:04:38.204 [INFO] database P0000074443 T0000000000000074443  hlog_sys_destroy, n_logs[1], adjust_sta[0]
2023-07-28 19:04:38.206 [INFO] database P0000074443 T0000000000000074443  file lsn: 43705
2023-07-28 19:04:38.206 [INFO] database P0000074443 T0000000000000074443  ndct_load_ex_idcls_map load 0 ex_idcls.
2023-07-28 19:04:38.207 [INFO] database P0000074443 T0000000000000074443  ndct db load finished
2023-07-28 19:04:38.211 [ERROR] database P0000074443 T0000000000000074443  os_file_open_low_real error! desc: No such file or directory, path: /dm8/data/PROD/TBS01.dbf, code: 2
2023-07-28 19:04:38.211 [ERROR] database P0000074443 T0000000000000074443  os_file_open_low_real error! desc: No such file or directory, path: /dm8/data/PROD/TBS01.dbf, code: 2
2023-07-28 19:04:38.211 [INFO] database P0000074443 T0000000000000074443  ndct second level fill fast pool finished
2023-07-28 19:04:38.211 [INFO] database P0000074443 T0000000000000074443  ndct third level fill fast pool finished
2023-07-28 19:04:38.227 [INFO] database P0000074443 T0000000000000074443  ndct second level fill fast pool finished
2023-07-28 19:04:38.227 [INFO] database P0000074443 T0000000000000074443  ndct third level fill fast pool finished
2023-07-28 19:04:38.227 [INFO] database P0000074443 T0000000000000074443  ndct fill fast pool finished
2023-07-28 19:04:38.228 [ERROR] database P0000074443 T0000000000000074443  os_file_open_low_real error! desc: No such file or directory, path: /dm8/data/PROD/TBS01.dbf, code: 2
2023-07-28 19:04:38.228 [ERROR] database P0000074443 T0000000000000074443  os_file_open_low_real error! desc: No such file or directory, path: /dm8/data/PROD/TBS01.dbf, code: 2
2023-07-28 19:04:38.229 [INFO] database P0000074443 T0000000000000074443  sess4 aux tsksys init success
2023-07-28 19:04:38.238 [WARNING] database P0000074443 T0000000000000074443  fail to load libgssapi_krb5.so, libgssapi_krb5.so: cannot open shared object file: No such file or directory
2023-07-28 19:04:38.247 [INFO] database P0000074443 T0000000000000074443  nsvr_startup end.
2023-07-28 19:04:38.349 [INFO] database P0000074443 T0000000000000074443  aud sys init success.
2023-07-28 19:04:38.349 [INFO] database P0000074443 T0000000000000074443  aud rt sys init success.
2023-07-28 19:04:38.350 [INFO] database P0000074443 T0000000000000074443  systables desc init success.
2023-07-28 19:04:38.350 [INFO] database P0000074443 T0000000000000074443  ndct_db_load_info success.
2023-07-28 19:04:38.351 [INFO] database P0000074443 T0000000000000074516  nsvr_lsnr_thread successfully created.
2023-07-28 19:04:38.351 [INFO] database P0000074443 T0000000000000074443  backup control file /dm8/data/PROD/dm.ctl to file /dm8/data/PROD/dm_20230728190438_351399.ctl
2023-07-28 19:04:38.353 [INFO] database P0000074443 T0000000000000074443  backup control file /dm8/data/PROD/dm.ctl to file /dm8/data/PROD/ctl_bak/dm_20230728190438_352275.ctl succeed
2023-07-28 19:04:38.353 [INFO] database P0000074443 T0000000000000074443  local instance name is TEST, mode is NORMAL, status is MOUNT.
2023-07-28 19:04:38.353 [INFO] database P0000074443 T0000000000000074443  SYSTEM IS READY.
2023-07-28 19:04:38.353 [INFO] database P0000074443 T0000000000000074443  set g_dw_stat from UNDEFINED to NONE success, g_dw_recover_stop is 0
2023-07-28 19:04:39.351 [INFO] database P0000074443 T0000000000000074479  iid_set_new_next_trxid_if_necessary, next_trxid: 11035

3.2 恢复

3.2.1 文本方式
sql 复制代码
--关闭实例
[root@test1 arch]# systemctl stop DmServiceTEST.service 

--恢复
[dmdba@test1 PROD]$ dmrman
dmrman V8
RMAN> check backupset '/dm8/backup/20230729_bak';
check backupset '/dm8/backup/20230729_bak';
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]                                 
check backupset successfully.
time used: 136.189(ms)
RMAN> RESTORE DATABASE '/dm8/data/PROD/dm.ini' tablespace "TBS" FROM BACKUPSET '/dm8/backup/20230729_bak' DEVICE TYPE disk;
RESTORE DATABASE '/dm8/data/PROD/dm.ini' tablespace "TBS" FROM BACKUPSET '/dm8/backup/20230729_bak' DEVICE TYPE disk;
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
begin redo pwr log collect, last ckpt lsn: 43705 ...
redo pwr log collect finished
EP[0]'s cur_lsn[43705], file_lsn[43705]
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00]                                 
restore successfully.
time used: 00:00:02.418
RMAN> RECOVER DATABASE '/dm8/data/PROD/dm.ini' TABLESPACE TBS WITH ARCHIVEDIR '/dm8/arch';
RECOVER DATABASE '/dm8/data/PROD/dm.ini' TABLESPACE TBS WITH ARCHIVEDIR '/dm8/arch';
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
begin redo pwr log collect, last ckpt lsn: 43705 ...
redo pwr log collect finished
EP[0]'s cur_lsn[43705], file_lsn[43705]
[Percent:100.00%][Speed:0.00PKG/s][Cost:00:00:00][Remaining:00:00:00]                               
recover successfully.
time used: 428.573(ms)

--开启实例
[root@test1 arch]# systemctl start DmServiceTEST.service 

[dmdba@test1 PROD]$ disql sysdba/Dameng123@localhost:5237

服务器[localhost:5237]:处于普通打开状态
登录使用时间 : 3.691(ms)
disql V8
SQL> select status$ from v$instance;

行号     STATUS$
---------- -------
1          OPEN

已用时间: 1.736(毫秒). 执行号:500.
3.2.2 图形界面
sql 复制代码
[dmdba@test1 ~]$ console


sql 复制代码
[dmdba@test1 PROD]$ DmServiceTEST start
Starting DmServiceTEST:                                    [ OK ]
[dmdba@test1 PROD]$ disql sysdba/Dameng123@localhost:5237

服务器[localhost:5237]:处于普通打开状态
登录使用时间 : 3.502(ms)
disql V8
SQL> select status$ from v$instance;

行号     STATUS$
---------- -------
1          OPEN

已用时间: 9.941(毫秒). 执行号:500.
SQL> select file_name from dba_data_files;

行号     FILE_NAME                
---------- -------------------------
1          /dm8/data/PROD/SYSTEM.DBF
2          /dm8/data/PROD/TBS02.dbf
3          /dm8/data/PROD/TBS01.dbf
4          /dm8/data/PROD/MAIN.DBF
5          /dm8/data/PROD/TEMP.DBF
6          /dm8/data/PROD/ROLL.DBF

6 rows got

已用时间: 18.857(毫秒). 执行号:501.
SQL>

4 数据库全库恢复

4.1 模拟报错

sql 复制代码
2023-07-31 05:34:41.856 [INFO] database P0000026050 T0000000000000026050  INI parameter DPC_2PC changed, the original value 1, new value 0
2023-07-31 05:34:41.863 [INFO] database P0000026050 T0000000000000026050  version info: develop
2023-07-31 05:34:41.864 [INFO] database P0000026050 T0000000000000026050  os_sema2_create_low, create and inc sema success, key:151595369, sem_id:65539, sem_value:1!
2023-07-31 05:34:41.864 [ERROR] database P0000026050 T0000000000000026050  /dm8/data/PROD/SYSTEM.DBF not exist

[dmdba@test1 PROD]$ DmServiceTEST start
Starting DmServiceTEST:                                    [ FAILED ]

4.2 恢复

4.2.1 文本方式
sql 复制代码
[dmdba@test1 dm8]$ dmrman
dmrman V8
RMAN> check backupset '/dm8/backup/20230801_bak';
check backupset '/dm8/backup/20230801_bak';
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]                                 
check backupset successfully.
time used: 138.700(ms)
RMAN> RESTORE DATABASE '/dm8/data/PROD/dm.ini' FROM BACKUPSET '/dm8/backup/20230801_bak' DEVICE TYPE disk;
RESTORE DATABASE '/dm8/data/PROD/dm.ini' FROM BACKUPSET '/dm8/backup/20230801_bak' DEVICE TYPE disk;
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.403
RMAN> RECOVER DATABASE '/dm8/data/PROD/dm.ini' WITH ARCHIVEDIR '/dm8/arch';
RECOVER DATABASE '/dm8/data/PROD/dm.ini' WITH ARCHIVEDIR '/dm8/arch';
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[44962], file_lsn[44962]
[Percent:100.00%][Speed:0.00PKG/s][Cost:00:00:00][Remaining:00:00:00]                               
recover successfully!
time used: 410.957(ms)
RMAN> recover database '/dm8/data/PROD/dm.ini' update db_magic;
recover database '/dm8/data/PROD/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[46614], file_lsn[46614]
recover successfully!
time used: 00:00:01.001
RMAN>


确认
[dmdba@test1 PROD]$ DmServiceTEST start
Starting DmServiceTEST:                                    [ OK ]
[dmdba@test1 PROD]$ disql sysdba/Dameng123@localhost:5237

服务器[localhost:5237]:处于普通打开状态
登录使用时间 : 3.070(ms)
disql V8
SQL> select status$ from v$instance;

行号     STATUS$
---------- -------
1          OPEN

已用时间: 1.994(毫秒). 执行号:500.
SQL> select file_name from dba_data_files;

行号     FILE_NAME                
---------- -------------------------
1          /dm8/data/PROD/SYSTEM.DBF
2          /dm8/data/PROD/TBS02.dbf
3          /dm8/data/PROD/TBS01.dbf
4          /dm8/data/PROD/MAIN.DBF
5          /dm8/data/PROD/TEMP.DBF
6          /dm8/data/PROD/ROLL.DBF

6 rows got

已用时间: 7.471(毫秒). 执行号:501.
SQL>
4.2.2 图形界面
sql 复制代码
[dmdba@test1 ~]$ console

sql 复制代码
[dmdba@test1 PROD]$ DmServiceTEST start
Starting DmServiceTEST:                                    [ OK ]
[dmdba@test1 PROD]$ disql sysdba/Dameng123@localhost:5237

服务器[localhost:5237]:处于普通打开状态
登录使用时间 : 3.766(ms)
disql V8
SQL> select status$ from v$instance;

行号     STATUS$
---------- -------
1          OPEN

已用时间: 2.323(毫秒). 执行号:500.
SQL> select file_name from dba_data_files;

行号     FILE_NAME                
---------- -------------------------
1          /dm8/data/PROD/SYSTEM.DBF
2          /dm8/data/PROD/TBS02.dbf
3          /dm8/data/PROD/TBS01.dbf
4          /dm8/data/PROD/MAIN.DBF
5          /dm8/data/PROD/TEMP.DBF
6          /dm8/data/PROD/ROLL.DBF

6 rows got

已用时间: 9.022(毫秒). 执行号:501.
SQL>

5 归档日志备份与恢复

5.1 归档日志备份

5.1.1 文本方式
sql 复制代码
[dmdba@test1 backup]$ disql sysdba/Dameng123@localhost:5239

Server[localhost:5239]:mode is normal, state is open
login used time : 2.420(ms)
disql V8
SQL> backup archivelog all not backed up to "ARCH_20230806" backupset 'ARCH_20230806';
executed successfully
used time: 00:00:03.536. Execute id is 900.
SQL> select backup_name,backup_path,object_name from v$backupset;

LINEID     BACKUP_NAME   BACKUP_PATH           OBJECT_NAME
---------- ------------- --------------------- -----------
1          DB_BAK        /backup/DB_BAK        PROD
2          ARCH_20230806 /backup/ARCH_20230806 ARCHIVE

used time: 17.186(ms). Execute id is 901.
SQL>
5.1.2 图形界面



5.2 恢复

5.2.1 文本方式
sql 复制代码
[dmdba@test1 arch]$ dmrman
dmrman V8
RMAN> restore archive log from backupset '/backup/ARCH_20230806' TO  archivedir '/dm/arch' overwrite 2;
restore archive log from backupset '/backup/ARCH_20230806' TO archivedir '/dm/arch' overwrite 2;
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]                                 
restore successfully.
time used: 150.999(ms)
5.2.2 图形界面

[dmdba@test1 tool]$





谨记:心存敬畏,行有所止。

相关推荐
荒Huang24 分钟前
Linux挖矿病毒(kswapd0进程使cpu爆满)
linux·运维·服务器
海阔天空_201334 分钟前
Python pyautogui库:自动化操作的强大工具
运维·开发语言·python·青少年编程·自动化
桥田智能36 分钟前
气爪在自动化装配线中是如何应用的?
运维·自动化
MonkeyKing_sunyuhua39 分钟前
ubuntu22.04 docker-compose安装postgresql数据库
数据库·docker·postgresql
天郁青39 分钟前
数据库交互的本地项目:后台管理系统
数据库·交互
马剑威(威哥爱编程)44 分钟前
MongoDB面试专题33道解析
数据库·mongodb·面试
小光学长1 小时前
基于vue框架的的流浪宠物救助系统25128(程序+源码+数据库+调试部署+开发环境)系统界面在最后面。
数据库·vue.js·宠物
零炻大礼包2 小时前
【SQL server】数据库远程连接配置
数据库
zmgst2 小时前
canal1.1.7使用canal-adapter进行mysql同步数据
java·数据库·mysql
随心............2 小时前
python操作MySQL以及SQL综合案例
数据库·mysql