|
从文件系统进ASM:
- select * from v$log;
- alter database drop logfile group 3;
- alter database add logfile group 3 size 50M;
- select member from v$logfile;
- alter database drop logfile group 1;
- alter database add logfile group 1 size 50M;
- alter system switch logfile;
- alter system checkpoint;
- alter database drop logfile group 2;
- alter database add logfile group 2 size 50M;
- ------------------------------------------------------------------
复制代码- SQL> startup mount
- ORACLE instance started.
- Total System Global Area 1046224896 bytes
- Fixed Size 1341140 bytes
- Variable Size 603982124 bytes
- Database Buffers 436207616 bytes
- Redo Buffers 4694016 bytes
- ORA-00205: error in identifying control file, check alert log for more info
- SQL> show parameter control
- NAME TYPE
- ------------------------------------ ---------------------------------
- VALUE
- ------------------------------
- control_file_record_keep_time integer
- 7
- control_files string
- /u01/app/oracle/product/11.2.0
- /dbhome_1/dbs/cntrlorcl.dbf
- control_management_pack_access string
- DIAGNOSTIC+TUNING
- SQL> alter system set control_files='/u01/app/oracle/oradata/orcl/control01.ctl' scope=spfile;
- System altered.
- SQL> shutdown immediate
- ORA-01507: database not mounted
- ORACLE instance shut down.
- SQL> startup mount
- ORACLE instance started.
- Total System Global Area 1046224896 bytes
- Fixed Size 1341140 bytes
- Variable Size 603982124 bytes
- Database Buffers 436207616 bytes
- Redo Buffers 4694016 bytes
- Database mounted.
- SQL> exit
- Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- [oracle@station86 dbs]$ rman target /
- Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jun 26 19:54:12 2018
- Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
- connected to target database: ORCL (DBID=1359978017, not open)
- RMAN> exit
- Recovery Manager complete.
- [oracle@station86 dbs]$ sqlplus /nolog
- SQL*Plus: Release 11.2.0.1.0 Production on Tue Jun 26 19:54:56 2018
- Copyright (c) 1982, 2009, Oracle. All rights reserved.
- SQL> conn / as sysdba
- Connected.
- SQL> show parameter db_recovery
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- db_recovery_file_dest string +FRA
- db_recovery_file_dest_size big integer 4G
- SQL> alter system set db_recovery_file_dest='+DATA';
- System altered.
- SQL> exit
- Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- [oracle@station86 dbs]$ rman target /
- Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jun 26 19:55:20 2018
- Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
- connected to target database: ORCL (DBID=1359978017, not open)
- RMAN> backup as copy database;
- Starting backup at 2018-06-26:19:55:49
- using target database control file instead of recovery catalog
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: SID=136 device type=DISK
- allocated channel: ORA_DISK_2
- channel ORA_DISK_2: SID=7 device type=DISK
- allocated channel: ORA_DISK_3
- channel ORA_DISK_3: SID=49 device type=DISK
- allocated channel: ORA_DISK_4
- channel ORA_DISK_4: SID=93 device type=DISK
- allocated channel: ORA_DISK_5
- channel ORA_DISK_5: SID=137 device type=DISK
- allocated channel: ORA_DISK_6
- channel ORA_DISK_6: SID=8 device type=DISK
- allocated channel: ORA_DISK_7
- channel ORA_DISK_7: SID=50 device type=DISK
- allocated channel: ORA_DISK_8
- channel ORA_DISK_8: SID=94 device type=DISK
- channel ORA_DISK_1: starting datafile copy
- input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
- channel ORA_DISK_2: starting datafile copy
- input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
- channel ORA_DISK_3: starting datafile copy
- input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs1.dbf
- channel ORA_DISK_4: starting datafile copy
- input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
- channel ORA_DISK_5: starting datafile copy
- input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
- channel ORA_DISK_6: starting datafile copy
- input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/tbs1.dbf
- channel ORA_DISK_7: starting datafile copy
- input datafile file number=00007 name=/u01/app/oracle/oradata/orcl/tbs2.dbf
- output file name=+DATA/orcl/datafile/users.265.979847755 tag=TAG20180626T195551 RECID=17 STAMP=979847767
- channel ORA_DISK_5: datafile copy complete, elapsed time: 00:00:25
- output file name=+DATA/orcl/datafile/tbs1.256.979847755 tag=TAG20180626T195551 RECID=15 STAMP=979847764
- channel ORA_DISK_6: datafile copy complete, elapsed time: 00:00:25
- output file name=+DATA/orcl/datafile/tbs2.257.979847755 tag=TAG20180626T195551 RECID=16 STAMP=979847765
- channel ORA_DISK_7: datafile copy complete, elapsed time: 00:00:26
- output file name=+DATA/orcl/datafile/undotbs1.258.979847755 tag=TAG20180626T195551 RECID=19 STAMP=979847811
- channel ORA_DISK_3: datafile copy complete, elapsed time: 00:01:07
- output file name=+DATA/orcl/datafile/example.259.979847765 tag=TAG20180626T195551 RECID=18 STAMP=979847810
- channel ORA_DISK_4: datafile copy complete, elapsed time: 00:01:07
- output file name=+DATA/orcl/datafile/sysaux.267.979847755 tag=TAG20180626T195551 RECID=20 STAMP=979847825
- channel ORA_DISK_2: datafile copy complete, elapsed time: 00:01:19
- output file name=+DATA/orcl/datafile/system.268.979847755 tag=TAG20180626T195551 RECID=21 STAMP=979847830
- channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:29
- Finished backup at 2018-06-26:19:57:20
- Starting Control File and SPFILE Autobackup at 2018-06-26:19:57:20
- piece handle=+DATA/orcl/autobackup/2018_06_26/s_979847323.263.979847841 comment=NONE
- Finished Control File and SPFILE Autobackup at 2018-06-26:19:57:21
- RMAN> switch database to copy ;
- datafile 1 switched to datafile copy "+DATA/orcl/datafile/system.268.979847755"
- datafile 2 switched to datafile copy "+DATA/orcl/datafile/sysaux.267.979847755"
- datafile 3 switched to datafile copy "+DATA/orcl/datafile/undotbs1.258.979847755"
- datafile 4 switched to datafile copy "+DATA/orcl/datafile/users.265.979847755"
- datafile 5 switched to datafile copy "+DATA/orcl/datafile/example.259.979847765"
- datafile 6 switched to datafile copy "+DATA/orcl/datafile/tbs1.256.979847755"
- datafile 7 switched to datafile copy "+DATA/orcl/datafile/tbs2.257.979847755"
- RMAN> exit
- Recovery Manager complete.
- [oracle@station86 dbs]$ sqlplus /nolog
- SQL*Plus: Release 11.2.0.1.0 Production on Tue Jun 26 19:57:44 2018
- Copyright (c) 1982, 2009, Oracle. All rights reserved.
- SQL> conn / as sysdba
- Connected.
- SQL> show parameter db_recovery
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- db_recovery_file_dest string +DATA
- db_recovery_file_dest_size big integer 4G
- SQL> alter system set db_recovery_file_dest='+FRA';
- System altered.
- SQL>
复制代码- SQL>
- SQL> alter database backup controlfile to trace as '/home/oracle/control8c-2.sql'
- 2 ;
- Database altered.
- SQL> exit
复制代码 control8c-2.sql:
- CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOG
- MAXLOGFILES 16
- MAXLOGMEMBERS 3
- MAXDATAFILES 100
- MAXINSTANCES 8
- MAXLOGHISTORY 292
- LOGFILE
- GROUP 1 (
- '+DATA/orcl/onlinelog/group_1.264.979847063',
- '+FRA/orcl/onlinelog/group_1.320.979847065'
- ) SIZE 50M BLOCKSIZE 512,
- GROUP 2 (
- '+DATA/orcl/onlinelog/group_2.260.979847183',
- '+FRA/orcl/onlinelog/group_2.350.979847185'
- ) SIZE 50M BLOCKSIZE 512,
- GROUP 3 (
- '+DATA/orcl/onlinelog/group_3.266.979846987',
- '+FRA/orcl/onlinelog/group_3.294.979846989'
- ) SIZE 50M BLOCKSIZE 512
- DATAFILE
- '+DATA/orcl/datafile/system.268.979847755',
- '+DATA/orcl/datafile/sysaux.267.979847755',
- '+DATA/orcl/datafile/undotbs1.258.979847755',
- '+DATA/orcl/datafile/users.265.979847755',
- '+DATA/orcl/datafile/example.259.979847765',
- '+DATA/orcl/datafile/tbs1.256.979847755',
- '+DATA/orcl/datafile/tbs2.257.979847755'
- CHARACTER SET AL32UTF8
- ;
- -- Configure RMAN configuration record 1
- VARIABLE RECNO NUMBER;
- EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('RETENTION POLICY','TO RECOVERY WINDOW OF 1 DAYS');
- -- Configure RMAN configuration record 2
- VARIABLE RECNO NUMBER;
- EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('BACKUP OPTIMIZATION','ON');
- -- Configure RMAN configuration record 3
- VARIABLE RECNO NUMBER;
- EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP','ON');
- -- Configure RMAN configuration record 4
- VARIABLE RECNO NUMBER;
- EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('DEVICE TYPE','DISK PARALLELISM 8 BACKUP TYPE TO BACKUPSET');
- -- Configure RMAN configuration record 5
- VARIABLE RECNO NUMBER;
- EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('DEFAULT DEVICE TYPE TO','DISK');
- -- Configure RMAN configuration record 6
- VARIABLE RECNO NUMBER;
- EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('DEVICE TYPE','''SBT_TAPE'' PARALLELISM 2 BACKUP TYPE TO BACKUPSET');
- -- Configure RMAN configuration record 7
- VARIABLE RECNO NUMBER;
- EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CHANNEL','1 DEVICE TYPE ''SBT_TAPE'' PARMS ''ENV=(OB_MEDIA_FAMILY=station86)''');
- -- Configure RMAN configuration record 8
- VARIABLE RECNO NUMBER;
- EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CHANNEL','2 DEVICE TYPE ''SBT_TAPE'' PARMS ''ENV=(OB_MEDIA_FAMILY=station86)''');
- -- Configure RMAN configuration record 9
- VARIABLE RECNO NUMBER;
- EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CHANNEL','DEVICE TYPE ''SBT_TAPE'' PARMS ''ENV=(OB_MEDIA_FAMILY=station86)''');
复制代码- [oracle@station86 ~]$ sqlplus /nolog
- SQL*Plus: Release 11.2.0.1.0 Production on Tue Jun 26 20:02:48 2018
- Copyright (c) 1982, 2009, Oracle. All rights reserved.
- SQL> conn / as sysdba
- Connected.
- SQL> show parameter control
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- control_file_record_keep_time integer 7
- control_files string /u01/app/oracle/oradata/orcl/c
- ontrol01.ctl
- control_management_pack_access string DIAGNOSTIC+TUNING
- SQL> alter system set control_files='+DATA','+FRA' scope=spfile;
- System altered.
- SQL> shutdown immediate
- ORA-01109: database not open
- Database dismounted.
- ORACLE instance shut down.
- SQL> startup nomount
- ORACLE instance started.
- Total System Global Area 1046224896 bytes
- Fixed Size 1341140 bytes
- Variable Size 603982124 bytes
- Database Buffers 436207616 bytes
- Redo Buffers 4694016 bytes
- SQL> @/home/oracle/control8c-2
- Control file created.
- PL/SQL procedure successfully completed.
- PL/SQL procedure successfully completed.
- PL/SQL procedure successfully completed.
- PL/SQL procedure successfully completed.
- PL/SQL procedure successfully completed.
- PL/SQL procedure successfully completed.
- PL/SQL procedure successfully completed.
- PL/SQL procedure successfully completed.
- PL/SQL procedure successfully completed.
- SQL> alter database open ;
- Database altered.
- SQL> alter tablespace temp add tempfile '+DATA' size 30M autoextend on ;
- Tablespace altered.
- SQL> show parameter spfile;
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- spfile string /u01/app/oracle/product/11.2.0
- /dbhome_1/dbs/spfileorcl.ora
- SQL> create pfile='/home/oracle/pfile.ora' from spfile;
- File created.
- SQL> create spfile='+data/orcl/spfileorcl.ora' from pfile='/home/oracle/pfile.ora';
- File created.
- SQL> shutdown immediate
- Database closed.
- Database dismounted.
- ORACLE instance shut down.
- SQL>
复制代码
写/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora为spfile='+data/orcl/spfileorcl.ora'
再启动,做完。
- [oracle@station86 ~]$ srvctl remove database -d orcl
- Remove the database orcl? (y/[n]) y
- [oracle@station86 ~]$ srvctl add database -d orcl -o /u01/app/oracle/product/11.2.0/dbhome_1
- [oracle@station86 ~]$ crs_stat -t
- Name Type Target State Host
- ------------------------------------------------------------
- ora.DATA.dg ora....up.type ONLINE ONLINE station86
- ora.FRA.dg ora....up.type ONLINE ONLINE station86
- ora....ER.lsnr ora....er.type ONLINE ONLINE station86
- ora.asm ora.asm.type ONLINE ONLINE station86
- ora.cssd ora.cssd.type ONLINE ONLINE station86
- ora.diskmon ora....on.type ONLINE ONLINE station86
- ora.orcl.db ora....se.type OFFLINE OFFLINE
- [oracle@station86 ~]$ crsctl start res ora.orcl.db
- CRS-2672: Attempting to start 'ora.orcl.db' on 'station86'
复制代码 关于ASM迁移的最后的讨论:
当时的操作时串行:
- RMAN> run {
- 2> allocate channel c1 device type disk format '/u01/app/oracle/oradata/orcl/system01.dbf';
- 3> backup as copy datafile 1;
- 4> release channel c1;
- 5> allocate channel c1 device type disk format '/u01/app/oracle/oradata/orcl/sysaux01.dbf';
- 6> backup as copy datafile 2;
- 7> release channel c1;
- 8> allocate channel c1 device type disk format '/u01/app/oracle/oradata/orcl/undotbs1.dbf';
- 9> backup as copy datafile 3;
- 10> release channel c1;
- 11> allocate channel c1 device type disk format '/u01/app/oracle/oradata/orcl/users01.dbf';
- 12> backup as copy datafile 4;
- 13> release channel c1;
- 14> allocate channel c1 device type disk format '/u01/app/oracle/oradata/orcl/example01.dbf';
- 15> backup as copy datafile 5;
- 16> release channel c1;
- 17> allocate channel c1 device type disk format '/u01/app/oracle/oradata/orcl/tbs1.dbf';
- 18> backup as copy datafile 6;
- 19> release channel c1;
- 20> allocate channel c1 device type disk format '/u01/app/oracle/oradata/orcl/tbs2.dbf';
- 21> backup as copy datafile 7;
- 22> release channel c1;
- 23> }
复制代码
做数据文件迁移的时候能改进一下吗:
- RMAN> run {
- 2> allocate channel c1 device type disk format '/u01/app/oracle/oradata/orcl/system01.dbf';
- 3> allocate channel c2 device type disk format '/u01/app/oracle/oradata/orcl/sysaux01.dbf';
- 4> allocate channel c3 device type disk format '/u01/app/oracle/oradata/orcl/undotbs1.dbf';
- 5> allocate channel c4 device type disk format '/u01/app/oracle/oradata/orcl/users01.dbf';
- 6> allocate channel c5 device type disk format '/u01/app/oracle/oradata/orcl/example01.dbf';
- 7> allocate channel c6 device type disk format '/u01/app/oracle/oradata/orcl/tbs1.dbf';
- 8> allocate channel c7device type disk format '/u01/app/oracle/oradata/orcl/tbs2.dbf';
- 9> backup as copy database;
- 10>}
复制代码
以上的做法有可能存在通道和输入不是你想要的对应关系:
- Tag: ORA_OEM_LEVEL_0
- RMAN> list copy of datafile 5;
- List of Datafile Copies
- =======================
- Key File S Completion Time Ckp SCN Ckp Time
- ------- ---- - ------------------- ---------- -------------------
- 9 5 A 2018-06-26:20:18:09 1334275 2018-06-26:20:17:12
- Name: /u01/app/oracle/oradata/orcl/users01.dbf
- Tag: TAG20180626T201706
- 4 5 A 2018-06-26:20:16:50 1333986 2018-06-26:20:16:40
- Name: +FRA/orcl/datafile/example.340.979849001
- Tag: ORA_OEM_LEVEL_0
- RMAN>
复制代码
可以提前看一下1Z0-053第8章的解决方案:
- RMAN> report schema;
- Report of database schema for database with db_unique_name ORCL
- List of Permanent Datafiles
- ===========================
- File Size(MB) Tablespace RB segs Datafile Name
- ---- -------- -------------------- ------- ------------------------
- 1 690 SYSTEM *** +DATA/orcl/datafile/system.268.979847755
- 2 570 SYSAUX *** +DATA/orcl/datafile/sysaux.267.979847755
- 3 290 UNDOTBS1 *** +DATA/orcl/datafile/undotbs1.258.979847755
- 4 5 USERS *** +DATA/orcl/datafile/users.265.979847755
- 5 198 EXAMPLE *** +DATA/orcl/datafile/example.259.979847765
- 6 5 TBS1 *** +DATA/orcl/datafile/tbs1.256.979847755
- 7 5 TBS2 *** +DATA/orcl/datafile/tbs2.257.979847755
- List of Temporary Files
- =======================
- File Size(MB) Tablespace Maxsize(MB) Tempfile Name
- ---- -------- -------------------- ----------- --------------------
- 1 30 TEMP 32767 +DATA/orcl/tempfile/temp.261.979848279
复制代码
- RMAN> run {
- 2> allocate channel c1 device type disk format '/u01/app/oracle/oradata/orcl/system01.dbf';
- 3> allocate channel c2 device type disk format '/u01/app/oracle/oradata/orcl/sysaux01.dbf';
- 4> allocate channel c3 device type disk format '/u01/app/oracle/oradata/orcl/undotbs1.dbf';
- 5> allocate channel c4 device type disk format '/u01/app/oracle/oradata/orcl/users01.dbf';
- 6> allocate channel c5 device type disk format '/u01/app/oracle/oradata/orcl/example01.dbf';
- 7> allocate channel c6 device type disk format '/u01/app/oracle/oradata/orcl/tbs1.dbf';
- 8> allocate channel c7 device type disk format '/u01/app/oracle/oradata/orcl/tbs2.dbf';
- 9> backup as copy (datafile 1 channel c1 )
- (datafile 2 channel c2)
- (datafile 3 channel c3)
- (datafile 4 channel c4)
- (datafile 5 channel c5)
- (datafile 6 channel c6)
- (datafile 7 channel c7) ;
- 10>}
复制代码- RMAN> list failure;
- using target database control file instead of recovery catalog
- List of Database Failures
- =========================
- Failure ID Priority Status Time Detected Summary
- ---------- -------- --------- ------------------- -------
- 4268 HIGH OPEN 2018-06-26:21:11:51 Tablespace 4: 'USERS' is offline
- RMAN> advise failure;
- List of Database Failures
- =========================
- Failure ID Priority Status Time Detected Summary
- ---------- -------- --------- ------------------- -------
- 4268 HIGH OPEN 2018-06-26:21:11:51 Tablespace 4: 'USERS' is offline
- analyzing automatic repair options; this may take some time
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: SID=105 device type=DISK
- allocated channel: ORA_DISK_2
- channel ORA_DISK_2: SID=147 device type=DISK
- allocated channel: ORA_DISK_3
- channel ORA_DISK_3: SID=16 device type=DISK
- allocated channel: ORA_DISK_4
- channel ORA_DISK_4: SID=48 device type=DISK
- allocated channel: ORA_DISK_5
- channel ORA_DISK_5: SID=104 device type=DISK
- allocated channel: ORA_DISK_6
- channel ORA_DISK_6: SID=148 device type=DISK
- allocated channel: ORA_DISK_7
- channel ORA_DISK_7: SID=13 device type=DISK
- allocated channel: ORA_DISK_8
- channel ORA_DISK_8: SID=53 device type=DISK
- allocated channel: ORA_SBT_TAPE_1
- channel ORA_SBT_TAPE_1: SID=100 device type=SBT_TAPE
- channel ORA_SBT_TAPE_1: Oracle Secure Backup
- allocated channel: ORA_SBT_TAPE_2
- channel ORA_SBT_TAPE_2: SID=144 device type=SBT_TAPE
- channel ORA_SBT_TAPE_2: Oracle Secure Backup
- analyzing automatic repair options complete
- Mandatory Manual Actions
- ========================
- no manual actions available
- Optional Manual Actions
- =======================
- no manual actions available
- Automated Repair Options
- ========================
- Option Repair Description
- ------ ------------------
- 1 Online tablespace USERS
- Strategy: The repair includes complete media recovery with no data loss
- Repair script: /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_87746635.hm
- RMAN> repair failure preview;
- Strategy: The repair includes complete media recovery with no data loss
- Repair script: /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_87746635.hm
- contents of repair script:
- # online a offline tablespace
- sql "begin sys.dbms_ir.execsqlscript(filename => ''/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2569490396.hm'' ); end;";
- RMAN> repair failure;
- Strategy: The repair includes complete media recovery with no data loss
- Repair script: /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_87746635.hm
- contents of repair script:
- # online a offline tablespace
- sql "begin sys.dbms_ir.execsqlscript(filename => ''/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2569490396.hm'' ); end;";
- Do you really want to execute the above repair (enter YES or NO)? YES
- executing repair script
- sql statement: begin sys.dbms_ir.execsqlscript(filename => ''/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2569490396.hm'' ); end;
- repair failure complete
- RMAN> exit
- Recovery Manager complete.
- [oracle@station86 ~]$
复制代码
|
|