-- 论Oracle恢复测试手术杂谈:
[oracle@newmachine ~]$ ifconfig |grep addr
bond0 Link encap:Ethernet HWaddr 6C:92:BF:6B:4D:94
inet addr:10.180.58.100 Bcast:10.180.255.255 Mask:255.255.0.0
inet6 addr: fe80::6e92:bfff:fe6b:4d94/64 Scopeink
eth0 Link encap:Ethernet HWaddr 6C:92:BF:6B:4D:94
inet6 addr: fe80::6e92:bfff:fe6b:4d94/64 Scopeink
eth1 Link encap:Ethernet HWaddr 6C:92:BF:6B:4D:94
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
对应等一些列体检清单,spfile不可少....
[oracle@newmachine restore]$ cat boss.pfile
*.archive_lag_target=1200
*.audit_file_dest='/u01/app/oracle/admin/bossdb/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_file_record_keep_time=7
*.control_files=/data/oradata/bossdb/controlfile/bossdb_control01.ctl'
*.db_block_size=8192
*.db_create_file_dest='/data/oradata/bossdb/datafile'
*.db_domain=''
*.db_name='boss'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=10737418240
*.db_unique_name='bossdb'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=bossdbXDB)'
*.job_queue_processes=1000
*.log_archive_dest_1='location=/data/oradata/bossdb/archivelog'
*.log_archive_dest_state_1='enable'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_max_target=12884901888
*.memory_target=11884901888
*.open_cursors=500
*.pga_aggregate_target=884901888
*.processes=4000
*.remote_login_passwordfile='exclusive'
*.service_names='bossdb','bossdg','boss_bg'
*.undo_tablespace='UNDOTBS1'
记得插入各种管,异物泄露台上就不好了,然后继续数据处理......
[oracle@newmachine restore]$ mkdir -pv /u01/app/oracle/admin/bossdb/adump /data/oradata/bossdb/controlfile/ /data/oradata/bossdb/datafile /u01/app/oracle/fast_recovery_area /data/oradata/bossdb/archivelog
mkdir: created directory `/u01/app/oracle/admin'
mkdir: created directory `/u01/app/oracle/admin/bossdb'
mkdir: created directory `/u01/app/oracle/admin/bossdb/adump'
mkdir: created directory `/data/oradata/bossdb/controlfile/'
mkdir: created directory `/u01/app/oracle/fast_recovery_area'
[oracle@newmachine restore]$ pwd
/data/restore
开始干活了,不聊了,忙了!
[oracle@newmachine restore]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sat Sep 22 08:46:52 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
手术之前,除了手术刀,还得有spfile 文件,不然会很麻烦得后期通过动态修改参数,相信我说得.....
SQL> create spfile from pfile='/data/restore/boss.pfile';
File created.
不说了,真滴要干活了,nomount 状态启动...
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1.2827E+10 bytes
Fixed Size 2265224 bytes
Variable Size 4999614328 bytes
Database Buffers 7818182656 bytes
Redo Buffers 7307264 bytes
-- nomount 状态加载成功,开始吸收日月精华,恢复生机咯...
[oracle@newmachine 20180819]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Sep 22 09:30:24 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: BOSS (not mounted)
-- 一夫当关,没有我得把控,是万万不行滴...
RMAN> restore controlfile from '/data/restore/20180819/Current_Controlfile_BOSS_20180819_6890_.ctl';
Starting restore at 22-SEP-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=4520 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/data/oradata/bossdb/controlfile/bossdb_control01.ctl'
Finished restore at 22-SEP-18
RMAN>
--鸟巢已经架好,开始生蛋造孵化器了....
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
--看看,就知道内容忒丰富,这么多文件,绝对不能错过哦....
RMAN>
1515425624
RMAN> run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
catalog start with '/data/restore/20180819';
set newname for datafile 1 to '/data/oradata/bossdb/datafile/system.272.946425675';
set newname for datafile 2 to '/data/oradata/bossdb/datafile/sysaux.259.946425635';
set newname for datafile 3 to '/data/oradata/bossdb/datafile/undotbs1.274.946425679';
set newname for datafile 4 to '/data/oradata/bossdb/datafile/users.283.946426289';
set newname for datafile 5 to '/data/oradata/bossdb/datafile/undotbs2.275.946425681';
set newname for datafile 6 to '/data/oradata/bossdb/datafile/undotbs3.276.946425685';
set newname for datafile 7 to '/data/oradata/bossdb/datafile/undotbs4.277.946425687';
set newname for datafile 8 to '/data/oradata/bossdb/datafile/main.278.946426271';
set newname for datafile 9 to '/data/oradata/bossdb/datafile/main.260.946425635';
set newname for datafile 10 to '/data/oradata/bossdb/datafile/main.261.946425635';
set newname for datafile 11 to '/data/oradata/bossdb/datafile/main.279.946426275';
set newname for datafile 12 to '/data/oradata/bossdb/datafile/main.262.946425643';
set newname for datafile 13 to '/data/oradata/bossdb/datafile/main.264.946425645';
set newname for datafile 14 to '/data/oradata/bossdb/datafile/main.263.946425645';
set newname for datafile 15 to '/data/oradata/bossdb/datafile/main.280.946426279';
set newname for datafile 16 to '/data/oradata/bossdb/datafile/main.265.946425653';
set newname for datafile 17 to '/data/oradata/bossdb/datafile/main.267.946425657';
set newname for datafile 18 to '/data/oradata/bossdb/datafile/main.266.946425653';
set newname for datafile 19 to '/data/oradata/bossdb/datafile/main.281.946426283';
set newname for datafile 20 to '/data/oradata/bossdb/datafile/main.268.946425663';
set newname for datafile 21 to '/data/oradata/bossdb/datafile/main.270.946425667';
set newname for datafile 22 to '/data/oradata/bossdb/datafile/main.269.946425665';
set newname for datafile 23 to '/data/oradata/bossdb/datafile/main.282.946426287';
set newname for datafile 24 to '/data/oradata/bossdb/datafile/main.271.946425675';
set newname for datafile 25 to '/data/oradata/bossdb/datafile/main.273.946425679';
set newname for datafile 26 to '/data/oradata/bossdb/datafile/sysaux_02.dbf';
set newname for tempfile 1 to '/data/oradata/bossdb/datafile/temp.284.947205797';
set newname for tempfile 2 to '/data/oradata/bossdb/datafile/main_temp.288.947205799';
restore database;
switch datafile all;
switch tempfile all;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
};
..........
..........
.........
--此处省略N项ABCD12345 等符号...
..........
..........
..........
channel ORA_DISK_1: reading from backup piece /data/restore/20180819/Rmanbak_6879_1_20180819_BOSS_DB
channel ORA_DISK_1: piece handle=/data/restore/20180819/Rmanbak_6879_1_20180819_BOSS_DB tag=RMANBAK_FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 01:08:36
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to /data/oradata/bossdb/datafile/sysaux.259.946425635
channel ORA_DISK_1: restoring datafile 00005 to /data/oradata/bossdb/datafile/undotbs2.275.946425681
channel ORA_DISK_1: restoring datafile 00014 to /data/oradata/bossdb/datafile/main.263.946425645
channel ORA_DISK_1: restoring datafile 00018 to /data/oradata/bossdb/datafile/main.266.946425653
channel ORA_DISK_1: restoring datafile 00022 to /data/oradata/bossdb/datafile/main.269.946425665
channel ORA_DISK_1: restoring datafile 00026 to /data/oradata/bossdb/datafile/sysaux_02.dbf
channel ORA_DISK_1: reading from backup piece /data/restore/20180819/Rmanbak_6881_1_20180819_BOSS_DB
channel ORA_DISK_1: piece handle=/data/restore/20180819/Rmanbak_6881_1_20180819_BOSS_DB tag=RMANBAK_FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 01:14:26
Finished restore at 22-SEP-18
-- 终于撸完了,虽然过程很是幸苦,但是结果还是可以接受滴... 这不,就等这Finished 这个译文单词了,虽然不知道他说什么。
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/data/oradata/bossdb/datafile/system.272.946425675'
RMAN > RECOVER DATABASE ;
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00349: failure obtaining block size for
'+DB_REDO/bossdb/onlinelog/thread1_redo11.db
-- 神马情况,不科学啊,战场立下这么多汉马功劳,难道就在这里被卡主了么? BS它,BS它....
-- 一路键盘噼里啪啦声,声声入耳,看看再说,终于逮到一个表现得机会了。
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
14 1 0 104857600 512 1 YES CLEARING 1744495247 19-AUG-18 1744513340 19-AUG-18
13 1 0 104857600 512 1 YES CLEARING 1744495162 19-AUG-18 1744495247 19-AUG-18
12 1 0 104857600 512 1 NO CLEARING_CURRENT 1744538089 19-AUG-18 2.8147E+14
11 1 0 104857600 512 1 YES CLEARING 1744535324 19-AUG-18 1744538089 19-AUG-18
15 1 0 104857600 512 1 YES CLEARING 1744513340 19-AUG-18 1744535324 19-AUG-18
24 2 0 104857600 512 1 YES CLEARING 1744495153 19-AUG-18 1744495238 19-AUG-18
23 2 0 104857600 512 1 NO CLEARING_CURRENT 1744538095 19-AUG-18 2.8147E+14
22 2 0 104857600 512 1 YES CLEARING 1744535321 19-AUG-18 1744538095 19-AUG-18
21 2 0 104857600 512 1 YES CLEARING 1744513346 19-AUG-18 1744535321 19-AUG-18
25 2 0 104857600 512 1 YES CLEARING 1744495238 19-AUG-18 1744513346 19-AUG-18
31 3 0 104857600 512 1 NO CLEARING_CURRENT 1744538092 19-AUG-18 2.8147E+14
32 3 0 104857600 512 1 YES CLEARING 1744495156 19-AUG-18 1744495241 19-AUG-18
33 3 0 104857600 512 1 YES CLEARING 1744495241 19-AUG-18 1744513343 19-AUG-18
34 3 0 104857600 512 1 YES CLEARING 1744513343 19-AUG-18 1744535327 19-AUG-18
35 3 0 104857600 512 1 YES CLEARING 1744535327 19-AUG-18 1744538092 19-AUG-18
41 4 0 104857600 512 1 YES CLEARING 1744535330 19-AUG-18 1744538044 19-AUG-18
42 4 0 104857600 512 1 NO CLEARING_CURRENT 1744538044 19-AUG-18 2.8147E+14
43 4 0 104857600 512 1 YES CLEARING 1744495159 19-AUG-18 1744495244 19-AUG-18
44 4 0 104857600 512 1 YES CLEARING 1744495244 19-AUG-18 1744513349 19-AUG-18
45 4 0 104857600 512 1 YES CLEARING 1744513349 19-AUG-18 1744535330 19-AUG-18
20 rows selected.
SQL> alter database clear unarchived logfile group 12;
alter database clear unarchived logfile group 12
*
ERROR at line 1:
ORA-00349: failure obtaining block size for '+DB_REDO/bossdb/onlinelog/thread1_redo12.db
SQL> select CHECKPOINT_CHANGE#,count(*) from V$DATAFILE_HEADER group by CHECKPOINT_CHANGE#;
CHECKPOINT_CHANGE# COUNT(*)
------------------ ----------
1744538044 26
-- 难道要我使用大招,你这小样才能屈服么?
-- 降龙十八掌...
--看我少林大力金刚掌...
SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS '/tmp/restore_control.sql' resetlogs ;
Database altered.
-- 看我杀猪技术,你这 佩奇 身体不错,筋络清晰,没毛病...
[oracle@newmachine 20180819]$ cat /tmp/restore_control.sql
CREATE CONTROLFILE REUSE DATABASE "BOSS" RESETLOGS FORCE LOGGING ARCHIVELOG
MAXLOGFILES 802
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 3373
LOGFILE
GROUP 11 '/data/oradata/bossdb/logfile/thread1_redo11.dbf' SIZE 100M BLOCKSIZE 512,
GROUP 12 '/data/oradata/bossdb/logfile/thread1_redo12.dbf' SIZE 100M BLOCKSIZE 512,
GROUP 13 '/data/oradata/bossdb/logfile/thread1_redo13.dbf' SIZE 100M BLOCKSIZE 512,
GROUP 14 '/data/oradata/bossdb/logfile/thread1_redo14.dbf' SIZE 100M BLOCKSIZE 512,
GROUP 15 '/data/oradata/bossdb/logfile/thread1_redo15.dbf' SIZE 100M BLOCKSIZE 512
DATAFILE
'/data/oradata/bossdb/datafile/system.272.946425675',
'/data/oradata/bossdb/datafile/sysaux.259.946425635',
'/data/oradata/bossdb/datafile/undotbs1.274.946425679',
'/data/oradata/bossdb/datafile/users.283.946426289',
'/data/oradata/bossdb/datafile/undotbs2.275.946425681',
'/data/oradata/bossdb/datafile/undotbs3.276.946425685',
'/data/oradata/bossdb/datafile/undotbs4.277.946425687',
'/data/oradata/bossdb/datafile/main.278.946426271',
'/data/oradata/bossdb/datafile/main.260.946425635',
'/data/oradata/bossdb/datafile/main.261.946425635',
'/data/oradata/bossdb/datafile/main.279.946426275',
'/data/oradata/bossdb/datafile/main.262.946425643',
'/data/oradata/bossdb/datafile/main.264.946425645',
'/data/oradata/bossdb/datafile/main.263.946425645',
'/data/oradata/bossdb/datafile/main.280.946426279',
'/data/oradata/bossdb/datafile/main.265.946425653',
'/data/oradata/bossdb/datafile/main.267.946425657',
'/data/oradata/bossdb/datafile/main.266.946425653',
'/data/oradata/bossdb/datafile/main.281.946426283',
'/data/oradata/bossdb/datafile/main.268.946425663',
'/data/oradata/bossdb/datafile/main.270.946425667',
'/data/oradata/bossdb/datafile/main.269.946425665',
'/data/oradata/bossdb/datafile/main.282.946426287',
'/data/oradata/bossdb/datafile/main.271.946425675',
'/data/oradata/bossdb/datafile/main.273.946425679',
'/data/oradata/bossdb/datafile/sysaux_02.dbf'
CHARACTER SET ZHS16GBK
;
-- 擦擦汗,尼玛你这太重了,看来牛刀解剖听费力气滴,下次得用剪刀才合适,噗呲噗呲....
[oracle@newmachine tmp]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sat Sep 22 19:33:29 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-- 上帝之手,神操作,无需解释....
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 1.2827E+10 bytes
Fixed Size 2265224 bytes
Variable Size 4999614328 bytes
Database Buffers 7818182656 bytes
Redo Buffers 7307264 bytes
-- 重塑金身,前途无量,虽然很BS你得前身.....
SQL> @/tmp/restore_control.sql
Control file created.
-- 不好意思,不好意思 方才小手一抖,突然感觉有点累了.
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-01100: database already mounted
-- 幸我花费你身上得心血没有白费,小样你好像复活了,看你春光灿烂的....
SQL> alter database open resetlogs;
Database altered.
-- 出院之前,是不是要再检测一下,有木有问题....
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
BOSS READ WRITE
SQL> select username,account_status from dba_users where account_status='OPEN';
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
SYSTEM OPEN
SYS OPEN
QUERY500 OPEN
OEM OPEN
WEB4RO OPEN
OGG_BOSS OPEN
MGMT_VIEW OPEN
BOSS OPEN
BOSS_SERVICE OPEN
WEB4BI OPEN
LIMIN OPEN
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
SYSMAN OPEN
DBSNMP OPEN
13 rows selected.
SQL> SELECT COUNT(*) FROM BOSS.B_ALLUSERMONEY;
COUNT(*)
----------
47
-- 好吧,你可以滚了....