ITPub博客

首页 > 数据库 > Oracle > 用vmware体验Oracle10g的ASM数据库

用vmware体验Oracle10g的ASM数据库

原创 Oracle 作者:jolly10 时间:2009-02-23 09:24:32 0 删除 编辑

vmware版本:vmware server console 1.0.5
数据库版本:10.2.0.1
OS版本:rhel4 u4
参考http://www.oracle-base.com/articles/10g/AutomaticStorageManagement10g.php

[@more@]

数据库是之前就安装好的,准备增加几个ASM设备来体验一下ASM管理的数据文件

1.先用vmware的vdiskmanager工具创建了六个磁盘

C:Program FilesVMwareVMware Server>vmware-vdiskmanager.exe -c -s 100Mb -a lsilo
gic -t 2 D:Virtual Machinessingle RHEL4_31asmasm01.vmdk
Using log file C:DOCUME~1L5MLOCALS~1Tempvmware-L5Mvdiskmanager.log
Creating monolithic preallocated disk 'D:Virtual Machinessingle RHEL4_31asmasm01.vmdk'
Create: 100% done.
Virtual disk creation successful.


C:Program FilesVMwareVMware Server>vmware-vdiskmanager.exe -c -s 100Mb -a lsilo
gic -t 2 D:Virtual Machinessingle RHEL4_31asmasm02.vmdk
Using log file C:DOCUME~1L5MLOCALS~1Tempvmware-L5Mvdiskmanager.log
Creating monolithic preallocated disk 'D:Virtual Machinessingle RHEL4_31asmasm02.vmdk'
Create: 100% done.
Virtual disk creation successful.

C:Program FilesVMwareVMware Server>vmware-vdiskmanager.exe -c -s 100Mb -a lsilo
gic -t 2 D:Virtual Machinessingle RHEL4_31asmasm03.vmdk
Using log file C:DOCUME~1L5MLOCALS~1Tempvmware-L5Mvdiskmanager.log
Creating monolithic preallocated disk 'D:Virtual Machinessingle RHEL4_31asmasm03.vmdk'
Create: 100% done.
Virtual disk creation successful.

C:Program FilesVMwareVMware Server>vmware-vdiskmanager.exe -c -s 100Mb -a lsilo
gic -t 2 D:Virtual Machinessingle RHEL4_31asmasm04.vmdk
Using log file C:DOCUME~1L5MLOCALS~1Tempvmware-L5Mvdiskmanager.log
Creating monolithic preallocated disk 'D:Virtual Machinessingle RHEL4_31asmasm04.vmdk'
Create: 100% done.
Virtual disk creation successful.

C:Program FilesVMwareVMware Server>vmware-vdiskmanager.exe -c -s 100Mb -a lsilo
gic -t 2 D:Virtual Machinessingle RHEL4_31asmasm05.vmdk
Using log file C:DOCUME~1L5MLOCALS~1Tempvmware-L5Mvdiskmanager.log
Creating monolithic preallocated disk 'D:Virtual Machinessingle RHEL4_31asmasm05.vmdk'
Create: 100% done.
Virtual disk creation successful.

C:Program FilesVMwareVMware Server>vmware-vdiskmanager.exe -c -s 100Mb -a lsilo
gic -t 2 D:Virtual Machinessingle RHEL4_31asmasm06.vmdk
Using log file C:DOCUME~1L5MLOCALS~1Tempvmware-L5Mvdiskmanager.log
Creating monolithic preallocated disk 'D:Virtual Machinessingle RHEL4_31asmasm06.vmdk'
Create: 100% done.
Virtual disk creation successful.

2.在虚拟机的Red Hat Enterprise Linux 4.vmx文件里增加以下内容
scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"
scsi1.sharedBus = "virtual"

scsi1:1.present = "TRUE"
scsi1:1.mode = "independent-persistent"
scsi1:1.filename = "D:Virtual Machinessingle RHEL4_31asmasm01.vmdk"
scsi1:1.deviceType = "disk"

scsi1:2.present = "TRUE"
scsi1:2.mode = "independent-persistent"
scsi1:2.filename = "D:Virtual Machinessingle RHEL4_31asmasm02.vmdk"
scsi1:2.deviceType = "disk"

scsi1:3.present = "TRUE"
scsi1:3.mode = "independent-persistent"
scsi1:3.filename = "D:Virtual Machinessingle RHEL4_31asmasm03.vmdk"
scsi1:3.deviceType = "disk"

scsi1:4.present = "TRUE"
scsi1:4.mode = "independent-persistent"
scsi1:4.filename = "D:Virtual Machinessingle RHEL4_31asmasm04.vmdk"
scsi1:4.deviceType = "disk"

scsi1:5.present = "TRUE"
scsi1:5.mode = "independent-persistent"
scsi1:5.filename = "D:Virtual Machinessingle RHEL4_31asmasm05.vmdk"
scsi1:5.deviceType = "disk"

scsi1:6.present = "TRUE"
scsi1:6.mode = "independent-persistent"
scsi1:6.filename = "D:Virtual Machinessingle RHEL4_31asmasm06.vmdk"
scsi1:6.deviceType = "disk"

disk.locking = "false"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"

3.启动虚拟机,安装ASM包
[root@rhel131 source]# rpm -ivh oracleasm-support-2.0.3-1.i386.rpm
Preparing... ########################################### [100%]
1:oracleasm-support ########################################### [100%]

[root@rhel131 source]# rpm -ivh oracleasm-2.6.9-42.ELsmp-2.0.3-1.i686.rpm
Preparing... ########################################### [100%]
1:oracleasm-2.6.9-42.ELsm############################################### [100%]

[root@rhel131 source]# rpm -ivh oracleasmlib-2.0.2-1.i386.rpm
Preparing... ########################################### [100%]
1:oracleasmlib ########################################### [100%]


4.创建ASM
创建ASM之前,需要将几个磁盘fdisk成分区,否则ASM不认。

[root@rhel131 source]# 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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130

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


5.用oracleasm建立ASM所能识别的盘

[root@rhel131 source]# /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 []: oinstall
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Creating /dev/oracleasm mount point: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]

[root@rhel131 source]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk: [ OK ]

[root@rhel131 source]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk: [ OK ]

[root@rhel131 source]# /etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk: [ OK ]

[root@rhel131 source]# /etc/init.d/oracleasm createdisk VOL4 /dev/sde1
Marking disk "/dev/sde1" as an ASM disk: [ OK ]

[root@rhel131 source]# /etc/init.d/oracleasm createdisk VOL5 /dev/sdf1
Marking disk "/dev/sdf1" as an ASM disk: [ OK ]

[root@rhel131 source]# /etc/init.d/oracleasm createdisk VOL6 /dev/sdg1
Marking disk "/dev/sdg1" as an ASM disk: [ OK ]

验正一下

[root@rhel131 rc3.d]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
VOL5
VOL6


6.建立ASM实例

我是用DBCA建立的ASM实例,在建立实例之前需要运行一个脚本配置CSS
$ORACLE_HOME/bin/localconfig add

ASM实例建好后在$ORACLE_HOME/dbs下会有AS实例的SPFILE

[oracle@rhel131 dbs]$ cat spfile+ASM.ora
*.background_dump_dest='/u01/app/oracle/admin/+ASM/bdump'
*.core_dump_dest='/u01/app/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/u01/app/oracle/admin/+ASM/udump'


7.启动ASM实例

[oracle@rhel131 dbs]$ export ORACLE_SID=+ASM


SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 16 20:04:50 2009

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

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>

8.建立ASM diskgroup

SQL> create diskgroup dgroup1 normal redundancy
2 failgroup fgroup1 disk 'ORCL:VOL1','ORCL:VOL2'
3 failgroup fgroup2 disk 'ORCL:VOL3','ORCL:VOL4';

Diskgroup created.

SQL> select GROUP_NUMBER,NAME,SECTOR_SIZE,BLOCK_SIZE,ALLOCATION_UNIT_SIZE,STATE,TOTAL_MB,FREE_MB from v$asm_diskgroup;

GROUP_NUMBER NAME SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE TOTAL_MB FREE_MB
------------ ---------- ----------- ---------- -------------------- ----------- ---------- ----------
1 DGROUP1 512 4096 1048576 MOUNTED 396 290

SQL> alter diskgroup dgroup1 add disk 'ORCL:VOL5';

Diskgroup altered.

SQL> select group_number,disk_number,mount_status,header_status,state,total_mb,free_mb,name,failgroup from v$asm_disk
2 order by disk_number;

GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE TOTAL_MB FREE_MB NAME FAILGROUP
------------ ----------- ------- ------------ -------- ---------- ---------- ---------- ------------------------------
1 0 CACHED MEMBER NORMAL 99 73 VOL1 FGROUP1
1 1 CACHED MEMBER NORMAL 99 72 VOL2 FGROUP1
1 2 CACHED MEMBER NORMAL 99 72 VOL3 FGROUP2
1 3 CACHED MEMBER NORMAL 99 73 VOL4 FGROUP2
1 4 CACHED MEMBER NORMAL 99 48 VOL5 VOL5
0 5 CLOSED PROVISIONED NORMAL 99 0

6 rows selected.

Since no FAILGROUP clauses are included in the ALTER DISKGROUP statement, each disk is assigned to its own failgroup. The NAME clauses assign names to the disks, otherwise they would have been assigned system generated names.
如果在增加disk时没有指定failgroup子句,则failgroup则是增加的磁盘自己。

SQL> alter diskgroup dgroup1 drop disk VOL5;

Diskgroup altered.


SQL> ALTER DISKGROUP DGROUP1 ADD FAILGROUP FGROUP1 DISK 'ORCL:VOL5' FAILGROUP FGROUP2 DISK 'ORCL:VOL6';


Diskgroup altered.


SQL> select group_number,disk_number,mount_status,header_status,state,total_mb,free_mb,name,failgroup from v$asm_disk order by PATH;

GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE TOTAL_MB FREE_MB NAME FAILGROUP
------------ ----------- ------- ------------ -------- ---------- ---------- ---------- ------------------------------
1 0 CACHED MEMBER NORMAL 99 81 VOL1 FGROUP1
1 1 CACHED MEMBER NORMAL 99 80 VOL2 FGROUP1
1 2 CACHED MEMBER NORMAL 99 80 VOL3 FGROUP2
1 3 CACHED MEMBER NORMAL 99 81 VOL4 FGROUP2
1 4 CACHED MEMBER NORMAL 99 81 VOL5 FGROUP1
1 5 CACHED MEMBER NORMAL 99 81 VOL6 FGROUP2

6 rows selected.

在alter期间可以通过v$asm_operation视图检查数据库的auto rebalance工作进度,数据库已将原来分布在两个磁盘上的数据平均分配到三个磁盘上


SQL> alter diskgroup dgroup1 drop disk 'VOL5';

Diskgroup altered.


SQL> select group_number,disk_number,mount_status,header_status,state,total_mb,free_mb,name,failgroup from v$asm_disk order by PATH;

GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE TOTAL_MB FREE_MB NAME FAILGROUP
------------ ----------- ------- ------------ -------- ---------- ---------- ---------- ------------------------------
1 0 CACHED MEMBER NORMAL 99 73 VOL1 FGROUP1
1 1 CACHED MEMBER NORMAL 99 72 VOL2 FGROUP1
1 2 CACHED MEMBER NORMAL 99 80 VOL3 FGROUP2
1 3 CACHED MEMBER NORMAL 99 82 VOL4 FGROUP2
0 0 CLOSED FORMER NORMAL 99 0
1 5 CACHED MEMBER NORMAL 99 80 VOL6 FGROUP2

6 rows selected.

删除掉FAILGROUP FGROUP2其中一个disk后,此时FGROUP1有两个磁盘,而FGROUP2有三个磁盘,这说明每个FAILGROUP的磁盘个数不必相同。


9.TEMPLATE的测试

Available attributes include:

UNPROTECTED - No mirroring or striping regardless of the redundancy setting.
MIRROR - Two-way mirroring for normal redundancy and three-way mirroring for high redundancy. This attribute cannot be set for external redundancy.
COARSE - Specifies lower granuality for striping. This attribute cannot be set for external redundancy.
FINE - Specifies higher granularity for striping. This attribute cannot be set for external redundancy.


SQL> ALTER DISKGROUP dgroup1 ADD TEMPLATE reliable ATTRIBUTES (MIRROR FINE);

Diskgroup altered.

SQL> select * From V$ASM_TEMPLATE where name='RELIABLE';

GROUP_NUMBER ENTRY_NUMBER REDUND STRIPE S NAME
------------ ------------ ------ ------ - ----------
1 13 MIRROR FINE N RELIABLE


SQL> ALTER DISKGROUP dgroup1 add TEMPLATE unreliable ATTRIBUTES (UNPROTECTED);

Diskgroup altered.

SQL> select * From V$ASM_TEMPLATE where name='UNRELIABLE';

GROUP_NUMBER ENTRY_NUMBER REDUND STRIPE S NAME
------------ ------------ ------ ------ - ----------
1 14 UNPROT COARSE N UNRELIABLE


SQL> alter diskgroup dgroup1 alter template reliable attributes(COARSE);

Diskgroup altered.

SQL> select * From V$ASM_TEMPLATE where name='RELIABLE';

GROUP_NUMBER ENTRY_NUMBER REDUND STRIPE S NAME
------------ ------------ ------ ------ - ----------
1 13 MIRROR COARSE N RELIABLE

10.建立一个目录供别名使用

SQL> ALTER DISKGROUP dgroup1 ADD DIRECTORY '+dgroup1/mydir';

Diskgroup altered.

可用rename子句修改目录

SQL> alter DISKGROUP dgroup1 rename directory '+dgroup1/mydir' to '+dgroup1/yourdir';

Diskgroup altered.

删除目录

SQL> alter diskgroup dgroup1 drop directory '+dgroup1/yourdir';

Diskgroup altered.

11.由于我ASM里面没有任何的文件,我无法建立别名,这个待以后来建立吧。
先把语法放在这,
ALTER DISKGROUP dgroup1 ADD ALIAS '+dgroup1/mydir/second.dbf'
FOR '+dgroupA/sample/datafile/mytable.342.3';
或
ALTER DISKGROUP dgroup1 ADD ALIAS '+dgroup1/mydir/second.dbf'
FOR '+dgroupA.342.3';

12.检查diskgroup元数据的内部一致性

SQL> ALTER DISKGROUP dgroup1 CHECK ALL;

Diskgroup altered.

没有任何错误返回说明diskgroup是正常的,如diskgroup有问题的话会返回错误信息,并将错误信息记录在alert.log.
ASSM自动检验任何错误,除非你指定了NOREPAIR子句。

13.有关ASM的视图:
View
ASM Instance
DB Instance
V$ASM_ALIAS
Displays a row for each alias present in every disk group mounted by the ASM instance.
Returns no rows
V$ASM_CLIENT
Displays a row for each database instance using a disk group managed by the ASM instance.
Displays a row for the ASM instance if the database has open ASM files.
V$ASM_DISK
Displays a row for each disk discovered by the ASM instance, including disks which are not part of any disk group.
Displays a row for each disk in disk groups in use by the database instance.
V$ASM_DISKGROUP
Displays a row for each disk group discovered by the ASM instance.
Displays a row for each disk group mounted by the local ASM instance.
V$ASM_FILE
Displays a row for each file for each disk group mounted by the ASM instance.
Displays no rows.
V$ASM_OPERATION
Displays a row for each file for each long running operation executing in the ASM instance.
Displays no rows.
V$ASM_TEMPLATE
Displays a row for each template present in each disk group mounted by the ASM instance.
Displays a row for each template present in each disk group mounted by the ASM instance with which the database instance communicates.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/271283/viewspace-1017727/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-02-20

  • 博文量
    263
  • 访问量
    826737