VMware虛擬機器搭建Linux Oracle 10g ASM環境

dukewyh發表於2012-07-09
1.新增磁碟進行分割槽

這裡我們將新增磁碟分成3部分:/dev/sdb1,/dev/sdb2,/dev/sdb3

[root@ocp db10g]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 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-783, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-783, default 783): +2G

Command (m for help): p

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         244     1959898+  83  Linux

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

Command (m for help): p

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         244     1959898+  83  Linux
/dev/sdb2             245         488     1959930   83  Linux

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

Command (m for help): p

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         244     1959898+  83  Linux
/dev/sdb2             245         488     1959930   83  Linux
/dev/sdb3             489         783     2369587+  83  Linux

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

Calling ioctl() to re-read partition table.
Syncing disks.

2.安裝asm包

[root@ocp asm2.6.18.164-el5]# 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@ocp asm2.6.18.164-el5]# 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@ocp asm2.6.18.164-el5]# 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%]

3.初始化ASM

[root@ocp asm2.6.18.164-el5]# /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 []: orainstall
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  ]

4.建立asm磁碟

[root@ocp asm2.6.18.164-el5]# /etc/init.d/oracleasm createdisk vol1 /dev/sdb1
Marking disk "vol1" as an ASM disk:                        [  OK  ]
[root@ocp asm2.6.18.164-el5]# /etc/init.d/oracleasm createdisk vol2 /dev/sdb2
Marking disk "vol2" as an ASM disk:                        [  OK  ]
[root@ocp asm2.6.18.164-el5]# /etc/init.d/oracleasm createdisk vol3 /dev/sdb3
Marking disk "vol3" as an ASM disk:                        [  OK  ]

列出所有asm磁碟

[root@ocp ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3

掃描asm磁碟

[root@ocp ~]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]

5.建立ASM例項

設定當前sid為asm

[oracle@ocp ~]$ export ORACLE_SID=+ASM

取一個pfile模板檔案,並進行修改

[oracle@ocp ~]$ cat $ORACLE_HOME/dbs/init.ora |grep -v ^# >$ORACLE_HOME/dbs/init+ASM.ora
[oracle@ocp ~]$ mkdir /u01/oracle/admin/+ASM/{b,c,u}dump -p
[oracle@ocp ~]$ cd $ORACLE_HOME/dbs

修改初始化檔案

[oracle@ocp dbs]$ vi init+ASM.ora

注意:這裡需要刪除原先的內容,新增以下內容:

asm_diskstring='ORCL:VOL*'
background_dump_dest='/u01/oracle/admin/+ASM/bdump'
user_dump_dest='/u01/oracle/admin/+ASM/udump'
instance_type='asm'
large_pool_size=30m
core_dump_dest='/u01/oracle/admin/+ASM/cdump'

6.建立密碼檔案,注意在dbs目錄下

[oracle@ocp dbs]$ orapwd file=orapw+ASM password=oracle

7.啟動css叢集服務

[oracle@ocp dbs]$ exit
[root@ocp ~]# cd /u01/oracle/product/10gr2/db10g/bin
[root@ocp 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.
        ocp
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)

8.啟動asm例項
[root@ocp bin]# su - oracle
[oracle@ocp ~]$ export ORACLE_SID=+ASM
[oracle@ocp ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 7 14:17:19 2012

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

SQL> conn sys as sysdba
Enter password:
Connected to an idle instance.
SQL> startup
ASM instance started

Total System Global Area  104857600 bytes
Fixed Size                  1217956 bytes
Variable Size              78473820 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted

因為我們還沒有進行磁碟組的分配,所以報錯ORA-15110是正常的。

建立磁碟組
第一個我們是用來放資料檔案的用的是normal方式
SQL> create diskgroup oradata normal redundancy disk 'ORCL:VOL1','ORCL:VOL2';

Diskgroup created.
這裡我們是用來放閃回區的,選擇為外部冗餘的方式
SQL> create diskgroup fla external redundancy disk 'ORCL:VOL3' size 2G;

Diskgroup created.

檢視一下我們的磁碟組
SQL> select GROUP_NUMBER,NAME,BLOCK_SIZE,STATE,TYPE from v$asm_diskgroup;

GROUP_NUMBER NAME                           BLOCK_SIZE      STATE       TYPE
------------ ------------------------------ ---------- ----------- ------
           1     ORADATA                              4096                            MOUNTED     NORMAL
           2     FLA                                         4096                             MOUNTED     EXTERN

ASM例項已經啟動,這個時候我們就可以用DBCA來建立資料庫了,唯一需要注意的是在選擇資料檔案和閃回區存放位置的時候設定一下


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

相關文章