DB环境: Oracle 10gR2
下载相应的oracleasm.rpm包,注意最后一个必须要和你当前的OS内核一致。
[root@zhong mysql]# uname -r 2.6.9-89.EL [root@zhong mysql]# rpm -qa|grep oracleasm oracleasmlib-2.0.4-1.el4 oracleasm-support-2.1.7-1.el4 oracleasm-2.6.9-89.EL-2.0.5-1.el4 [root@zhong mysql]#
[root@zhong mysql]# ll /dev/sd* |grep -v sda brw-rw---- 1 root disk 8, 16 Jan 7 22:05 /dev/sdb brw-rw---- 1 root disk 8, 17 Jan 8 09:50 /dev/sdb1 brw-rw---- 1 root disk 8, 32 Jan 7 22:05 /dev/sdc brw-rw---- 1 root disk 8, 33 Jan 8 09:51 /dev/sdc1 brw-rw---- 1 root disk 8, 48 Jan 7 22:05 /dev/sdd brw-rw---- 1 root disk 8, 49 Jan 8 09:51 /dev/sdd1 brw-rw---- 1 root disk 8, 64 Jan 7 22:05 /dev/sde brw-rw---- 1 root disk 8, 65 Jan 8 09:52 /dev/sde1 brw-rw---- 1 root disk 8, 80 Jan 7 22:05 /dev/sdf brw-rw---- 1 root disk 8, 81 Jan 8 09:53 /dev/sdf1 brw-rw---- 1 root disk 8, 96 Jan 7 22:05 /dev/sdg brw-rw---- 1 root disk 8, 97 Jan 8 09:53 /dev/sdg1 [root@zhong mysql]#
SYS@joy:~>select name from v$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/joy/system01.dbf /u01/app/oracle/oradata/joy/undotbs01.dbf /u01/app/oracle/oradata/joy/sysaux01.dbf /u01/app/oracle/oradata/joy/users01.dbf /u01/app/oracle/oradata/joy/example01.dbf SYS@joy:~>select name from v$tempfile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/joy/temp01.dbf SYS@joy:~>select name from v$controlfile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/joy/control01.ctl /u01/app/oracle/oradata/joy/control02.ctl /u01/app/oracle/oradata/joy/control03.ctl SYS@joy:~>select name from v$archived_log; NAME -------------------------------------------------------------------------------- /u01/app/oracle/flash_recovery_area/JOY/archivelog/2012_01_07/o1_mf_1_4_7jj67qm4_.arc SYS@joy:~>select member from v$logfile; MEMBER -------------------------------------------------------------------------------- /u01/app/oracle/oradata/joy/redo03.log /u01/app/oracle/oradata/joy/redo02.log /u01/app/oracle/oradata/joy/redo01.log SYS@joy:~>
[root@zhong mysql]# /etc/init.d/oracleasm configure Configuring the Oracle ASM library driver. This will configure the on-boot properties of the Oracle ASM library driver. The following questions will determine whether the driver is loaded on boot and what permissions it will have. The current values will be shown in brackets ('[]'). Hitting without typing an answer will keep that current value. Ctrl-C will abort. Default user to own the driver interface []: oracle Default group to own the driver interface []: dba Start Oracle ASM library driver on boot (y/n) [n]: y Scan for Oracle ASM disks on boot (y/n) [y]: y Writing Oracle ASM library driver configuration: done Initializing the Oracle ASMLib driver: [ OK ] Scanning the system for Oracle ASMLib disks: [ OK ] [root@zhong mysql]# /etc/init.d/oracleasm scandisks Scanning the system for Oracle ASMLib disks: [ OK ] [root@zhong mysql]# /etc/init.d/oracleasm status Checking if ASM is loaded: yes Checking if /dev/oracleasm is mounted: yes [root@zhong mysql]#
[root@zhong ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1 Marking disk "VOL1" as an ASM disk: [ OK ] [root@zhong ~]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1 Marking disk "VOL2" as an ASM disk: [ OK ] [root@zhong ~]# /etc/init.d/oracleasm createdisk VOL3 /dev/sdd1 Marking disk "VOL3" as an ASM disk: [ OK ] [root@zhong ~]# /etc/init.d/oracleasm createdisk VOL4 /dev/sde1 Marking disk "VOL4" as an ASM disk: [ OK ] [root@zhong ~]# /etc/init.d/oracleasm createdisk VOL5 /dev/sdf1 Marking disk "VOL5" as an ASM disk: [ OK ] [root@zhong ~]# /etc/init.d/oracleasm createdisk VOL6 /dev/sdg1 Marking disk "VOL6" as an ASM disk: [ OK ] [root@zhong ~]#
[root@zhong ~]# /etc/init.d/oracleasm listdisks VOL1 VOL2 VOL3 VOL4 VOL5 VOL6 [root@zhong ~]#
[root@zhong ~]# /u01/app/oracle/product/10.2.0/db_1/bin/localconfig add /etc/oracle does not exist. Creating it now. Successfully accumulated necessary OCR keys. Creating OCR keys for user 'root', privgrp 'root'.. Operation successful. Configuration for local CSS has been initialized Adding to inittab Startup will be queued to init within 90 seconds. Checking the status of new Oracle init process... Expecting the CRS daemons to be up within 600 seconds. CSS is active on these nodes. zhong CSS is active on all nodes. Oracle CSS service is installed and running under init(1M) [root@zhong ~]#
[oracle@zhong ~]$ ps -ef|grep css root 15719 1 0 10:43 ? 00:00:00 /bin/su -l oracle -c sh -c 'cd /u01/app/oracle/product/10.2.0/db_1/log/zhong/cssd; ulimit -c unlimited; exec /u01/app/oracle/product/10.2.0/db_1/bin/ocssd ' oracle 15802 15719 0 10:44 ? 00:00:00 /u01/app/oracle/product/10.2.0/db_1/bin/ocssd.bin oracle 15850 14466 0 10:45 pts/0 00:00:00 grep css [oracle@zhong ~]$
[oracle@zhong dbs]$ cd /u01/app/oracle/product/10.2.0/db_1/dbs/ [oracle@zhong dbs]$ cat init+ASM.ora instance_type=asm large_pool_size=12M remote_login_passwordfile=exclusive asm_diskstring='ORCL:VOL*' asm_diskgroups=dg1,dg2,recovery background_dump_dest=/u01/app/oracle/admin/+ASM/bdump core_dump_dest=/u01/app/oracle/admin/+ASM/cdump user_dump_dest=/u01/app/oracle/admin/+ASM/udump [oracle@zhong dbs]$
[oracle@zhong ~]$ orapwd file=/u01/app/oracle/product/10.2.0/db_1/dbs/orapw+ASM entries=3 password=oracle [oracle@zhong ~]$ ls $ORACLE_HOME/dbs/orapw* /u01/app/oracle/product/10.2.0/db_1/dbs/orapw+ASM /u01/app/oracle/product/10.2.0/db_1/dbs/orapwjoy [oracle@zhong ~]$
[oracle@zhong dbs]$ export ORACLE_SID=+ASM [oracle@zhong dbs]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jan 8 10:57:24 2012 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to an idle instance. SYS@+ASM:~>startup ASM instance started Total System Global Area 83886080 bytes Fixed Size 1217836 bytes Variable Size 57502420 bytes ASM Cache 25165824 bytes ORA-15110: no diskgroups mounted SYS@+ASM:~>
SYS@+ASM:~>create diskgroup dg1 external redundancy disk 'ORCL:VOL1','ORCL:VOL2'; Diskgroup created. SYS@+ASM:~>create diskgroup dg2 external redundancy disk 'ORCL:VOL3','ORCL:VOL4'; Diskgroup created. SYS@+ASM:~>create diskgroup recovery external redundancy disk 'ORCL:VOL5','ORCL:VOL6'; Diskgroup created.
[oracle@zhong ~]$ export ORACLE_SID=+ASM [oracle@zhong ~]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jan 8 11:19:29 2012 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to an idle instance. SYS@+ASM:~>startup nomount ASM instance started Total System Global Area 83886080 bytes Fixed Size 1217836 bytes Variable Size 57502420 bytes ASM Cache 25165824 bytes SYS@+ASM:~>alter diskgroup all mount; Diskgroup altered.
SYS@+ASM:~>create spfile from pfile; File created. SYS@+ASM:~>shutdown immediate ASM diskgroups dismounted ASM instance shutdown SYS@+ASM:~>startup ASM instance started Total System Global Area 83886080 bytes Fixed Size 1217836 bytes Variable Size 57502420 bytes ASM Cache 25165824 bytes ASM diskgroups mounted SYS@+ASM:~>show parameter spfile NAME TYPE ------------------------------------ ---------------------- VALUE ------------------------------ spfile string /u01/app/oracle/product/10.2.0 /db_1/dbs/spfile+ASM.ora SYS@+ASM:~>select name,state from v$asm_diskgroup; NAME STATE -------- -------- DG1 MOUNTED DG2 MOUNTED RECOVERY MOUNTED SYS@+ASM:~>
[oracle@zhong ~]$ export ORACLE_SID=joy [oracle@zhong ~]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Sun Jan 8 11:22:15 2012 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: JOY (DBID=1667606455) RMAN> backup as copy database format '+DG1'; Starting backup at 08-JAN-12 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=211 devtype=DISK channel ORA_DISK_1: starting datafile copy input datafile fno=00001 name=/u01/app/oracle/oradata/joy/system01.dbf output filename=+DG1/joy/datafile/system.256.772024975 tag=TAG20120108T112250 recid=3 stamp=772024979 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile copy input datafile fno=00003 name=/u01/app/oracle/oradata/joy/sysaux01.dbf output filename=+DG1/joy/datafile/sysaux.257.772024985 tag=TAG20120108T112250 recid=4 stamp=772024988 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile copy input datafile fno=00005 name=/u01/app/oracle/oradata/joy/example01.dbf output filename=+DG1/joy/datafile/example.258.772024989 tag=TAG20120108T112250 recid=5 stamp=772024989 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile copy input datafile fno=00002 name=/u01/app/oracle/oradata/joy/undotbs01.dbf output filename=+DG1/joy/datafile/undotbs1.259.772024993 tag=TAG20120108T112250 recid=6 stamp=772024995 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile copy input datafile fno=00004 name=/u01/app/oracle/oradata/joy/users01.dbf output filename=+DG1/joy/datafile/users.260.772024997 tag=TAG20120108T112250 recid=7 stamp=772024997 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile copy copying current control file output filename=+DG1/joy/controlfile/backup.261.772024999 tag=TAG20120108T112250 recid=8 stamp=772024999 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset including current SPFILE in backupset channel ORA_DISK_1: starting piece 1 at 08-JAN-12 channel ORA_DISK_1: finished piece 1 at 08-JAN-12 piece handle=+DG1/joy/backupset/2012_01_08/nnsnf0_tag20120108t112250_0.262.772025001 tag=TAG20120108T112250 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 08-JAN-12 RMAN>
[oracle@zhong ~]$ export ORACLE_SID=+ASM [oracle@zhong ~]$ asmcmd ASMCMD> pwd + ASMCMD> ls DG1/ DG2/ RECOVERY/ ASMCMD> cd dg1/joy/datafile ASMCMD> pwd +dg1/joy/datafile ASMCMD> ls -l Type Redund Striped Time Sys Name DATAFILE UNPROT COARSE JAN 08 11:00:00 Y EXAMPLE.258.772024989 DATAFILE UNPROT COARSE JAN 08 11:00:00 Y SYSAUX.257.772024985 DATAFILE UNPROT COARSE JAN 08 11:00:00 Y SYSTEM.256.772024975 DATAFILE UNPROT COARSE JAN 08 11:00:00 Y UNDOTBS1.259.772024993 DATAFILE UNPROT COARSE JAN 08 11:00:00 Y USERS.260.772024997 ASMCMD>
[oracle@zhong ~]$ export ORACLE_SID=joy [oracle@zhong ~]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jan 8 11:30:37 2012 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SYS@joy:~>alter system set db_recovery_file_dest_size=3g; System altered. SYS@joy:~>alter system set db_recovery_file_dest='+RECOVERY'; System altered. SYS@joy:~>
SYS@joy:~>alter system set db_create_file_dest='+DG1'; System altered. SYS@joy:~>alter system set db_create_online_log_dest_1='+DG1'; System altered. SYS@joy:~>alter system set db_create_online_log_dest_2='+DG2'; System altered. SYS@joy:~>
SYS@joy:~>select group#,member from v$logfile; GROUP# MEMBER ---------- ---------------------------------------- 3 /u01/app/oracle/oradata/joy/redo03.log 2 /u01/app/oracle/oradata/joy/redo02.log 1 /u01/app/oracle/oradata/joy/redo01.log SYS@joy:~>alter database add logfile member '+DG1','+DG2' to group 1; Database altered. SYS@joy:~>alter database add logfile member '+DG1','+DG2' to group 2; Database altered. SYS@joy:~>alter database add logfile member '+DG1','+DG2' to group 3; Database altered. SYS@joy:~>alter system switch logfile; System altered. SYS@joy:~>alter database drop logfile member '/u01/app/oracle/oradata/joy/redo01.log'; Database altered. SYS@joy:~>alter system switch logfile; System altered. SYS@joy:~>alter database drop logfile member '/u01/app/oracle/oradata/joy/redo02.log'; Database altered. SYS@joy:~>alter system switch logfile; System altered. SYS@joy:~>alter database drop logfile member '/u01/app/oracle/oradata/joy/redo03.log'; Database altered. SYS@joy:~>
SYS@joy:~>select group#,member from v$logfile; GROUP# MEMBER ---------- ---------------------------------------- 1 +DG1/joy/onlinelog/group_1.263.772025879 1 +DG2/joy/onlinelog/group_1.256.772025883 2 +DG1/joy/onlinelog/group_2.264.772025891 2 +DG2/joy/onlinelog/group_2.257.772025891 3 +DG1/joy/onlinelog/group_3.265.772025895 3 +DG2/joy/onlinelog/group_3.258.772025901 6 rows selected. SYS@joy:~>
SYS@joy:~>select file_name,tablespace_name from dba_temp_files; FILE_NAME TABLESPACE_NAME ---------------------------------------- ------------------- /u01/app/oracle/oradata/joy/temp01.dbf TEMP SYS@joy:~>alter tablespace temp add tempfile size 100m; Tablespace altered. SYS@joy:~>alter database tempfile '/u01/app/oracle/oradata/joy/temp01.dbf' drop; Database altered. SYS@joy:~>select file_name,tablespace_name from dba_temp_files; FILE_NAME TABLESPACE_NAME ---------------------------------------- ------------------- +DG1/joy/tempfile/temp.266.772026681 TEMP SYS@joy:~>
SYS@joy:~>show parameter control_files NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_files string /u01/app/oracle/oradata/joy/co ntrol01.ctl, /u01/app/oracle/o radata/joy/control02.ctl, /u01 /app/oracle/oradata/joy/contro l03.ctl SYS@joy:~>
SYS@joy:~>alter system set control_files='+DG1/JOY/CONTROLFILE/control01','+DG2/JOY/CONTROLFILE/control02' scope=spfile; System altered. SYS@joy:~>shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SYS@joy:~>
SYS@joy:~>startup nomount ORACLE instance started. Total System Global Area 285212672 bytes Fixed Size 1218992 bytes Variable Size 109053520 bytes Database Buffers 171966464 bytes Redo Buffers 2973696 bytes SYS@joy:~>
[oracle@zhong ~]$ rman target=sys/oracle Recovery Manager: Release 10.2.0.1.0 - Production on Sun Jan 8 12:16:12 2012 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: joy (not mounted) RMAN> restore controlfile from '/u01/app/oracle/oradata/joy/control01.ctl'; Starting restore at 08-JAN-12 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=211 devtype=DISK channel ORA_DISK_1: copied control file copy output filename=+DG1/joy/controlfile/control01 output filename=+DG2/joy/controlfile/control02 Finished restore at 08-JAN-12 RMAN> RMAN> alter database mount; database mounted released channel: ORA_DISK_1 RMAN>
RMAN> switch database to copy; datafile 1 switched to datafile copy "+DG1/joy/datafile/system.256.772024975" datafile 2 switched to datafile copy "+DG1/joy/datafile/undotbs1.259.772024993" datafile 3 switched to datafile copy "+DG1/joy/datafile/sysaux.257.772024985" datafile 4 switched to datafile copy "+DG1/joy/datafile/users.260.772024997" datafile 5 switched to datafile copy "+DG1/joy/datafile/example.258.772024989" RMAN>
RMAN> recover database; Starting recover at 08-JAN-12 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=207 devtype=DISK starting media recovery archive log thread 1 sequence 5 is already on disk as file +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_5.256.772025957 archive log thread 1 sequence 6 is already on disk as file +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_6.257.772025995 archive log thread 1 sequence 7 is already on disk as file +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_7.258.772026029 archive log thread 1 sequence 8 is already on disk as file +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_8.259.772026043 archive log thread 1 sequence 9 is already on disk as file +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_9.260.772026053 archive log thread 1 sequence 10 is already on disk as file +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_10.261.772026061 archive log filename=+RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_5.256.772025957 thread=1 sequence=5 archive log filename=+RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_6.257.772025995 thread=1 sequence=6 archive log filename=+RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_7.258.772026029 thread=1 sequence=7 archive log filename=+RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_8.259.772026043 thread=1 sequence=8 media recovery complete, elapsed time: 00:00:03 Finished recover at 08-JAN-12 RMAN> RMAN> alter database open; database opened RMAN>
SYS@joy:~>select name from v$datafile; NAME -------------------------------------------------------------------------------- +DG1/joy/datafile/system.256.772024975 +DG1/joy/datafile/undotbs1.259.772024993 +DG1/joy/datafile/sysaux.257.772024985 +DG1/joy/datafile/users.260.772024997 +DG1/joy/datafile/example.258.772024989 SYS@joy:~>select name from v$tempfile; NAME -------------------------------------------------------------------------------- +DG1/joy/tempfile/temp.266.772026681 SYS@joy:~>select name from v$controlfile; NAME -------------------------------------------------------------------------------- +DG1/joy/controlfile/control01 +DG2/joy/controlfile/control02 SYS@joy:~>select member from v$logfile; MEMBER -------------------------------------------------------------------------------- +DG1/joy/onlinelog/group_1.263.772025879 +DG2/joy/onlinelog/group_1.256.772025883 +DG1/joy/onlinelog/group_2.264.772025891 +DG2/joy/onlinelog/group_2.257.772025891 +DG1/joy/onlinelog/group_3.265.772025895 +DG2/joy/onlinelog/group_3.258.772025901 6 rows selected. SYS@joy:~>select name from v$archived_log; NAME -------------------------------------------------------------------------------- +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_5.256.772025957 +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_6.257.772025995 +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_7.258.772026029 +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_8.259.772026043 +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_9.260.772026053 +RECOVERY/joy/archivelog/2012_01_08/thread_1_seq_10.261.772026061 6 rows selected. SYS@joy:~>
SYS@joy:~>select b.NAME, b.STATE, a.MOUNT_STATUS, a.MODE_STATUS, a.PATH 2 from v$asm_disk a, v$asm_diskgroup b 3 where a.GROUP_NUMBER(+) = b.GROUP_NUMBER; NAME STATE MOUNT_STATUS MODE_STATUS PATH -------- ---------- ------------- ------------- ---------- DG1 CONNECTED OPENED ONLINE ORCL:VOL1 DG1 CONNECTED OPENED ONLINE ORCL:VOL2 DG2 CONNECTED OPENED ONLINE ORCL:VOL3 DG2 CONNECTED OPENED ONLINE ORCL:VOL4 RECOVERY MOUNTED SYS@joy:~>