asm

---創建asm實例 [oracle@edsir1p8-PROD4 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 22 09:48:03 2017 Copyright (c) 1982, 2009, Oracle.  All rights reserved. Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area  129724416 bytes Fixed Size    1334996 bytes Variable Size  113246508 bytes Database Buffers    8388608 bytes Redo Buffers    6754304 bytes Database mounted. Database opened. ---查看當前數據庫文件的形式 SQL> select name from  v$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/PROD4/PROD4/system01.dbf /u01/app/oracle/oradata/PROD4/PROD4/sysaux01.dbf /u01/app/oracle/oradata/PROD4/PROD4/undotbs01.dbf /u01/app/oracle/oradata/PROD4/PROD4/users01.dbf /u01/app/oracle/oradata/PROD4/PROD4/example01.dbf SQL> select name from  v$controlfile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/PROD4/PROD4/control01.ctl /u01/app/oracle/oradata/PROD4/PROD4/control02.ctl /home/oracle/control03.ctl SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- /u01/app/oracle/oradata/PROD4/PROD4/redo03.log /u01/app/oracle/oradata/PROD4/PROD4/redo02.log /u01/app/oracle/oradata/PROD4/PROD4/redo01.log SQL> select name from v$tempfile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/PROD4/PROD4/temp01.dbf --都是文件系統形式 ---用rman進行拷貝文件(以asm的形式),需要asm實例的支持 ---在grid命令下 ---./asmca --1、確定歸檔時開着的 SQL> archive log list Database log mode       Archive Mode Automatic archival       Enabled Archive destination       /home/oracle/arch Oldest online log sequence     24 Next log sequence to archive   26 Current log sequence       26 --2、copy 文件系統文件 格式爲asm [oracle@edsir1p8-PROD4 ~]$ echo $ORACLE_SID PROD4 [oracle@edsir1p8-PROD4 ~]$ rman target / Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jun 22 09:59:38 2017 Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved. connected to target database: PROD4 (DBID=1612213667) RMAN> BACKUP as copy database format '+DATA'; RMAN-03009: failure of backup command on ORA_DISK_1 channel at 06/25/2017 14:04:09 ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode    ---歸檔沒有開 SQL> archive log list; Database log mode       No Archive Mode Automatic archival       Disabled Archive destination       /u01/app/oracle/product/11.2.0/db_1/dbs/arch Oldest online log sequence     5 Current log sequence SQL> shutdown immediate SQL> startup mount SQL> alter system set log_archive_dest_1='location=/home/oracle/arch';  ---目錄創建好 SQL> alter database archivelog; SQL> archive log list; SQL> alter database open; RMAN> BACKUP as copy database format '+DATA'; ......... Finished backup at 22-JUN-17 --只會複製.dbf ,不會複製temp.dbf的文件 --進到asmcmd裏面查看是否copy成功 [oracle@edsir1p8-+ASM ~]$ echo $ORACLE_SID +ASM [oracle@edsir1p8-+ASM ~]$ asmcmd ASMCMD> ls DATA/ DATA3/ ASMCMD> cd DATA ASMCMD> ls ASM/ PROD4/ ASMCMD> cd PROD4 ASMCMD> ls BACKUPSET/ CONTROLFILE/ DATAFILE/ ASMCMD> cd datafile ASMCMD> ls EXAMPLE.259.947325847 SYSAUX.256.947325777 SYSTEM.257.947325691 UNDOTBS1.258.947325823 USERS.261.947325859 ASMCMD> pwd +DATA/PROD4/datafile      --需要用到 ASMCMD> cd .. ASMCMD> ls BACKUPSET/ CONTROLFILE/ DATAFILE/ ASMCMD> cd controlfile ASMCMD> pwd +data/prod4/controlfile                ---參數文件裏需要指定他的位置 ASMCMD> ls Backup.260.947325855 --創建一個表,模擬數據庫在變化 --prod4操作: SQL> create table t1 as select * from dba_objects; Table created. ---切歸檔 SQL> alter system switch logfile; System altered. --指定控制文件,控制文件指向各種文件 --改參數文件,以這個文件啓動數據庫到mount [oracle@edsir1p8-PROD4 ~]$ vi bb.ora *.control_files='+data/prod4/controlfile/Backup.260.947325855' [oracle@edsir1p8-PROD4 ~]$ export ORACLE_SID=p4        --(隨便的名字) ---只要文件對,用什麼實例都能連進去 [oracle@edsir1p8-p4 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 22 10:30:27 2017 Copyright (c) 1982, 2009, Oracle.  All rights reserved. Connected to an idle instance SQL> startup mount pfile='/home/oralce/p4.ora'; LRM-00109: could not open parameter file '/home/oralce/p4.ora' ORA-01078: failure in processing system parameters --原因: [oracle@edsir1p8-p4 ~]$ echo $ORACLE_HOME /u01/app/oracle/product/11.2.0/grid --解決: [root@edsir1p8 ~]# su - oracle [oracle@edsir1p8- ~]$ export ORACLE_SID=p4 [oracle@edsir1p8-p4 ~]$ echo $ORACLE_SID p4 [oracle@edsir1p8-p4 ~]$ sqlplus / as sysdba -bash: sqlplus: command not found [oracle@edsir1p8-p4 ~]$ . oraenv PROD4 ORACLE_SID = [p4] ? The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 is /u01/app/oracle [oracle@edsir1p8-p4 ~]$ . oraenv ORACLE_SID = [p4] ? PROD4 The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 is /u01/app/oracle [oracle@edsir1p8-PROD4 ~]$ export ORACLE_SID=p4 [oracle@edsir1p8-p4 ~]$ echo $ORACLE_SID p4 [oracle@edsir1p8-p4 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 22 11:04:00 2017 Copyright (c) 1982, 2009, Oracle.  All rights reserved. Connected to an idle instance. SQL> startup mount pfile='/home/oracle/p4.ora'; ORACLE instance started. Total System Global Area  129724416 bytes Fixed Size    1334996 bytes Variable Size   83886380 bytes Database Buffers   37748736 bytes Redo Buffers    6754304 bytes ORA-01102: cannot mount database in exclusive mode  ---單機只能有一個實例去開啓一個文件 ----通過刪文件解決 [oracle@edsir1p8-p4 ~]$ echo $ORACLE_HOME /u01/app/oracle/product/11.2.0/db_1 [oracle@edsir1p8-PROD4 dbs]$ pwd /u01/app/oracle/product/11.2.0/db_1/dbs [oracle@edsir1p8-PROD4 dbs]$ rm -fr lkPROD4   --這個會把實例鎖起來 SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/PROD4/PROD4/system01.dbf /u01/app/oracle/oradata/PROD4/PROD4/sysaux01.dbf /u01/app/oracle/oradata/PROD4/PROD4/undotbs01.dbf /u01/app/oracle/oradata/PROD4/PROD4/users01.dbf /u01/app/oracle/oradata/PROD4/PROD4/example01.dbf --在rman裏改 [oracle@edsir1p8-p4 ~]$ echo $ORACLE_SID p4 [oracle@edsir1p8-p4 ~]$ echo $ORACLE_HOME /u01/app/oracle/product/11.2.0/db_1 --從備份中拷貝 RMAN> catalog start with '+data';    --將DATA備份集恢復 ---做文件的路徑修改 RMAN> switch database to copy; datafile 1 switched to datafile copy "+DATA/prod4/datafile/system.257.947325691" datafile 2 switched to datafile copy "+DATA/prod4/datafile/sysaux.256.947325777" datafile 3 switched to datafile copy "+DATA/prod4/datafile/undotbs1.258.947325823" datafile 4 switched to datafile copy "+DATA/prod4/datafile/users.261.947325859" datafile 5 switched to datafile copy "+DATA/prod4/datafile/example.259.947325847" --數據庫恢復,--會把歸檔裏的內容做一遍 RMAN> recover database; SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- +DATA/prod4/datafile/system.257.947325691 +DATA/prod4/datafile/sysaux.256.947325777 +DATA/prod4/datafile/undotbs1.258.947325823 +DATA/prod4/datafile/users.261.947325859 +DATA/prod4/datafile/example.259.947325847 ---然後關生產庫 [oracle@edsir1p8-p4 ~]$ . oraenv ORACLE_SID = [p4] ? PROD4 The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 is /u01/app/oracle [oracle@edsir1p8-PROD4 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 22 11:20:07 2017 Copyright (c) 1982, 2009, Oracle.  All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> shutdown immediate;   ---注意關的位置,在open p4之前 [oracle@edsir1p8-PROD4 ~]$ export ORACLE_SID=p4 [oracle@edsir1p8-p4 ~]$ echo $ORACLE_SID p4 [oracle@edsir1p8-p4 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 22 11:21:18 2017 Copyright (c) 1982, 2009, Oracle.  All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Partitioning, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> alter database open  ; alter database open * ERROR at line 1: ORA-01589: must use RESETLOGS or NORESETLOGS option for database open SQL> alter database open resetlogs; Database altered. SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- +DATA/prod4/datafile/system.257.947325691 +DATA/prod4/datafile/sysaux.256.947325777 +DATA/prod4/datafile/undotbs1.258.947325823 +DATA/prod4/datafile/users.261.947325859 +DATA/prod4/datafile/example.259.947325847 SQL> select name from v$controlfile; NAME -------------------------------------------------------------------------------- +DATA/prod4/controlfile/backup.260.947325855 SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- /u01/app/oracle/oradata/PROD4/PROD4/redo03.log /u01/app/oracle/oradata/PROD4/PROD4/redo02.log /u01/app/oracle/oradata/PROD4/PROD4/redo01.log -----還不是 --1.添加redo日誌 SQL> alter database add logfile member '+data' to group 1; Database altered. SQL> alter database add logfile member '+data' to group 2; Database altered. SQL> alter database add logfile member '+data' to group 3; Database altered --2.切換日誌 SQL> alter system switch logfile; System altered. SQL> / System altered. SQL> / System altered. --3、刪除就的redo SQL> alter database drop logfile member '/u01/app/oracle/oradata/PROD4/PROD4/redo01.log'; alter database drop logfile member '/u01/app/oracle/oradata/PROD4/PROD4/redo01.log' * ERROR at line 1: ORA-00362: member is required to form a valid logfile in group 1 ORA-01517: log member: '/u01/app/oracle/oradata/PROD4/PROD4/redo01.log' ---是因爲沒有切日誌 SQL> alter database drop logfile member '/u01/app/oracle/oradata/PROD4/PROD4/redo01.log'; Database altered. SQL> alter database drop logfile member '/u01/app/oracle/oradata/PROD4/PROD4/redo02.log'; alter database drop logfile member '/u01/app/oracle/oradata/PROD4/PROD4/redo02.log' * ERROR at line 1: ORA-01609: log 2 is the current log for thread 1 - cannot drop members ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/PROD4/PROD4/redo02.log' ORA-00312: online log 2 thread 1: '+DATA/prod4/onlinelog/group_2.264.947330771' --解決: --當前的redo,不能刪,切 SQL> alter system switch logfile; System altered. SQL> alter database drop logfile member '/u01/app/oracle/oradata/PROD4/PROD4/redo02.log'; Database altered. SQL> alter database drop logfile member '/u01/app/oracle/oradata/PROD4/PROD4/redo03.log'; Database altered. --查看redolog SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- +DATA/prod4/onlinelog/group_1.263.947330761 +DATA/prod4/onlinelog/group_2.264.947330771 +DATA/prod4/onlinelog/group_3.265.947330777 --解決tmp.dbf SQL> alter tablespace temp add tempfile '+DATA' size 20M; Tablespace altered. SQL> alter tablespace temp drop tempfile '/u01/app/oracle/oradata/PROD4/PROD4/temp 01.dbf'; Tablespace altered. --查看tempfile SQL> select name from v$tempfile; NAME -------------------------------------------------------------------------------- +DATA/prod4/tempfile/temp.266.947331451 --查看創建的表是否存在 select count(*) from t1; SQL> create spfile from memory; File created. --關數據庫 SQL> shutdown immediate; [oracle@edsir1p8-p4 db_1]$ cd dbs [oracle@edsir1p8-p4 dbs]$ ls hc_DBUA0.dat  init.ora       orapwEMREP     peshm_EMREP_0    spfilePROD4.ora hc_EMREP.dat  initPROD4.ora  orapwPROD4     peshm_PROD4_0 hc_p4.dat     lkEMREP        peshm__0       spfileEMREP.ora hc_PROD4.dat  lkPROD4        peshm_DBUA0_0  spfilep4.ora --一定注意PROD4的實例關掉 [oracle@edsir1p8-p4 dbs]$ mv spfilePROD4.ora spfilePROD4.ora.bak --p4實例關掉 [oracle@edsir1p8-p4 dbs]$ mv spfilep4.ora  spfilePROD4.ora [oracle@edsir1p8-p4 dbs]$ pwd /u01/app/oracle/product/11.2.0/db_1/dbs [oracle@edsir1p8-p4 dbs]$ . oraenv ORACLE_SID = [p4] ? PROD4 The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 is /u01/app/oracle [oracle@edsir1p8-PROD4 dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 22 11:43:47 2017 Copyright (c) 1982, 2009, Oracle.  All rights reserved. Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area  129724416 bytes Fixed Size    1334996 bytes Variable Size  100663596 bytes Database Buffers   20971520 bytes Redo Buffers    6754304 bytes Database mounted. Database opened. --重新再查一遍 -----注意實例別用混了 SQL> show parameter control NAME     TYPE VALUE ------------------------------------ ----------- ------------------------------ _optimizer_extended_stats_usage_cont integer 224 rol _optimizer_join_order_control     integer 3 control_file_record_keep_time     integer 7 control_files     string +DATA/prod4/controlfile/backup  .260.947325855 control_management_pack_access     string DIAGNOSTIC+TUNING SQL> select name from v$controlfile; NAME -------------------------------------------------------------------------------- +DATA/prod4/controlfile/backup.260.947325855 注意:在操作之前該關閉的要關閉,否則會報內部錯誤
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章