首页 > 其他分享 >rman异机恢复(11G单机)

rman异机恢复(11G单机)

时间:2023-11-27 18:15:27浏览次数:37  
标签:11G 27 23 app oracle NOV rman 异机 u01

环境:
OS:Centos6.9
DB:11.2.0.4
主库SID:slnngka
备库SID:slnngkb

 

1.异地机器安装相同版本的数据库软件
安装步骤省略,注意只安装软件和启动监听器(没有监听任何服务器)
确保监听器已经启动

 

[oracle@slnngkb rmanbak]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 27-NOV-2023 15:10:25

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=slnngkb)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                27-NOV-2023 09:25:57
Uptime                    0 days 5 hr. 44 min. 28 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/slnngkb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slnngkb)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

 

2.异地机器创建相应的目录
su - oracle
mkdir -p $ORACLE_BASE/oradata/slnngkb/
mkdir -p $ORACLE_BASE/admin/slnngkb/adump
mkdir -p $ORACLE_BASE/admin/slnngkb/dpdump
mkdir -p $ORACLE_BASE/fast_recovery_area/slnngkb

 

3.异地服务器准备参数文件
可以从主库拷贝进行相应修改
SQL>create pfile='/tmp/master_pfile.ora' from spfile;
拷贝到异地机器的dbs目录
scp /tmp/master_pfile.ora [email protected]:/u01/app/oracle/product/11.2.0.4/db_1/dbs/


从库对参数文件重命令
[oracle@slavea dbs]$ cd /u01/app/oracle/product/11.2.0.4/db_1/dbs/
[oracle@slavea dbs]$ mv master_pfile.ora initslnngkb.ora

进行修改,最后的参数如下:

*.audit_file_dest='/u01/app/oracle/admin/slnngkb/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/slnngkb/control01.ctl','/u01/app/oracle/fast_recovery_area/slnngkb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='slnngka'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=slnngkbXDB)'
*.enable_goldengate_replication=TRUE
*.log_archive_dest_1='location=/u01/archivelog/ valid_for=(all_logfiles,all_roles) db_unique_name=slnngkb'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=1070596096
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=3213885440
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

 

注意:
*.db_name保留与源库一致不需要修改,否则在启动的时候报如下错误:

SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-01103: database name 'SLNNGKA' in control file is not 'SLNNGKB'

 

4.原库备份

run{
allocate channel c1 device type disk;
backup as compressed backupset format '/u01/rmanbak/df_t%t_s%s_p%p' database;
sql 'alter system archive log current';
backup as compressed backupset archivelog all delete input format '/u01/rmanbak/archive_log_t%t_s%s_p%p';
backup current controlfile format '/u01/rmanbak/ctl_%u.bak' tag 'bak_controlfile';
backup spfile format '/u01/rmanbak/spfile_%u_%T.bak';
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt obsolete;
release channel c1;
}

 

RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/u01/archivelog/1_129_1153413040.dbf thread=1 sequence=129
有DG的环境,归档日志还不能删除


解决办法1(不需要重启):
好像该方法不管用
alter system set "_deferred_log_dest_is_valid" = FALSE scope=both;

 

解决办法2:
alter system set log_archive_dest_2='' scope=both;

 

5.将备份集拷贝到异机

scp archive_log_t1154017805_s41_p1  [email protected]:/u01/rmanbak/
scp ctl_1a2chqhh.bak                [email protected]:/u01/rmanbak/
scp df_t1154017711_s38_p1           [email protected]:/u01/rmanbak/
scp spfile_1b2chqhj_20231127.bak    [email protected]:/u01/rmanbak/

 

 

6.异地机器启动到nomont状态

[oracle@slnngkb dbs]$ sqlplus /nolog
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup nomount pfile=/u01/app/oracle/product/11.2.0.4/db_1/dbs/initslnngkb.ora
ORACLE instance started.

Total System Global Area 3206836224 bytes
Fixed Size                  2257520 bytes
Variable Size             721423760 bytes
Database Buffers         2466250752 bytes
Redo Buffers               16904192 bytes

 

7.恢复控制文件(在nomount状态下恢复)

[oracle@slnngkb dbs]$ rman target /
RMAN> restore controlfile from '/u01/rmanbak/ctl_1a2chqhh.bak';

Starting restore at 27-NOV-23
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/slnngkb/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/slnngkb/control02.ctl
Finished restore at 27-NOV-23


自动会根据启动参数的配置参数*.control_files复制到指定的位置.

 

8.启动数据库到mount阶段
SQL> connect / as sysdba
Connected.
SQL> alter database mount;

Database altered.

 

9.注册备份集

[oracle@slnngkb dbs]$ rman target /
RMAN>catalog start with '/u01/rmanbak';

查看备份集:
RMAN> crosscheck backupset;
RMAN> delete expired backupset;
RMAN> list backup of database;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
14      Full    311.94M    DISK        00:00:50     27-NOV-23      
        BP Key: 14   Status: AVAILABLE  Compressed: YES  Tag: TAG20231127T145444
        Piece Name: /u01/rmanbak/df_t1154012084_s14_p1
  List of Datafiles in backup set 14
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 3655725    27-NOV-23 /u01/app/oracle/oradata/slnngka/system01.dbf
  2       Full 3655725    27-NOV-23 /u01/app/oracle/oradata/slnngka/sysaux01.dbf
  3       Full 3655725    27-NOV-23 /u01/app/oracle/oradata/slnngka/undotbs01.dbf
  4       Full 3655725    27-NOV-23 /u01/app/oracle/oradata/slnngka/users01.dbf
  5       Full 3655725    27-NOV-23 /u01/app/oracle/oradata/slnngka/gguser.dbf
  6       Full 3655725    27-NOV-23 /u01/app/oracle/oradata/slnngka/tps_goldengate01.dbf

 

10.还原数据文件

run{
allocate channel c1 device type disk;
set newname for database to '/u01/app/oracle/oradata/slnngkb/%b';
restore database;
switch datafile all;
switch tempfile all;
release channel c1;
}

 

参数说明:
%b 指定的文件名从目录路径中剥离,只获取数据文件名称.

 

11.恢复数据库
查看备份过来的归档日志

RMAN> list backup of archivelog all;


List of Backup Sets
===================


BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
16      346.29M    DISK        00:00:47     27-NOV-23      
        BP Key: 16   Status: AVAILABLE  Compressed: YES  Tag: TAG20231127T145542
        Piece Name: /u01/rmanbak/archive_log_t1154012143_s16_p1
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
18      231.09M    DISK        00:00:38     27-NOV-23      
        BP Key: 18   Status: AVAILABLE  Compressed: YES  Tag: TAG20231127T145542
        Piece Name: /u01/rmanbak/archive_log_t1154012244_s18_p1

  List of Archived Logs in backup set 18
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    98      3205872    23-NOV-23 3205990    23-NOV-23
  1    99      3205990    23-NOV-23 3206048    23-NOV-23
  1    100     3206048    23-NOV-23 3206105    23-NOV-23
  1    101     3206105    23-NOV-23 3206164    23-NOV-23
  1    102     3206164    23-NOV-23 3206316    23-NOV-23
  1    103     3206316    23-NOV-23 3206892    23-NOV-23
  1    104     3206892    23-NOV-23 3207306    23-NOV-23
  1    105     3207306    23-NOV-23 3309631    23-NOV-23
  1    106     3309631    23-NOV-23 3309722    23-NOV-23
  1    107     3309722    23-NOV-23 3309782    23-NOV-23
  1    108     3309782    23-NOV-23 3309840    23-NOV-23
  1    109     3309840    23-NOV-23 3309899    23-NOV-23
  1    110     3309899    23-NOV-23 3310046    23-NOV-23
  1    111     3310046    23-NOV-23 3330987    27-NOV-23
  1    112     3330987    27-NOV-23 3331257    27-NOV-23
  1    113     3331257    27-NOV-23 3433179    27-NOV-23
  1    114     3433179    27-NOV-23 3433268    27-NOV-23
  1    115     3433268    27-NOV-23 3433328    27-NOV-23
  1    116     3433328    27-NOV-23 3433389    27-NOV-23
  1    117     3433389    27-NOV-23 3433449    27-NOV-23
  1    118     3433449    27-NOV-23 3433603    27-NOV-23
  1    119     3433603    27-NOV-23 3436106    27-NOV-23
  1    120     3436106    27-NOV-23 3436489    27-NOV-23
  1    121     3436489    27-NOV-23 3536868    27-NOV-23
  1    122     3536868    27-NOV-23 3536943    27-NOV-23
  1    123     3536943    27-NOV-23 3536991    27-NOV-23
  1    124     3536991    27-NOV-23 3537046    27-NOV-23
  1    125     3537046    27-NOV-23 3537100    27-NOV-23
  1    126     3537100    27-NOV-23 3537171    27-NOV-23
  1    127     3537171    27-NOV-23 3537631    27-NOV-23
  1    128     3537631    27-NOV-23 3538990    27-NOV-23
  1    129     3538990    27-NOV-23 3554627    27-NOV-23
  1    130     3554627    27-NOV-23 3593037    27-NOV-23
  1    131     3593037    27-NOV-23 3633058    27-NOV-23
  1    132     3633058    27-NOV-23 3655797    27-NOV-23
  1    133     3655797    27-NOV-23 3655805    27-NOV-23

 

12.恢复到指定的归档日志
我们这里恢复到133的归档日志,语法需要指定到134(133+1)

run{
set until sequence 134 thread 1;
recover database;
}

 

13.打开数据库

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00344: unable to re-create online log
'/u01/app/oracle/oradata/slnngka/redo01.log'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1

查看当前v$log日志
SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/slnngka/redo03.log
/u01/app/oracle/oradata/slnngka/redo02.log
/u01/app/oracle/oradata/slnngka/redo01.log
/u01/app/oracle/oradata/slnngka/stdbyredo04.log
/u01/app/oracle/oradata/slnngka/stdbyredo05.log
/u01/app/oracle/oradata/slnngka/stdbyredo06.log

6 rows selected.

修改路径
alter database rename file '/u01/app/oracle/oradata/slnngka/redo01.log' to '/u01/app/oracle/oradata/slnngkb/redo01.log';
alter database rename file '/u01/app/oracle/oradata/slnngka/redo02.log' to '/u01/app/oracle/oradata/slnngkb/redo02.log';
alter database rename file '/u01/app/oracle/oradata/slnngka/redo03.log' to '/u01/app/oracle/oradata/slnngkb/redo03.log';


standby log调整,若这里不调整,open数据库的时候可以进行删除
alter database rename file '/u01/app/oracle/oradata/slnngka/stdbyredo04.log' to '/u01/app/oracle/oradata/slnngkb/stdbyredo04.log';
alter database rename file '/u01/app/oracle/oradata/slnngka/stdbyredo05.log' to '/u01/app/oracle/oradata/slnngkb/stdbyredo05.log';
alter database rename file '/u01/app/oracle/oradata/slnngka/stdbyredo06.log' to '/u01/app/oracle/oradata/slnngkb/stdbyredo06.log';

删除standby log的方法(open database的情况下)
select GROUP# from v$standby_log;

alter database drop logfile group 4;
alter database drop logfile group 5;
alter database drop logfile group 6;

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00392: log 2 of thread 1 is being cleared, operation not allowed
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/slnngkb/redo02.log'

查看日志状态
SQL> select group#,bytes/1024/1024||'M',status from v$log;

    GROUP# BYTES/1024/1024||'M'                      STATUS
---------- ----------------------------------------- ----------------
         1 50M                                       CLEARING
         3 50M                                       CLEARING
         2 50M                                       CLEARING_CURRENT

修复:
SQL> alter database clear logfile group 1;
SQL> alter database clear logfile group 2;
SQL> alter database clear logfile group 3;

再次打开:
SQL> alter database open resetlogs;

Database altered.

 

14.创建spfile
create spfile from pfile='/u01/app/oracle/product/11.2.0.4/db_1/dbs/initslnngkb.ora';

 

标签:11G,27,23,app,oracle,NOV,rman,异机,u01
From: https://www.cnblogs.com/hxlasky/p/17859992.html

相关文章

  • MySQL8.x 中 performance_schema 下 processlist表的说明
    MySQL8.x中performance_schema下processlist表的说明最近在研究一个MySQL数据库的监控相关功能的系统的实现,因此专门研究了一下processlist表。processlist表为MySQL的核心表之一。MySQLprocesslist表示当前由服务器内执行的线程集执行的操作。进程列表表是进程信息的来......
  • FH511GB是一款24键外红遥控电子蜡烛灯IC芯片
    FH511GB是一款24键外红遥控电子蜡烛灯IC芯片,仿真蜡烛效果。闪法新颖.采用CMOS制造工艺,低功耗,内建震荡电阻,宽电压使 用范围: DC 2.2V –5.0V ,上电工作,可用于封装在LED里面。FH511GB是一款极富创新性的电子蜡烛灯IC芯片,具有24个键的外红遥控功能,仿真蜡烛效果,且闪法新颖。采用......
  • Linux下Oracle11G数据备份恢复(RMAN)
    数据库安装参考步骤1--14https://www.cnblogs.com/baixisuozai/p/17852235.html创建初始pfile文件$viminit.umpay.ora文件内容:umpay.__java_pool_size=4194304umpay.__large_pool_size=4194304umpay.__oracle_base='/DataBase/app/oracle'#ORACLE_BASEsetfromenv......
  • linux下安装oracle 11g(静默安装)
    关闭selinux关闭防火墙检查安装依赖包yum-yinstallbinutilscompat-libcap1vsftpdgccgcc-c++glibc-develglibcelfutils-libelfdevelcompat-libcap1libaio-develkshlibgcclibstdc++libstdc++-devellibaiolibaio-develmakesysstatunixODBCunixODBC-devel......
  • 使用RMAN Duplicate搭建DG,备库启动时报ORA-19838
    1、故障概要客户使用duplicate搭建DataGuard时,遭遇ORA-19838错误,备库无法mount,具体报错信息如下所示。 2、故障分析(1).与客户进行电话沟通,了解整个故障的过程:客户先在主库上进行RMAN备份,然后将备份集传输至备库,最后使用duplicatetargetdatabaseforstandbynofilenameche......
  • Performance Improvements in .NET 8 -- Exceptions & Reflection & Primitives【翻译
    Exceptions在.NET6中,ArgumentNullException增加了一个ThrowIfNull方法,我们开始尝试提供“抛出助手”。该方法的目的是简洁地表达正在验证的约束,让系统在未满足约束时抛出一致的异常,同时也优化了成功和99.999%的情况,无需抛出异常。该方法的结构是这样的,执行检查的快速路径被......
  • Performance Improvements in .NET 8 -- Exceptions & Reflection & Primitives【翻译
    Exceptions在.NET6中,ArgumentNullException增加了一个ThrowIfNull方法,我们开始尝试提供“抛出助手”。该方法的目的是简洁地表达正在验证的约束,让系统在未满足约束时抛出一致的异常,同时也优化了成功和99.999%的情况,无需抛出异常。该方法的结构是这样的,执行检查的快速路径被......
  • 运用xtrabackup异机迁移单库
    文档课题:运用xtrabackup异机迁移单库.数据库:mysql5.7.21innobackupex版本:2.4.12innobackupex安装包:percona-xtrabackup-24-2.4.12-1.el7.x86_64.rpm节点1:192.168.133.111+mysql-leo-master节点2:192.168.133.112+mysql-leo-slave1、测试数据确认--节点1数据.mysql>s......
  • RMAN-ERROR:因为找不到过期和丢失的归档日志而备份失败
    oracleRMANERRORoracle采用rman备份,但是备份过程中报错如下:RMAN-00571:===========================================================RMAN-00569:===============ERRORMESSAGESTACKFOLLOWS===============RMAN-00571:========================================......
  • CF911G Mass Change Queries
    题目描述:给出一个数列,有q个操作,每种操作是把区间[l,r]中等于x的数改成y.输出q步操作完的数列.数据范围:\(1\len\le2\times10^5\)\(1\lea_i\le100\)\(1\leq\le2\times10^5,1\lel,r\len,1\lex,y\le100\)思路:观察数据范围,我们发现值域只有可怜的\(100\)所以一......