Sie sind auf Seite 1von 13

ASM

ASM Diskgroups
Create Diskgroup
CREATE DISKGROUP disk_group_1 NORMAL
REDUNDANCY
FAILGROUP failure_group_1 DISK
'/devices/diska1' NAME diska1,
'/devices/diska2' NAME diska2,
FAILGROUP failure_group_2 DISK
'/devices/diskb1' NAME diskb1,
'/devices/diskb2' NAME diskb2;

NOTE : The above disk group given as NORMAL redundancy, that means it contain 2 Fail groups (i.e.,
2 sets of each data is maintained) also similarly for EXTERNAL redundancy each data is made into
thrice(1 original and 2 duplicates) so it makes 3 fail groups in Disk group
Drop disk groups
DROP DISKGROUP DATA INCLUDING CONTENTS;

Add disks
ALTER DISKGROUP DATA ADD DISK '/dev/sda3';

Drop a disk
ALTER DISKGROUP DATA DROP DISK DATA_0001;

Resize all disks in a disk group


ALTER DISKGROUP DATA RESIZE ALL SIZE 100G;

UNDROP DISKS clause of the ALTER DISKGROUP

ALTER DISKGROUP DATA UNDROP DISKS;

Rebalance diskgroup
ALTER DISKGROUP DATA REBALANCE POWER 5;

Check Diskgroup
ALTER DISKGROUP DATA CHECK;
ALTER DISKGROUP DATA CHECK NOREPAIR;

Diskgroup Metadata Backup


md_backup -b asm_backup.mdb.txt -g data,fra

ASM Specific Init.ora Parameters


*.cluster_database=true
*.asm_diskstring='/dev/sd*1'
*.instance_type=asm
*.shared_pool_size=100M
*.large_pool_size=80M
*.db_cache_size=60M
*.asm_diskgroups='DATA','FRA'

Initialize ASM for non-RAC


./localconfig add

Manually start CSSD (non-RAC)


/etc/init.d/init.cssd start

Manually stop CSSD ( non-RAC)


/etc/init.d/init.cssd stop

Resetting CSS to new Oracle Home


localconfig reset /apps/oracle/product/11.1.0/ASM

ASM Dictionary Views


v$asm_alias ---list all aliases in all currently mounted diskgroups
v$asm_client ---list all the databases currently accessing the diskgroups
v$asm_disk ----lists all the disks discovered by the ASM instance.
v$asm_diskgroup ---Lists all the diskgroups discovered by the ASM instance.
v$asm_file ---Lists all files that belong to diskgroups mounted by the ASM instance.
v$asm_operation ---Reports information about current active operations. Rebalance activity is
reported in this view.
v$asm_template ---Lists all the templates currently mounted by the ASM instance.
v$asm_diskgroup_stat ---same as v$asm_diskgroup but does discover new disgroups. Use this
view instead of v$asm_diskgroup.
v$asm_disk_stat ---same as v$asm_disk but does not discover new disks. Use this view instead of
v$asm_disk.

srvctl commands
ADD
srvctl add asm -n rac3 -i +ASM3 -o /opt/oracle/app/product/10.2.0/asm

ENABLE
srvctl enable asm -n rac3 -i +ASM3

DISABLE
srvctl disable asm -n rac3 -i +ASM3

START
srvctl start asm -n rac3

STOP
srvctl stop asm -n rac3

CONFIG
srvctl config asm -n rac1

REMOVE
srvctl remove asm -n rac1
STATUS
srvctl status asm
srvctl status asm -n rac1

MODIFY
srvctl modify asm -o -n rac1

ASMLIB commands ( as root)


/etc/init.d/oracleasm start
/etc/init.d/oracleasm stop
/etc/init.d/oracleasm restart
/etc/init.d/oracleasm configure
/etc/init.d/oracleasm status
/etc/init.d/oracleasm enable
/etc/init.d/oracleasm disable
/etc/init.d/oracleasm listdisks
/etc/init.d/oracleasm deletedisk
/etc/init.d/oracleasm scandisks
/etc/init.d/oracleasm querydisk /dev/sdb1
/etc/init.d/oracleasm createdisk /dev/sdb1 VOL1

/etc/init.d/oracleasm renamedisk /dev/sdb1 VOL1

asmcmd Commands
cd -----changes the current directory to the specified directory
du -----Displays the total disk space occupied by ASM files in the specified
ASM directory and all its subdirectories, recursively.
find -----Lists the paths of all occurrences of the specified name ( with wildcards) under the specified
directory.
ls +data/testdb ----Lists the contents of an ASM director, the attributes of the specified file, or the
names and attributes of all disk groups.
lsct -----Lists information about current ASM clients.
lsdg ----Lists all disk groups and their attributes
mkalias ----Creates an alias for a system generated filename.
mkdir -----Creates ASM directories.
pwd --------Displays the path of the current ASM directory.
rm

-------Deletes the specified ASM Files or directories.

rm -f
rmalias ---------Deletes the specified alias, retaining the file that the alias points to
lsdsk ----------Lists disks visible to ASM.
md_backup ------Creates a backup of all of the mounted disk groups.
md_restore ------Restores disk groups from a backup.
remap ----repairs a range of physical blocks on a disk.
cp ------copies files into and out of ASM.

SYSASM Role (Starting in Oracle Database 11g)


SQL> Grant sysasm to sys; ---sysdba deprecated sqlplus / as sysasm

ASM Rolling Upgrades START


alter system start rolling migration to 11.2.0.2;

DISABLE
alter system stop rolling migration;

Database INIT parameters for ASM.


*.control_files='+DATA/orcl/controlfile/control1.ctl','+FRA/orcl/controlfile/control2.ctl'
*.db_create_file_dest='+DATA'
*.db_create_online_log_dest_1='+DATA'
*.db_recovery_file_dest='+DATA'
*.log_archive_dest_1='LOCATION=+DATA'
*.log_file_name_convert='+DATA/VISKDR','+DATA/VISK' ##added for DG

Removing disks from an ASM disk group

1 select group_number,name from v$asm_disk


2* order by group_number,name
SQL> /
GROUP_NUMBER NAME
------------ -----------------------------1 ASM_ORADATA31_0000
1 ASM_ORADATA31_0001
1 ASM_ORADATA31_0002
1 ASM_ORADATA31_0003
1 ASM_ORADATA31_0004
1 ASM_ORADATA31_0005
2 ASM_ORADATA32_0000
2 ASM_ORADATA32_0001
2 ASM_ORADATA32_0002
2 ASM_ORADATA32_0003
2 ASM_ORADATA32_0004
2 ASM_ORADATA32_0005
12 rows selected.
SQL> ALTER DISKGROUP ASM_ORADATA31 DROP DISK ASM_ORADATA31_0005;
Diskgroup altered.

SQL> ALTER DISKGROUP ASM_ORADATA32 DROP DISK ASM_ORADATA32_0005;


Diskgroup altered.
SQL> select est_minutes from V$ASM_OPERATION;
EST_MINUTES
----------6

MIGRATE to ASM using RMAN


run
{
backup as copy database format '+DATA';
switch database to copy;
#For each logfile
sql "alter database rename '/data/oracle/VISK/redo1a.rdo' to '+DATA' ";
alter database open resetlogs;
#For each tempfile
sql "alter tablespace TEMP add tempfile" ;
}
Restore Database to ASM using SET NEWNAME
run
{
allocate channel d1 type disk;
#For each datafile
set newname for datafile 1 to '+DATA';
restore database;
switch datafile all;
release channel d1;
}

Migrate From Database File system to ASM

TO MIGRATE the database files from disk to ASM disk is as follows:

1.
2.
3.
4.
5.
6.

Configure flash recovery area.


Migrate datafiles to ASM.
Control file to ASM.
Create Temporary tablespace.
Migrate Redo logfiles
Migrate spfile to ASM.

Step 1:

Configure flash recovery area.

SQL> connect sys/sys@prod1 as sysdba


Connected.

SQL> alter database disable block change tracking;


Database altered.
SQL> alter system set db_recovery_file_dest_size=500m;
System altered.
SQL> alter system set db_recovery_file_dest=+RECOVERYDEST;
System altered

Step 2 and 3: Migrate data files and control file to ASM.


Use RMAN to migrate the data files to ASM disk groups.
All data files will be migrated to the newly created disk group, DATA
SQL> alter system set db_create_file_dest='+DATA';
System altered.
SQL> alter system set control_files='+DATA/ctf1.dbf' scope=spfile;
System altered.
SQL> shut immediate
[oracle@rac1 bin]$ ./rman target /

RMAN> startup nomount

Oracle instance started


RMAN> restore controlfile from '/u01/new/oracle/oradata/mydb/control01.ctl';
Starting restore at 08-DEC-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=146 device type=DISK
channel ORA_DISK_1: copied control file copy
output file name=+DATA/ctf1.dbf
Finished restore at 08-DEC-09
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> backup as copy database format '+DATA';
Starting backup at 08-DEC-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=146 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/new/oracle/oradata/mydb/system01.dbf
output file name=+DATA/mydb/datafile/system.257.705063763 tag=TAG20091208T110241 RECID=1
STAMP=705064274
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:08:39
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/new/oracle/oradata/mydb/sysaux01.dbf
output file name=+DATA/mydb/datafile/sysaux.258.705064283 tag=TAG20091208T110241 RECID=2
STAMP=705064812
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:08:56
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/new/oracle/oradata/mydb/undotbs01.dbf
output file name=+DATA/mydb/datafile/undotbs1.259.705064821 tag=TAG20091208T110241
RECID=3 STAMP=705064897
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:25
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=+DATA/mydb/controlfile/backup.260.705064907 tag=TAG20091208T110241
RECID=4 STAMP=705064912
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/new/oracle/oradata/mydb/users01.dbf
output file name=+DATA/mydb/datafile/users.261.705064915 tag=TAG20091208T110241 RECID=5
STAMP=705064915
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 08-DEC-09
channel ORA_DISK_1: finished piece 1 at 08-DEC-09
piece handle=+DATA/mydb/backupset/2009_12_08/nnsnf0_tag20091208t110241_0.262.705064919
tag=TAG20091208T110241 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01


Finished backup at 08-DEC-09
RMAN> switch database to copy;
datafile
datafile
datafile
datafile

1
2
3
4

switched
switched
switched
switched

to
to
to
to

datafile
datafile
datafile
datafile

copy
copy
copy
copy

"+DATA/mydb/datafile/system.257.705063763"
"+DATA/mydb/datafile/sysaux.258.705064283"
"+DATA/mydb/datafile/undotbs1.259.705064821"
"+DATA/mydb/datafile/users.261.705064915"

RMAN> alter database open;


database opened
RMAN> exit
Recovery Manager complete.
SQL> conn sys/oracle as sysdba
Connected.
SQL> select tablespace_name,file_name from dba_data_files;
TABLESPACE_NAME
FILE_NAME
------------------------------ --------------------------------------------USERS

+DATA/mydb/datafile/users.261.705064915

UNDOTBS1

+DATA/mydb/datafile/undotbs1.259.705064821

SYSAUX

+DATA/mydb/datafile/sysaux.258.705064283

SYSTEM

+DATA/mydb/datafile/system.257.705063763

SQL> select name from v$controlfile;

NAME
-------+DATA/ctf1.dbf

Step 4: Migrate temp tablespace to ASM.


SQL> alter tablespace temp add tempfile size 100m;
Tablespace altered.
SQL> select file_name from dba_temp_files;

FILE_NAME
--------------------------------------------+DATA/mydb/tempfile/temp.263.705065455
otherwise,
Create temporary tablespace in ASM disk group.
SQL> CREATE TABLESPACE temp1 ADD TEMPFILE +diskgroup1;

Step 5: Migrate redo logs to ASM.


SQL> select member,group# from v$logfile;
MEMBER

GROUP#

-------------------------------------------------- ---------/u01/new/oracle/oradata/mydb/redo03.log

/u01/new/oracle/oradata/mydb/redo02.log

/u01/new/oracle/oradata/mydb/redo01.log

SQL> alter database add logfile group 4 size 5m;


Database altered.
SQL> alter database add logfile group 5 size 5m;
Database altered.
SQL> alter database add logfile group 6 size 5m;
Database altered.
SQL> select member,group# from v$logfile;
MEMBER
--------------------------------------------------

GROUP#
----------

/u01/new/oracle/oradata/mydb/redo03.log

/u01/new/oracle/oradata/mydb/redo02.log

/u01/new/oracle/oradata/mydb/redo01.log

+DATA/mydb/onlinelog/group_4.264.705065691

+DATA/mydb/onlinelog/group_5.265.705065703

+DATA/mydb/onlinelog/group_6.266.705065719

SQL> alter system switch logfile;


System altered.
SQL> alter database drop logfile group 2;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL> alter database drop logfile group 4;
Database altered.
SQL> alter database drop logfile group 1;
Database altered.

Add additional control file.

If an additional control file is required for redundancy, you can create it in ASM as you would on any
other filesystem.
SQL> connect sys/sys@prod1 as sysdba
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
SQL> alter database backup controlfile to '+DATA/cf2.dbf';
Database altered.
SQL> alter system set control_files='+DATA/cf1.dbf ','+DATA/cf2.dbf' scope=spfile;
System altered.
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

SQL> startup

ORACLE instance started.


SQL> select name from v$controlfile;
NAME
--------------------------------------+DATA/cf1.dbf
+DATA/cf2.dbf
step 6:Migrate spfile to ASM:
Create a copy of the SPFILE in the ASM disk group.
In this example, the SPFILE for the migrated database will be stored as +DISK/spfile.
If the database is using an SPFILE already, then run these commands:
run {
BACKUP AS BACKUPSET SPFILE;
RESTORE SPFILE TO "+DISK/spfile";
}
If you are not using an SPFILE, then use CREATE SPFILE from SQL*Plus to create the new SPFILE in
ASM.
For example, if your parameter file is called /private/init.ora, use the following command:
SQL> create spfile='+DISK/spfile' from pfile='/private/init.ora';
NOTE:
After successfully migrating all the data files over to ASM, the old data files are no longer
needed and can be removed. Your single-instance database is now running on ASM

Das könnte Ihnen auch gefallen