探索ORACLE之ASM02_安裝

wuweilong發表於2012-04-09

探索ORACLEASM02_安裝

作者:吳偉龍

 

好了,現在開始談談有關於ASM安裝的相關內容,ASM的安裝必須建立在作業系統和資料庫軟體已經安裝完成的及例項未建立之前來進行安裝,之後再進行選擇ASM方式建庫。ASM不僅可以應用於單例項的資料庫,同時更適用於RAC叢集方式的資料庫,並且ASM只被ORACLE所認,同時也是ORACLE最佳的儲存解決方案,可以有效的替代RAID技術和卷管理技術,比裸裝置的管理更加方便;所以現在大部分企業都在迅速的向ASM技術遷移。

在上一篇中我們已經探討過了ASM的三種模式,及其的一些應用,在這裡我們就不對其進行過多的累述。正式進入這篇的主題,如何安裝ASM軟體,安裝ASM需要具備哪些條件。

 

ASM安裝步驟:

一、基礎環境準備

1、  檢查作業系統和資料庫軟體是否安裝完成:

 

Installation in progress (Mon Apr 09 19:12:44 CST 2012)

...............................................................  18% Done.

...............................................................  36% Done.

...............................................................  54% Done.

...............................................................  73% Done.

............                                                     76% Done.

Install successful

 

Linking in progress (Mon Apr 09 19:19:34 CST 2012)

Link successful

 

Setup in progress (Mon Apr 09 19:23:13 CST 2012)

..............                                                  100% Done.

Setup successful

 

End of install phases.(Mon Apr 09 19:23:26 CST 2012)

WARNING:A new inventory has been created in this session. However, it has not yet been registered as the central inventory of this system.

To register the new inventory please run the script. '/oracle/oraInventory/orainstRoot.sh' with root privileges.

If you do not register the inventory, you may not be able to update or patch the products you installed.

 

The following configuration scripts

/oracle/orahome/10.2.0/db_1/root.sh

need to be executed as root for configuring the system. If you skip the execution of the configuration tools, the configuration will not be complete and the product wont function properly. In order to get the product to function properly, you will be required to execute the scripts and the configuration tools after exiting the OUI.

 

The installation of Oracle Database 10g was successful.

 

從如上資訊我們可以看到資料庫已經安裝完成,作業系統肯定也是沒有問題的。

 

 

2、  檢查資料庫和作業系統版本:

[oracle@wwl db_1]$ lsb_release -a

LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch

Distributor ID: EnterpriseEnterpriseServer

Description:    Enterprise Linux Enterprise Linux Server release 5.4 (Carthage)

Release:        5.4

Codename:       Carthage

[oracle@wwl db_1]$

 

[oracle@wwl db_1]$ uname -a

Linux wwl 2.6.18-164.el5 #1 SMP Thu Sep 3 02:16:47 EDT 2009 i686 i686 i386 GNU/Linux

作業系統版本為5.4 X86,核心版本為2.6.18-164.el5,後面下載ASM包必須要對應

 

 

[oracle@wwl db_1]$ sqlplus / as sysdba

 

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Apr 9 19:41:54 2012

 

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

 

Connected to an idle instance.

 

SQL>

 

資料庫版本是10.2.0.1.

 

 

3、  我們已經知道了這些資訊後,我們就可以有針對性的下載ASM:

 

ASM下載地址,版本不一樣,用的ASM包也不一樣

 

找到Intel IA32 (x86) Architecture系列中的這個包下載下來:

Drivers for kernel 2.6.18-164.el5

·        

·         以及如下兩個包下載下來就可以了:

Library and Tools

·        

·        

·          

 

4、  下載完了之後開始安裝asmrpm包,root使用者安裝,注意安裝順序,如下:

 

[root@wwl asmpark]# ls

oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm

oracleasmlib-2.0.4-1.el5.i386.rpm

oracleasm-support-2.1.7-1.el5.i386.rpm

[root@wwl asmpark]# rpm -ivh oracleasm-support-2.1.7-1.el5.i386.rpm

warning: oracleasm-support-2.1.7-1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159

Preparing...                ########################################### [100%]

   1:oracleasm-support      ########################################### [100%]

[root@wwl asmpark]# rpm -ivh oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm

warning: oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159

Preparing...                ########################################### [100%]

   1:oracleasm-2.6.18-164.el########################################### [100%]

[root@wwl asmpark]# rpm -ivh oracleasmlib-2.0.4-1.el5.i386.rpm

warning: oracleasmlib-2.0.4-1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159

Preparing...                ########################################### [100%]

   1:oracleasmlib           ########################################### [100%]

[root@wwl asmpark]#

 

 

5、  好了,現在ASM相關包已經安裝完成,現在來開始建立用於ASM的磁碟分割槽(不是一定要做,裸盤也可以做ASM

 

[root@wwl asmpark]# fdisk -l

 

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        1958    15623212+  8e  Linux LVM

 

Disk /dev/sdb: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdb doesn't contain a valid partition table

 

Disk /dev/sdc: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdc doesn't contain a valid partition table

[root@wwl asmpark]#

 

我們從上圖可以看出系統中有兩塊空閒的磁碟沒有使用,我們首先需要對磁碟建立分割槽,但不能格式化,命令如下:

fdisk /dev/sdb /n/p/1/回車/回車/w

fdisk /dev/sdc /n/p/1/回車/回車/w

 

如下就已經建立好了分割槽:

 

[root@wwl asmpark]# fdisk -l

 

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        1958    15623212+  8e  Linux LVM

 

Disk /dev/sdb: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        1305    10482381   83  Linux

 

Disk /dev/sdc: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1        1305    10482381   83  Linux

 

 

二、ASM配置

以上已將準備環境準備好,下一步驟就是開始配置了,這裡面配置包括如下幾個步驟

開始建立ASM例項,建立ASM例項的方式有兩種,一種是透過命令列,還有一種是透過圖形介面,執行DBCA後有一步是建立ASM例項,圖形介面實在太簡單了,跟建立DB是一樣的,在這裡就不累贅了。

 

在使用ASM之前首先要配置ASMLib驅動程式,如下:

 

我們首先可以看下asm的配置工具 oracleasm的語法和功能,如下:

 [root@wwl asmpark]# /etc/init.d/oracleasm --help

Usage: /etc/init.d/oracleasm {start|stop|restart|enable|disable|configure|createdisk|deletedisk|querydisk|listdisks|scandisks|status}

[root@wwl asmpark]#

 

1、開始配置ASMLib

 [root@wwl asmpark]# /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 []: 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  ]

 

2、啟用ASMLib驅動程式:

[root@wwl asmpark]# /etc/init.d/oracleasm enable

Writing Oracle ASM library driver configuration: done

Initializing the Oracle ASMLib driver: [  OK  ]

Scanning the system for Oracle ASMLib disks: [  OK  ]

 

 

3、透過以root使用者身份執行以下命令來標記由 ASMLib 使用的磁碟:

[root@wwl asmpark]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1

Marking disk "VOL1" as an ASM disk: [  OK  ]

[root@wwl asmpark]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1

Marking disk "VOL2" as an ASM disk: [  OK  ]

[root@wwl asmpark]#

 

4、透過如下命令檢視ASM所能使用的磁碟及狀態,一切顯示都是正常的。

[root@wwl asmpark]# oracleasm querydisk VOL1

Disk "VOL1" is a valid ASM disk

[root@wwl asmpark]# oracleasm querydisk /dev/sdb1

Device "/dev/sdb1" is marked an ASM disk with the label "VOL1"

 

[root@wwl asmpark]# oracleasm querydisk VOL2

Disk "VOL2" is a valid ASM disk

[root@wwl ~]# oracleasm querydisk /dev/sdc1

Device "/dev/sdc1" is marked an ASM disk with the label "VOL2"

 

[root@wwl asmpark]# oracleasm listdisks

VOL1

VOL2

 

[root@wwl asmpark]# ls -l /dev/oracleasm/disks/*

brw-rw---- 1 oracle dba 8, 17 Apr 10 00:25 /dev/oracleasm/disks/VOL1

brw-rw---- 1 oracle dba 8, 33 Apr 10 00:25 /dev/oracleasm/disks/VOL2

 

[root@wwl asmpark]# oracleasm status

Checking if ASM is loaded: yes

Checking if /dev/oracleasm is mounted: yes

 

5、如上ASMLib已經安裝完成,並且也將磁碟標記為可用,接下來要做的就是建立ASM例項,並構建一個使用ASM磁碟來儲存資料的資料庫,可以使用DBCA,當然也可以使用手工的方式來創,在這裡,我就採用手工方式建立ASM例項,步驟如下:

 

6、建立初始化引數檔案,資訊如下:

[oracle@wwl dbs]$ vi $ORACLE_HOME/dbs/init$ORACLE_SID.ora

asm_diskstring='WWL:VOL*'

background_dump_dest='/oracle/admin/+ASM/bdump'

core_dump_dest='/oracle/admin/+ASM/cdump'

user_dump_dest='/oracle/admin/+ASM/udump'

instance_type='asm'

large_pool_size=12M

remote_login_passwordfile='SHARED'

 

7、增加例項資訊到/etc/oratab

$ vi /etc/oratab

+ASM:/u01/app/oracle/product/10.2.0/db_1:Y

 

8、建立ASM例項密碼檔案:

[oracle@wwl dbs]$ $ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password='oracle' force=y;

[oracle@wwl dbs]$

 

9、建立ASM例項相應的目錄:

[oracle@wwl dbs]$  mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/bdump

[oracle@wwl dbs]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/cdump

[oracle@wwl dbs]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/udump

[oracle@wwl dbs]$

 

10、開啟CSS服務

$ su - root

[root@wwl ~]# /oracle/orahome/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 90 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.

        wwl

CSS is active on all nodes.

Oracle CSS service is installed and running under init(1M)

 

11、啟動ASM例項,並建立ASM磁碟組:

 

[oracle@wwl dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Apr 10 01:23:44 2012

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

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

 

SQL> startup nomount;

ASM instance started

Total System Global Area   83886080 bytes

Fixed Size                  1217836 bytes

Variable Size              57502420 bytes

ASM Cache                  25165824 bytes

 

SQL> select instance_name,status from v$instance;

 

INSTANCE_NAME    STATUS

---------------- ------------

+ASM             STARTED

 

SQL>

現在例項我已經將其啟動到nomount狀態,下一步開始建立ASM磁碟組。

 

12、建立ASM組並將其啟動到MOUNT狀態,

 

SQL> create diskgroup ASMGROUP1 normal redundancy disk '/dev/oracleasm/disks/VOL1','/dev/oracleasm/disks/VOL2';

 

Diskgroup created.

 

好了,磁碟組已經建立好了,並且也已經掛載了

SQL> select name,state from v$asm_diskgroup;

 

NAME                           STATE

------------------------------ -----------

ASMGROUP1                      MOUNTED

 

SQL>

 

可以看到如下,引數檔案也隨著更新了:

SQL> show parameter asm_diskgroups;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

asm_diskgroups                       string      ASMGROUP1

 

 

13、檢查ASM程式是否都正常啟動了,我們之前提到的幾個程式名稱,這裡面都有了,說明現在ASM已經是正常執行狀態。

[oracle@wwl ~]$ ps -ef | grep asm

oracle    3887     1  0 02:58 ?        00:00:00 asm_pmon_+ASM

oracle    3889     1  0 02:58 ?        00:00:00 asm_psp0_+ASM

oracle    3891     1  0 02:58 ?        00:00:00 asm_mman_+ASM

oracle    3893     1  0 02:58 ?        00:00:00 asm_dbw0_+ASM

oracle    3895     1  0 02:58 ?        00:00:00 asm_lgwr_+ASM

oracle    3897     1  0 02:58 ?        00:00:00 asm_ckpt_+ASM

oracle    3899     1  0 02:58 ?        00:00:00 asm_smon_+ASM

oracle    3901     1  0 02:58 ?        00:00:00 asm_rbal_+ASM

oracle    3903     1  0 02:58 ?        00:00:00 asm_gmon_+ASM

 

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

相關文章