RMAN中通过时间点不完全恢复报ORA-01841的解决办法

环境

  • 操作系统 oracle linux 6.5
  • 数据库 oracle 11.2.0.4

执行脚本

run {
allocate channel c1 type disk;
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss";
set until time='2017-10-8 00:00:00';
restore database;
recover database;
}

错误及分析

执行脚本后报错

RMAN-03002: failure of recover command at ……..
RMAN-11003: failure during parse/execution of SQL …….
ORA-01841: (full) year must be between -4713 and +9999, and not be 0

此处为貌似是我们的语句写错了,其实是oracle的bug
貌似有两个问题

  1. 需设置NLS_LANG环境变量

    在执行rman命令前先执行export NLS_LANG=AMERICAN_AMERICA.AL32UTF8

  2. 此处不能将restore database和recover database放在一个run块里,需在单独的run块中完成

run {
allocate channel c1 type disk;
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss";
set until time='2017-10-8 00:00:00';
restore database;
}
run {
allocate channel c1 type disk;
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss";
set until time='2017-10-8 00:00:00';
recover database;
}
发布了58 篇原创文章 · 获赞 3 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/lldustc/article/details/78348140