Oracle 10gR2 下配置簡單ASM例項

lyf625發表於2010-11-10

1. 從Oracle官方網站根據自己的作業系統下載 oracleasmlib 包,oracleasm-support 包 和 oracleasm-

     下載地址:http://www.oracle.com/technology/software/tech/linux/asmlib/rhel4.html

2. 下載完成後以root使用者安裝

[root@localhost ~]# rpm -qa |grep oracleasm
     [root@localhost software]# rpm -Uvh oracleasm-support-2.1.3-1.el4.x86_64.rpm \
> oracleasm-2.6.9-55.ELsmp-2.0.3-1.x86_64.rpm \
> oracleasmlib-2.0.4-1.el4.x86_64.rpm
     Preparing...                ########################################### [100%]
1:oracleasm-support      ########################################### [ 33%]
2:oracleasm-2.6.9-55.ELsm########################################### [ 67%]
3:oracleasmlib           ########################################### [100%]
[root@localhost software]#

3.   以root身份做localconfig 配置

[orarms@localhost bin]$ ./localconfig add
You must be logged in as root to run ./localconfig.
Log in as root and restart ./localconfig execution.
[orarms@localhost bin]$

     [root@localhost ~]# /home/orarms/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 30 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.
localhost
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)

    【附】可以通過crsclt check cssd命令檢查cssd service的狀態是否正常
[orarms@localhost ~]$ crsctl check cssd
CSS appears healthy
[orarms@localhost ~]$

4.   以root身份做oracleasm的配置
     [root@localhost software]# /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 []: orarms
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@localhost software]#

5.   以root身份做新增磁碟和分割槽操作

[root@localhost ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 121601.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id System
/dev/sdb1               1       51200   411263968+ 83 Linux
/dev/sdb2           51201      121601   565496032+ 83 Linux

Command (m for help): d
Partition number (1-4): 1

Command (m for help): d
Selected partition 2

Command (m for help): p

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id System

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-121601, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-121601, default 121601): 10145

Command (m for help): p

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id System
/dev/sdb1               1       10145    81489681   83 Linux

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (10146-121601, default 10146):
Using default value 10146
Last cylinder or +size or +sizeM or +sizeK (10146-121601, default 121601):
Using default value 121601

Command (m for help): p

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id System
/dev/sdb1               1       10145    81489681   83 Linux
/dev/sdb2           10146      121601   895270320   83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#

6. 建立ASM磁碟

[root@localhost software]# /etc/init.d/oracleasm listdisk
Usage: /etc/init.d/oracleasm {start|stop|restart|enable|disable|configure|createdisk|deletedisk|querydisk|listdisks|scandisks|status}
[root@localhost software]# /etc/init.d/oracleasm listdisks
MYVOL1
[root@localhost software]# /etc/init.d/oracleasm deletedisk MYVOL1
Removing ASM disk "MYVOL1": [ OK ]
[root@localhost software]# /etc/init.d/oracleasm listdisks
[root@localhost software]# /etc/init.d/oracleasm createdisk MYVOL1 /dev/sda8
Marking disk "MYVOL1" as an ASM disk: [ OK ]
[root@localhost software]# /etc/init.d/oracleasm createdisk MYVOL2 /dev/sdb2
Marking disk "MYVOL2" as an ASM disk: [ OK ]
[root@localhost software]# /etc/init.d/oracleasm listdisks
MYVOL1
MYVOL2      

【注】oracleasm scandisks 可以用在rac環境下同步ASM磁碟資訊,包含作業系統中獲取的磁碟資訊。       

7. 切換使用者為oracle或者其他安裝了oracle的使用者,本例中為orarms。在$ORACLE_HOME/dbs/下建立+ASM例項的init.ora檔案和密碼檔案

[orarms@localhost ~]$ cd $ORACLE_HOME
[orarms@localhost db_1]$ cd dbs
[orarms@localhost dbs]$ vi init+ASM.ora

*.asm_diskstring='ORCL:MYVOL*'
*.background_dump_dest='/home/orarms/admin/+ASM/bdump'
*.core_dump_dest='/home/orarms/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/home/orarms/admin/+ASM/udump'

[orarms@localhost dbs]$ orapwd file=orapw+ASM password=dba

8.   設定SID,啟動例項,建立磁碟組
[orarms@localhost ~]$ export ORACLE_SID=+ASM
[orarms@localhost dbs]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Sep 8 16:45:00 2009

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

SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ASM instance started

Total System Global Area 130023424 bytes
Fixed Size                  2082208 bytes
Variable Size             102775392 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted

【注】啟動例項的時候出現ORA-15110錯誤非常正常,因為我們還沒有建立diskgroup

SQL> select path,mount_status from v$asm_disk order by disk_number;

     PATH
--------------------------------------------------------------------------------
MOUNT_S
-------
ORCL:MYVOL1
     CLOSED

     ORCL:MYVOL2
     CLOSED

【注】此時查詢 v$asm_disk,可以看到我們之前建立的ASM磁碟MYVOL1和MYVOL2,如果沒有看到,則是設定的asm_diskstring引數不正確,需要調整。

-- 開始建立磁碟組
SQL> create diskgroup diskgrp1 normal redundancy
2     failgroup failgrp1 disk 'ORCL:MYVOL1'
3     failgroup failgrp2 disk 'ORCL:MYVOL2';

Diskgroup created.

SQL> select path,mount_status from v$asm_disk order by disk_number;

PATH
--------------------------------------------------------------------------------
MOUNT_S
-------
ORCL:MYVOL1
     CACHED

ORCL:MYVOL2
     CACHED
【注】建立磁碟組後,再次查詢v$asm_disk檢視,發現ASM磁碟的狀態由closed變成cached    

9. 建立spfile,重啟例項

-- 建立spfile     
SQL> create spfile from pfile;

File created.

SQL> shut immediate
ASM diskgroups dismounted
ASM instance shutdown
SQL> startup
ASM instance started

Total System Global Area 130023424 bytes
Fixed Size                  2082208 bytes
Variable Size             102775392 bytes
ASM Cache                  25165824 bytes
     ORA-15110: no diskgroups mounted
【注】非常奇怪,這個地方有提示沒有磁碟組mounted,決定手動mount看看

SQL> alter diskgroup all mount;
alter diskgroup all mount
*
ERROR at line 1:
ORA-15110: no diskgroups mounted
【注】手動mount失敗,繼續提示沒有磁碟組,參考oracle錯誤資訊,看一下asm的引數設定,發現asm_diskgroups 沒有值,設定上,手動mount成功,再次重啟成功。
ORA-15110: no diskgroups mounted
Cause:          No diskgroups were specified in the ASM_DISKGROUPS parameter, so instance startup or the ALTER DISKGROUP ALL MOUNT command did not mount any diskgroups.

Action:           Specify valid diskgroups in the ASM_DISKGROUPS parameter or ignore the error.


SQL> show parameter asm

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
     asm_diskgroups                       string
asm_diskstring                       string      ORCL:MYVOL*
asm_power_limit                      integer     1
SQL> alter system set asm_diskgroups="diskgrp1" scope=both;

System altered.

SQL> alter diskgroup all mount;

Diskgroup altered.

SQL> shut immediate
ASM diskgroups dismounted
ASM instance shutdown
SQL> startup
ASM instance started

Total System Global Area 130023424 bytes
Fixed Size                  2082208 bytes
Variable Size             102775392 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted
SQL>

至此,ASM簡單例項配置成功,建立使用ASM管理儲存的資料庫就很簡單了,dbca一路下去就ok

下面我在配置ASM出現問題和解決方法:

db_Standby-> export ORACLE_SID=+ASM
db_Standby-> sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Nov 9 12:52:48 2010

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

SQL> conn /as sysdba
Connected to an idle instance.
SQL> 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


SQL>  select path,mount_status from v$asm_disk order by disk_number;

PATH                 MOUNT_S
-------------------- -------
ORCL:VOL1            CLOSED
ORCL:VOL2            CLOSED
ORCL:VOL3            CLOSED
ORCL:VOL4            CLOSED

SQL> show parameter asm


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string
asm_diskstring                       string
asm_power_limit                      integer     1

alter system set asm_diskgroups="DATA" ;

System altered.

SQL> show parameter asm

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string      DATA
asm_diskstring                       string
asm_power_limit                      integer     1
SQL>  alter diskgroup all mount;


Diskgroup altered.

SQL> shut immediate
ASM diskgroups dismounted
ASM instance shutdown
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

 

 

【參考資料】
1. http://www.oracle.com/technology/tech/linux/asmlib/install.html
2. http://www.oracle.com/technology/global/cn/pub/articles/10gdba/week8_10gdba.html
3. http://jackjw.itpub.net/post/602/487507
4. http://blog.csdn.net/wyzxg/archive/2008/03/13/2176517.aspx


 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/13024285/viewspace-677847/,如需轉載,請註明出處,否則將追究法律責任。

相關文章