Archive

Posts Tagged ‘asm’

ASM之迁移到ASM

August 11th, 2009 wajoynece No comments

oracle@wayne-laptop:~$ rman target /

Recovery Manager: Release 10.2.0.4.0 – Production on Tue Aug 11 16:20:41 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: ORA10G (DBID=4013050375)

RMAN> BACKUP AS COPY INCREMENTAL LEVEL 0  DATABASE FORMAT ‘+dg1′TAG ‘ORA_ASM_MIGRATION’;

Starting backup at 11-AUG-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/home/oracle/app/oradata/ora10g/system01.dbf
output filename=+DG1/ora10g/datafile/system.264.694628679 tag=ORA_ASM_MIGRATION recid=7 stamp=694628715
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/home/oracle/app/oradata/ora10g/undotbs01.dbf
output filename=+DG1/ora10g/datafile/undotbs1.265.694628721 tag=ORA_ASM_MIGRATION recid=8 stamp=694628745
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/home/oracle/app/oradata/ora10g/sysaux01.dbf
output filename=+DG1/ora10g/datafile/sysaux.266.694628757 tag=ORA_ASM_MIGRATION recid=9 stamp=694628773
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/home/oracle/app/oradata/ORA10G/datafile/o1_mf_wayne_57q7y8hp_.dbf
output filename=+DG1/ora10g/datafile/wayne.268.694628781 tag=ORA_ASM_MIGRATION recid=10 stamp=694628787
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/home/oracle/app/oradata/ora10g/users01.dbf
output filename=+DG1/ora10g/datafile/users.261.694628797 tag=ORA_ASM_MIGRATION recid=11 stamp=694628796
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=+DG1/ora10g/controlfile/backup.262.694628797 tag=ORA_ASM_MIGRATION recid=12 stamp=694628799
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 11-AUG-09
channel ORA_DISK_1: finished piece 1 at 11-AUG-09
piece handle=+DG1/ora10g/backupset/2009_08_11/nnsnn0_ora_asm_migration_0.263.694628803 tag=ORA_ASM_MIGRATION comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 11-AUG-09

RMAN> run {
2> backup as backupset spfile;
3> restore spfile to ‘+dg1/spfile’;
4> }

Starting backup at 11-AUG-09
using channel ORA_DISK_1
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 11-AUG-09
channel ORA_DISK_1: finished piece 1 at 11-AUG-09
piece handle=/home/oracle/app/flash_recovery_area/ORA10G/backupset/2009_08_11/o1_mf_nnsnf_TAG20090811T162849_582by1ts_.bkp tag=TAG20090811T162849 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-AUG-09

Starting restore at 11-AUG-09
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: restoring SPFILE
output filename=+dg1/spfile
channel ORA_DISK_1: reading from backup piece /home/oracle/app/flash_recovery_area/ORA10G/backupset/2009_08_11/o1_mf_nnsnf_TAG20090811T162849_582by1ts_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/app/flash_recovery_area/ORA10G/backupset/2009_08_11/o1_mf_nnsnf_TAG20090811T162849_582by1ts_.bkp tag=TAG20090811T162849
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 11-AUG-09

RMAN> exit

Recovery Manager complete.
oracle@wayne-laptop:~$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 – Production on Tue Aug 11 16:29:42 2009

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> startup force nomount PFILE=”/tmp/pfile.ora”;
ORACLE instance started.

Total System Global Area  205520896 bytes
Fixed Size            1266584 bytes
Variable Size          100666472 bytes
Database Buffers       96468992 bytes
Redo Buffers            7118848 bytes
SQL> alter system set control_files=’+dg1/ct1.f’,'+fra/ct2.f’ scope=spfile;

System altered.

SQL> alter system set DB_RECOVERY_FILE_DEST_SIZE=2g scope=spfile;

System altered.

SQL> alter system set DB_RECOVERY_FILE_DEST=’+fra’ scope=spfile;

System altered.

SQL> shutdown immediate
ORA-01507: database not mounted

ORACLE instance shut down.
SQL> startup nomount PFILE=”/tmp/pfile.ora”;
ORACLE instance started.

Total System Global Area  205520896 bytes
Fixed Size            1266584 bytes
Variable Size          100666472 bytes
Database Buffers       96468992 bytes
Redo Buffers            7118848 bytes
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
oracle@wayne-laptop:~$ rman target /

Recovery Manager: Release 10.2.0.4.0 – Production on Tue Aug 11 16:33:18 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: ora10g (not mounted)

RMAN> restore controlfile from ‘/home/oracle/app/oradata/ora10g/control03.ctl’;

Starting restore at 11-AUG-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: copied control file copy
output filename=+DG1/ct1.f
output filename=+FRA/ct2.f
Finished restore at 11-AUG-09

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> switch database to copy;

datafile 1 switched to datafile copy “+DG1/ora10g/datafile/system.264.694628679″
datafile 2 switched to datafile copy “+DG1/ora10g/datafile/undotbs1.265.694628721″
datafile 3 switched to datafile copy “+DG1/ora10g/datafile/sysaux.266.694628757″
datafile 4 switched to datafile copy “+DG1/ora10g/datafile/users.261.694628797″
datafile 5 switched to datafile copy “+DG1/ora10g/datafile/wayne.268.694628781″

RMAN> recover database;

Starting recover at 11-AUG-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

starting media recovery
media recovery complete, elapsed time: 00:00:03

Finished recover at 11-AUG-09

RMAN> run {
set newname for tempfile 1 to ‘+dg1′;
switch tempfile all;
}

2> 3> 4>
executing command: SET NEWNAME

renamed temporary file 1 to +dg1 in control file

RMAN> ALTER DATABASE OPEN;

database opened

RMAN> exit

Recovery Manager complete.

oracle@wayne-laptop:~$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 – Production on Tue Aug 11 16:39:03 2009

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
SQL>
declare
cursor rlc is
select group# grp, thread# thr, bytes/1024 bytes_k, ‘NO’ srl
from v$log
union
select group# grp, thread# thr, bytes/1024 bytes_k, ‘YES’ srl
from v$standby_log
order by 1;
stmt     varchar2(2048);
swtstmt  varchar2(1024) := ‘alter system switch logfile’;
ckpstmt  varchar2(1024) := ‘alter system checkpoint global’;
begin
for rlcRec in rlc loop
if (rlcRec.srl = ‘YES’) then
stmt := ‘alter database add standby logfile thread ‘ ||
rlcRec.thr || ‘ ”+DG1” size ‘ ||
rlcRec.bytes_k || ‘K’;
execute immediate stmt;
stmt := ‘alter database drop standby logfile group ‘ || rlcRec.grp;
execute immediate stmt;
else
stmt := ‘alter database add logfile thread ‘ ||
rlcRec.thr || ‘ ”+DG1” size ‘ ||
rlcRec.bytes_k || ‘K’;
execute immediate stmt;
begin
stmt := ‘alter database drop logfile group ‘ || rlcRec.grp;
dbms_output.put_line(stmt);
execute immediate stmt;
exception
when others then
execute immediate swtstmt;
execute immediate ckpstmt;
execute immediate stmt;
end;
end if;
end loop;
38  end;
39  /

PL/SQL procedure successfully completed.

Categories: Oracle Tags: ,

ASM之建立实验环境

August 10th, 2009 wajoynece 4 comments

准备模拟磁盘文件

root@wayne-laptop:/home/oracle/test# for i in 0 1 2 3 ;do dd if=/dev/zero of=file_disk$i bs=1024 count=524288 ; done
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 14.0764 s, 38.1 MB/s
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 15.2912 s, 35.1 MB/s
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 18.8882 s, 28.4 MB/s
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 18.276 s, 29.4 MB/s
root@wayne-laptop:/home/oracle/test# ls -l
total 2099216
-rw-r–r– 1 root root 536870912 2009-08-10 10:48 file_disk0
-rw-r–r– 1 root root 536870912 2009-08-10 10:48 file_disk1
-rw-r–r– 1 root root 536870912 2009-08-10 10:49 file_disk2
-rw-r–r– 1 root root 536870912 2009-08-10 10:49 file_disk3

创建loop设备

root@wayne-laptop:/home/oracle/test# for i in 0 1 2 3 ; do losetup /dev/loop$i file_disk$i; done
root@wayne-laptop:/home/oracle/test# losetup -a
/dev/loop0: [0805]:1917697 (file_disk0)
/dev/loop1: [0805]:1917709 (file_disk1)
/dev/loop2: [0805]:1917711 (file_disk2)
/dev/loop3: [0805]:1917712 (file_disk3)
root@wayne-laptop:/dev# chown oracle:dba /dev/loop*

配置css

+++++++++++++++出现的问题以及解决++++++++++++++++++++++++++
root@wayne-laptop:/home/oracle/app/10.2.0/db_1/bin# localconfig add
/home/oracle/app/10.2.0/db_1/bin/crsctl.bin: /usr/lib/libstdc++.so.5: version `CXXABI_1.2′ not found (required by /home/oracle/app/10.2.0/db_1/bin/crsctl.bin)
/home/oracle/app/10.2.0/db_1/bin/crsctl.bin: /usr/lib/libstdc++.so.5: version `GLIBCPP_3.2′ not found (required by /home/oracle/app/10.2.0/db_1/bin/crsctl.bin)

root@wayne-laptop:/home/oracle/app/10.2.0/db_1/bin# cd /usr/lib
root@wayne-laptop:/usr/lib# ls -l | grep libstdc__
root@wayne-laptop:/usr/lib# ls -l | grep libstdc++
lrwxrwxrwx 1 root root 23 2009-05-12 11:16 libstdc++.so.5 -> /usr/lib/libstdc++.so.6
lrwxrwxrwx 1 root root 18 2009-05-11 18:32 libstdc++.so.6 -> libstdc++.so.6.0.9
-rw-r–r– 1 root root 970680 2009-02-19 18:42 libstdc++.so.6.0.9

root@wayne-laptop:/usr/lib# aptitude install libstdc++5
root@wayne-laptop:/usr/lib# ln -sf libstdc++.so.5.0.7 libstdc++.so.5
+++++++++++++++++++++++++++++++++++++++++

root@wayne-laptop:/home/oracle/app/10.2.0/db_1/bin# mkdir -p /var/lock/subsys
root@wayne-laptop:/home/oracle/app/10.2.0/db_1/bin# localconfig reset
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 30 seconds.
Checking the status of new Oracle init process…
Expecting the CRS daemons to be up within 600 seconds.

^c

root@wayne-laptop:/home/oracle/app/10.2.0/db_1/bin# nohup /etc/init.d/init.cssd run >/dev/null 2>&1
[1] 17991

创建asm实例

$ dbca -silent -configureASM \
-asmSysPassword change_on_install \
-diskString “/dev/loop*” \
-diskList /dev/loop1 \
-diskGroupName DG1 \
-redundancy EXTERNAL

Categories: Oracle Tags: ,