oracle 手動建立ASM

邱東陽發表於2014-03-20

手動建立ASM磁碟組

根據自己的需求為OS 新增磁碟

 

官方說明安裝ASM 需要三個包:

 

  oracleasm-support-version.arch.rpm

  oracleasmlib-version.arch.rpm

  oracleasm-kernel-version.arch.rpm

 

 

安裝ASM必要的包

 

[root@fengzi init.d]# cd /rhel5/Server/  (我的本地源)

[root@fengzi Server]# ls oracleasm*

oracleasm-2.6.18-274.el5-2.0.5-1.el5.x86_64.rpm

oracleasm-2.6.18-274.el5debug-2.0.5-1.el5.x86_64.rpm

oracleasm-2.6.18-274.el5xen-2.0.5-1.el5.x86_64.rpm

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

 

[root@fengziServer]#rpm -Uvh oracleasm-support-2.1.7-1.el5.x86_64.rpm

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

Preparing...                                                            (10########################################### [100%]

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

[root@fengzi Server]# rpm -Uvh oracleasm-2.6.18-274.el5-2.0.5-1.el5.x86_64.rpm

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

Preparing...                                                            (10########################################### [100%]

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

 

 

缺少oracleasmlib包(到網上下載)

使用SHH 工具上傳包

 

[root@fengzi oracle]# cd /root

[root@fengzi ~]# ls

anaconda-ks.cfg  install.log.syslog

Desktop         

oracleasmlib-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm(可能版本不是一致)

install.log

[root@fengzi ~]# rpm -Uvh oracleasmlib-2.6.18-194.32.1.el5-2.0.5-1.el5.x86_64.rpm

warning: oracleasmlib-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159

Preparing...                                                            (10########################################### [100%]

   1:oracleasmlib-2.6.18-194.3.e15                                           ( 1########################################### [100%]

 

 

配置 ASMLib

使用 ASMLib 之前,必須執行配置指令碼以準備驅動程式。以 root 使用者身份執行以下命令,並響應如下示例中所顯示的提示

 

 

[root@fengzi ~]# /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  ]

[root@fengzi ~]#

 

 

啟用 ASMLib 驅動程式

 

[root@fengzi ~]# /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  ]

[root@fengzi ~]#

 

ASM 配置磁碟

檢視當前磁碟

 

[root@fengzi u01]# fdisk -l

 

Disk /dev/sda: 20.5 GB, 20574109696 bytes

255 heads, 63 sectors/track, 2501 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1         130     1044193+  83  Linux

/dev/sda2             131        2371    18000832+  83  Linux

/dev/sda3            2372        2501     1044225   82  Linux swap / Solaris

 

Disk /dev/sdb: 21.5 GB, 21581791232 bytes

255 heads, 63 sectors/track, 2623 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        2623    21069216   83  Linux

 

Disk /dev/sdc: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

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

 

Disk /dev/sdd: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

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

 

Disk /dev/sde: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

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

 

Disk /dev/sdf: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

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

[root@fengzi u01]#

 

 

給磁碟分割槽

 

幾個盤都分割槽

[root@fengzi u01]# fdisk /dev/sdc

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): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-522, default 1): Enter

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-522, default 522): Enter

Using default value 522

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

[root@fengzi u01]#

 使用相同步驟將需要新增到磁碟組的磁碟都分割槽

我的為/dev/sdc  /dev/sdd  /dev/sde   /dev/sdf

 

 

配置磁碟

 

[root@fengzi u01]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1

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

[root@fengzi u01]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd1

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

[root@fengzi u01]# /etc/init.d/oracleasm createdisk VOL3 /dev/sde1

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

[root@fengzi u01]# /etc/init.d/oracleasm createdisk VOL4 /dev/sdf1

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

[root@fengzi u01]#

 

列出標記為由 ASMLib 使用的所有磁碟

[root@fengzi u01]# /etc/init.d/oracleasm listdisks

VOL1

VOL2

VOL3

VOL4

[root@fengzi u01]#

 

 

配置oracle叢集同步服務(css

 

用於同步ASM例項與RDBMS例項,使用root帳戶進行配置,配置程式位於$ORACLE_HOME/bin

$su

[root@fengzi u01]# $ORACLE_HOME/bin/localconfig all

/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.

        hxl

CSS is active on all nodes.

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

 

 

手動建立ASM目錄

使用oracle使用者

 

mkdir -p $ORACLE_BASE/admin/+ASM/bdump

mkdir -p $ORACLE_BASE/admin/+ASM/cdump

mkdir -p $ORACLE_BASE/admin/+ASM/hdump

mkdir -p $ORACLE_BASE/admin/+ASM/pfile

mkdir -p $ORACLE_BASE/admin/+ASM/udump

 

 

建立磁碟組引數檔案

 

[oracle@fengzi bin]#vi $ORACLE_BASE/admin/+ASM/pfile/init.ora

*.asm_diskgroups='DATA'

+ASM.asm_diskgroups='DATA'                              #Manual Mount

*.background_dump_dest='/u01/app/oracle/admin/+ASM/bdump'

*.cluster_database=true

*.core_dump_dest='/u01/app/oracle/admin/+ASM/cdump'

 

*.instance_type='asm'

*.large_pool_size=12M

*.remote_login_passwordfile='exclusive'

*.user_dump_dest='/u01/app/oracle/admin/+ASM/udump'

 

 

 

建立磁碟組

 

[oracle@fengzi bin]# export ORACLE_SID=+ASM

[oracle@fengzi bin]#sqlplus  / as  sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Feb 21 19:10:51 2010

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, Real Application Clusters, OLAP and Data Mining options

SQL>

 

 

外部冗餘方式

SQL> create  diskgroup DATA external redundancy disk '/dev/oracleasm/VOL1';

 

Diskgroupcreated.

 

SQL> alter diskgroup DATA add disk '/dev/oracleasm/VOL2';

 

Diskgroupaltered.

SQL> alter diskgroup DATA add disk '/dev/oracleasm/VOL3';

 

Diskgroupaltered.

SQL> alter diskgroup DATA add disk '/dev/oracleasm/VOL4';

 

Diskgroupaltered.

普通冗餘方式

SQL> create diskgroup DATA normal redundancy

  2  failgroup DATA1 disk '/dev/oracleasm/VOL1' name DATA1

  3  failgroup DATA2 disk '/dev/oracleasm/VOL2' name DATA2;

 

SQL> alter diskgroup DATA add disk '/dev/oracleasm/VOL1' name

VOL1,'/dev/oracleasm/VOL3' name VOL3,'/dev/oracleasm/VOL4' name VOL4

 

  建立spfile

SQL>create spfile from pfile;

File created.

 

 手動指定磁碟組的名

 

SQL> alter system set asm_diskgroups=DATA scope=both;

 

System altered.

 

SQL> show parameter asm;

 

NAME                                TYPE        VALUE

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

asm_diskgroups                      string      DATA

asm_diskstring                      string

asm_power_limit                     integer     1

 

 

重啟ASM

 

SQL>shutdown immediate 

ASMinstance shutdown

SQL>startup

ASMinstance started

 

TotalSystem Global Area   92274688 bytes

FixedSize                  1217884 bytes

VariableSize              65890980 bytes

ASMCache                  25165824 bytes

ASMdiskgroups mounted

SQL>select name,state from v$asm_diskgroup;

 

NAME                           STATE

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

DATA                    MOUNTED

 

 

 

建立完成,下面就可以構建一個使用ASM進行磁碟儲存的資料庫。

 

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

相關文章