Академический Документы
Профессиональный Документы
Культура Документы
Every time I work with Oracle RAC, I had to refer Google to get
What you are about to see are the commands not only used by
me but are also used by my students in real-time.
Let’s Start ;)
$ export ORACLE_SID=+ASM
$ sqlplus "/ as sysdba"
SQL> 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
$ export ORACLE_SID=+ASM
$ sqlplus "/ as sysdba"
shutdown immediate
Adding Diskgroup:
Drop a diskgroup
Disks can be added or removed from disk groups using the ALTER DISKGROUP statement.
Remember that the wildcard "*" can be used to reference disks so long as the resulting
string does not match a disk already used by an existing disk group.
-- Add disks.
ALTER DISKGROUP disk_group_1 ADD DISK
'/devices/disk*3',
'/devices/disk*4';
-- Drop a disk.
ALTER DISKGROUP disk_group_1 DROP DISK diska2;
Resizing disks
Disks can be resized using the RESIZE clause of the ALTER DISKGROUP statement. The
statement can be used to resize individual disks, all disks in a failure group or all disks in the
disk group. If the SIZE clause is omitted the disks are resized to the size of the disk returned
by the OS.
Disk groups are mounted at ASM instance startup and unmounted at ASM instance
shutdown. Manual mounting and dismounting can be accomplished using the ALTER
DISKGROUP statement as seen below.
Files are not deleted automatically if they are created using aliases, as they are not Oracle
Managed Files (OMF), or if a recovery is done to a point-in-time before the file was created.
For these circumstances it is necessary to manually delete the files, as shown below.
Checking Metadata
The internal consistency of disk group metadata can be checked in a number of ways using
the CHECK clause of the ALTER DISKGROUP statement.
Rebalancing
Ensure the database is using an SPFILE and not a PFILE (it's about time after all!). Set
parameters on the target database. For example, if we set both DB_CREATE_FILE_DEST
and DB_RECOVERY_FILE_DEST we should get mirrored controlfiles and duplexed log files
by default:
Start the database in NOMOUNT mode and restore the controlfile into the new location from
the old location:
Mount the database and copy the database into the ASM disk group:
Switch all datafiles to the new ASM location and open the database:
connect target;
sql "alter tablespace TSNAME offline";
backup as copy tablespace TSNAME format '+DATA';
switch tablespace TSNAME to copy;
sql "alter tablespace TSNAME online";
exit;
connect target;
sql "alter database datafile '...' offline";
backup as copy datafile '...' format '+DATA';
switch datafile '..' to copy;
sql "alter database datafile '...' online";
exit;
V$ASM_ALIAS Displays a row for each alias present in every disk group
mounted by the ASM instance.
V$ASM_CLIENT Displays a row for each database instance using a disk group
managed by the ASM instance.
V$ASM_DISK Displays a row for each disk discovered by the ASM instance,
including disks which are not part of any disk group.
V$ASM_DISKGROUP Displays a row for each disk group discovered by the ASM
instance.
V$ASM_FILE Displays a row for each file for each disk group mounted by the
ASM instance.
V$ASM_OPERATION Displays a row for each file for each long running operation
executing in the ASM instance.
V$ASM_TEMPLATE Displays a row for each template present in each disk group
mounted by the ASM instance.
ASM Filenames
There are several ways to reference ASM file. Some forms are used during creation
and some for referencing ASM files.
The ASM Command Line Utility can be started by executing the asmcmd command. Here is
a Linux/Unix example:
$ export ORACLE_SID=+ASM
$ cd $ORACLE_HOME/bin
$ asmcmd
ASMCMD> exit
The asmcmd utility also provides a useful "-p" option that will display the current path in the
prompt. Here is an example:
$ asmcmd -p
ASMCMD [+] > cd FLASH
ASMCMD [+FLASH] >
cd command
pwd command
help command
If you do not specify a value for command, then the help command lists all of the ASMCMD
commands and general information about using the ASMCMD utility.
ASMCMD> help
ASMCMD> help lsct
ASMCMD> ?
du command
Displays the total space used for files in the specified directory and in the entire directory
tree under the directory.
ASMCMD [+dgroup1/prod] > du
Used_MB Mirror_used_MB
1251 2507
find command
Displays the absolute paths of all occurrences of the specified name pattern (can have
wildcards) in a specified directory and its subdirectories.
ls command
How do you know how many databases are using an ASM instance?
rm command
chown command
mount command
Will mount the specified diskgroups. This operation mounts one or more diskgroups.
ASMCMD [+] > mount -f data
ASMCMD [+] > mount --restrict data
ASMCMD [+] > mount -a
umount command
The first example dismounts all diskgroups mounted on the Oracle ASM instance.
ASMCMD [+] > umount -a
The second example forces the dismount of the data disk group.
ASMCMD [+] > umount -f data
In the upcoming days I will be sending you Oracle RAC Tips that you
must be aware of as an Oracle RAC DBA!