一
ASM是Oracle
二
ASM它提供了以平台無關的文件系統
ASM是做為單獨的Oracle實例實施和部署
三
四
ASM使用獨特的鏡像算法
三種不同的冗余方式如下
五
ASM實例除了傳統的DBWR
RBAL
ARB
GMON
O
ASMB與ASM 實例的前台進程連接
RBAL用來進行全局調用
CSS集群同步服務
注意
六
七
八
如需了解更詳細信息請參見Oracle數據庫管理員指南(Oracle首次放出)
好了
在上面我們已經探討過了ASM的三種模式
ASM安裝步驟
一
Installation in progress (Mon Apr
Install successful
Linking in progress (Mon Apr
Link successful
Setup in progress (Mon Apr
Setup successful
End of install phases
WARNING:A new inventory has been created in this session
To register the new inventory please run the script
If you do not register the inventory
The following configuration scripts
/oracle/orahome/
need to be executed as root for configuring the system
The installation of Oracle Database
從如上信息我們可以看到數據庫已經安裝完成
[oracle@ db_
LSB Version: :core
Distributor ID: EnterpriseEnterpriseServer
Description: Enterprise Linux Enterprise Linux Server release
Release:
Codename: Carthage
[oracle@ db_
[oracle@ db_
Linux wwl
操作系統版本為
[oracle@ db_
SQL*Plus: Release
Copyright (c)
Connected to an idle instance
SQL>
數據庫版本是
ASM下載地址
l
找到Intel IA
· oracleasm
· 以及如下兩個包下載下來就可以了
· oracleasm
· oracleasmlib
·
[root@wwl asmpark]# ls
oracleasm
oracleasmlib
oracleasm
[root@wwl asmpark]# rpm
warning: oracleasm
Preparing
[root@wwl asmpark]# rpm
warning: oracleasm
Preparing
[root@wwl asmpark]# rpm
warning: oracleasmlib
Preparing
[root@wwl asmpark]#
[root@wwl asmpark]# fdisk
Disk /dev/sda:
Units = cylinders of
Device Boot Start End Blocks Id System
/dev/sda
/dev/sda
Disk /dev/sdb:
Units = cylinders of
Disk /dev/sdb doesn
Disk /dev/sdc:
Units = cylinders of
Disk /dev/sdc doesn
[root@wwl asmpark]#
我們從上圖可以看出系統中有兩塊空閒的磁盤沒有使用
fdisk /dev/sdb /n/p/
fdisk /dev/sdc /n/p/
如下就已經創建好了分區
[root@wwl asmpark]# fdisk
Disk /dev/sda:
Units = cylinders of
Device Boot Start End Blocks Id System
/dev/sda
/dev/sda
Disk /dev/sdb:
Units = cylinders of
Device Boot Start End Blocks Id System
/dev/sdb
Disk /dev/sdc:
Units = cylinders of
Device Boot Start End Blocks Id System
/dev/sdc
二
以上已將准備環境准備好
開始創建ASM實例
在使用ASM之前首先要配置ASMLib驅動程序
我們首先可以看下asm的配置工具 oracleasm的語法和功能
[root@wwl asmpark]# /etc/init
Usage: /etc/init
[root@wwl asmpark]#
[root@wwl asmpark]# /etc/init
Configuring the Oracle ASM library driver
This will configure the on
driver
loaded on boot and what permissions it will have
will be shown in brackets (
answer will keep that current value
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@wwl asmpark]# /etc/init
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [ OK ]
Scanning the system for Oracle ASMLib disks: [ OK ]
[root@wwl asmpark]# /etc/init
Marking disk
[root@wwl asmpark]# /etc/init
Marking disk
[root@wwl asmpark]#
[root@wwl asmpark]# oracleasm querydisk VOL
Disk
[root@wwl asmpark]# oracleasm querydisk /dev/sdb
Device
[root@wwl asmpark]# oracleasm querydisk VOL
Disk
[root@wwl ~]# oracleasm querydisk /dev/sdc
Device
[root@wwl asmpark]# oracleasm listdisks
VOL
VOL
[root@wwl asmpark]# ls
brw
brw
[root@wwl asmpark]# oracleasm status
Checking if ASM is loaded: yes
Checking if /dev/oracleasm is mounted: yes
[oracle@ dbs]$ vi $ORACLE_HOME/dbs/init$ORACLE_SID
asm_diskstring=
background_dump_dest=
core_dump_dest=
user_dump_dest=
instance_type=
large_pool_size=
remote_login_passwordfile=
$ vi /etc/oratab
+ASM:/u
[oracle@ dbs]$ $ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=
[oracle@ dbs]$
[oracle@ dbs]$ mkdir
[oracle@ dbs]$ mkdir
[oracle@ dbs]$ mkdir
[oracle@ dbs]$
$ su
[root@wwl ~]# /oracle/orahome/
/etc/oracle does not exist
Successfully accumulated necessary OCR keys
Creating OCR keys for user
Operation successful
Configuration for local CSS has been initialized
Adding to inittab
Startup will be queued to init within
Checking the status of new Oracle init process
Expecting the CRS daemons to be up within
CSS is active on these nodes
wwl
CSS is active on all nodes
Oracle CSS service is installed and running under init(
[oracle@ dbs]$ sqlplus / as sysdba
SQL*Plus: Release
Copyright (c)
Connected to:
Oracle Database
With the Partitioning
SQL> startup nomount;
ASM instance started
Total System Global Area
Fixed Size
Variable Size
ASM Cache
SQL> select instance_name
INSTANCE_NAME STATUS
+ASM STARTED
SQL>
現在實例我已經將其啟動到nomount狀態
SQL> create diskgroup ASMGROUP
Diskgroup created
好了
SQL> select name
NAME STATE
ASMGROUP
SQL>
可以看到如下
SQL> show parameter asm_diskgroups;
NAME TYPE VALUE
asm_diskgroups string ASMGROUP
[oracle@ ~]$ ps
oracle
oracle
oracle
oracle
oracle
oracle
oracle
oracle
oracle
一
二
SQL>select file_name
FILE_NAME TABLESPACE_NAME
+ASMGROUP
+ASMGROUP
+ASMGROUP
+ASMGROUP
SQL>
我們由如上可以看出
如下通過OMF方式創建表空間和添加數據文件的方式
SQL> show parameter db_create_file_dest
NAME TYPE VALUE
db_create_file_dest string +ASMGROUP
SQL> create tablespace asm;
Tablespace created
SQL> alter tablespace asm add datafile;
Tablespace altered
通過如下
SQL> selectFILE_NAME
FILE_NAME TABLESPACE_NAMEBYTES/
+ASMGROUP
+ASMGROUP
SQL> alter system set db_create_file_dest=
System altered
一
ASM實例的管理
ASM實例的啟動和數據庫實例的啟動有嚴格的先後關系
SQL>startup
ORA
ORA
ORA
ORA
SQL>
SQL>startup
ASMinstance started
TotalSystem Global Area
FixedSize
VariableSize
ASMCache
ASMdiskgroups mounted
SQL>select instance_name
INSTANCE_NAME STATUS
+ASM STARTED
SQL>
沒有關閉RDBMS實例關閉ASM將報錯ORA
$ export Oracle_SID=+ASM
$ sqlplus / as sysdba
SQL> shutdown immediate
ORA
關閉RDBMS實例狀態ASM是可以正常關閉的
$export ORACLE_SID=WWL
$sqlplus / as sysdba
SQL> shutdown immediate
Database closed
Database dismounted
ORACLE instance shut down
SQL>
$export ORACLE_SID=+ASM
$ sqlplus / as sysdba
SQL> shutdown immediate
ASM diskgroups dismounted
ASM instance shutdown
SQL>
二
# oracleasm listdisks
VOL
VOL
# oracleasm querydisk VOL
Disk
# oracleasm querydisk VOL
Disk
# ls
brw
brw
# oracleasm status
Checking if ASMis loaded: yes
Checking if /dev/oracleasm is mounted: yes
我們已知數據庫當有兩塊通過ASMLiB已經標記了的磁盤
l 報錯了
# /etc/init
Marking disk
l 先創建分區方法:fdisk /dev/sdd /n/p/
# /etc/init
Marking disk
# sh oracleasm 通過執行腳本命令
Marking disk
Marking disk
Marking disk
Marking disk
Marking disk
Marking disk
Marking disk
Marking disk
Marking disk
l 查看磁盤組的狀態
SQL> selectGROUP_NUMBER
GROUP_NUMBER NAME STATE TYPE
SQL> SELECT a
GRPNAME GR_NUMBER DK_NUMBER ASMFILE PATH MOUNT_S STATE
ASMGROUP
ASMGROUP
l 查看磁盤組ASMGROUP
SQL> selectgroup_number
GROUP_NUMBERDISK_NUMBER FAILGROUP NAME PATH
SQL>
l 添加為ASMGROUP
SQL> alterdiskgroup ASMGROUP
Diskgroupaltered
l 我們可以看到已經添加成功了
SQL> select group_number
GROUP_NUMBERDISK_NUMBER FAILGROUP NAME PATH
SQL> create diskgroup asmhigh high redundancy disk
Diskgroupcreated
SQL> creatediskgroup asmnormal normal redundancy disk
Diskgroupcreated
SQL> creatediskgroup asmexternal external redundancy disk
Diskgroupcreated
SQL> select name
NAME STATE TYPE
ASMGROUP
ASMHIGH MOUNTED HIGH
ASMNORMAL MOUNTED NORMAL
ASMEXTERNAL MOUNTED EXTERN
SQL> alter diskgroup ASMNORMAL add disk
Diskgroup altered
SQL> select group_number
GROUP_NUMBER DISK_NUMBER FAILGROUP NAME PATH
SQL>
SQL> alter diskgroup ASMNORMAL drop disk ASMNORMAL_
Diskgroup altered
SQL> select group_number
GROUP_NUMBER DISK_NUMBER FAILGROUP NAME PATH
SQL>
三
SQL> selecttablespace_name
TABLESPACE_NAMEFILE_NAME M
USERS +ASMGROUP
SYSAUX +ASMGROUP
UNDOTBS
SYSTEM +ASMGROUP
ASM +ASMGROUP
ASM +ASMGROUP
如上我們可以看到
SQL> selectusername
USERNAME DEFAULT_TABLESPACE
WWL ASM
通過WWL用戶登錄到系統創建一張表
SQL> connwwl/wwl
Connected
SQL> createtable wwl (id varchar(
Table created
SQL> begin
PL/SQLprocedure successfully completed
我們創建了一張wwl的表
SQL> selectcount(*) from wwl;
COUNT(*)
[root@wwl ~]#oracleasm deletedisk VOL
Clearing diskheader: done
Dropping disk:done
[root@wwl ~]#
仔細看下面
SQL> selectgroup_number
GROUP_NUMBERDISK_NUMBER FAILGROUP NAME PATH
SQL>
但是我們的實例和我們剛才創建的表數據都沒有丟失
SQL> selectcount(*) from wwl;
COUNT(*)
ASM日志信息如下
WARNING:offlining disk
NOTE: PSTupdate: grp =
NOTE: cacheclosing disk
NOTE: PSTupdate: grp =
NOTE: erasingheader on grp
四
別名就是外號
SQL> alter diskgroup ASMGROUP
Diskgroup altered
SQL> alter diskgroup ASMGROUP
Diskgroup altered
SQL> alter diskgroup ASMGROUP
Diskgroup altered
無論是添加
五
SQL> alter diskgroup ASMGROUP
Diskgroupaltered
SQL> alterdiskgroup ASMGROUP
Diskgroupaltered
SQL> alter diskgroup ASMGROUP
Diskgroupaltered
六
一般情況下ASM都會自動對其下的磁盤組進行平衡
SQL>alter diskgroup asmgroup
Diskgroup altered
七
[oracle@wwl ~]$ which asmcmd
/oracle/orahome/
[oracle@wwl ~]$ cd/oracle/orahome/
ASMCMD> ls
ASMEXTERNAL/
ASMGROUP
ASMHIGH/
ASMNORMAL/
ASMCMD>
ASMCMD> help
asmcmd [
The environment variables ORACLE_HOME and ORACLE_SID determine the
instance to which the program connects
bequeath connection to it
SYSDBA
Specifying the
in the command prompt
ASMCMD [+DATAFILE/ORCL/CONTROLFILE] >
[command] specifies one of the following commands
parameters
Type
commands:
cd
du
find
help
ls
lsct
lsdg
mkalias
mkdir
pwd
rm
rmalias
ASMCMD>
要查看某個命令的相信通過在命令前添加help來查看
ASMCMD> help cd
cd <dir>
Change the current directory to <dir>
ASMCMD> help du
du [
Display total space used for files located recursively under [dir]
similar to
values are returned
not take into account mirroring of the diskgroup while the second does
For instance
takes up
of space on a high redundancy diskgroup
[dir] can also contain wildcards
The
ASMCMD> help find
find [
Find the absolute paths of all occurrences of <pattern> under<dir>
<pattern> can be a directory and may include wildcards
include wildcards
The
search for all the control files at once
valid values in V$ASM_FILE
ASMCMD>
八
[root@wwl ~]# oracleasm
Usage: oracleasm[
oracleasm
oracleasm
oracleasm
The basic oracleasm commands are:
configure Configure the OracleLinux ASMLib driver
init Load andinitialize the ASMLib driver
exit Stop the ASMLibdriver
scandisks Scan the systemfor Oracle ASMLib disks
status Display thestatus of the Oracle ASMLib driver
listdisks List known OracleASMLib disks
querydisk Determine if adisk belongs to Oracle ASMlib
createdisk Allocate a devicefor Oracle ASMLib use
deletedisk Return a deviceto the operating system
renamedisk Change the labelof an Oracle ASMlib disk
update
[root@wwl ~]#
九
ASM由於其高度的封裝性
相關視圖和數據字典
View Name
X$ Table name
Description
V$ASM_DISKGROUP
X$KFGRP
performs disk discovery and lists diskgroups
V$ASM_DISKGROUP_STAT
X$KFGRP_STAT
diskgroup stats without disk discovery
V$ASM_DISK
X$KFDSK
performs disk discovery
V$ASM_DISK_STAT
X$KFDSK_STAT
lists disks and their usage metrics
V$ASM_FILE
X$KFFIL
lists ASM files
V$ASM_ALIAS
X$KFALS
lists ASM aliases
V$ASM_TEMPLATE
X$KFTMTA
lists the available templates and their properties
V$ASM_CLIENT
X$KFNCL
lists DB instances connected to ASM
V$ASM_OPERATION
X$KFGMG
lists rebalancing operations
N
X$KFKLIB
available libraries
N
X$KFDPARTNER
lists disk
N
X$KFFXP
extent map table for all ASM files
N
X$KFDAT
extent list for all ASM disks
N
X$KFBH
describes the ASM cache (buffer cache of ASM in blocks of
N
X$KFCCE
a linked list of ASM blocks
This list isobtained querying v$fixed_view_definitionwhere view_name like
SQL>select* fromv$fixed_view_definition whereview_name like
SQL>select* from sys
十
錯誤一
ORA
解決辦法
發生這個問題
錯誤二
[root@wwl ~]# /etc/init
Marking disk
報這個錯的原因在於磁盤為分區導致
十一
最多支持
十二
From:http://tw.wingwit.com/Article/program/Oracle/201405/30855.html