首页 » ORACLE » 虚拟机linux RHEL5 RAW 配置 ORACLE ASM instance

虚拟机linux RHEL5 RAW 配置 ORACLE ASM instance

ASM 管理表明了oracle 进军存储的矛头,oracle 内核把文件系统与卷管理的垂直整合,数据分配到所有的磁盘分布存储,自动负载均衡,随着数据的爆增与磁盘无限的增加、大量的文件名给ORACLE数据库管理带来了挑战,为了减轻你的任务,它诞生了,就是ASM

asm 两种配置方式,1,asmlib 2,oracle数据库10g后软件自带

因为我的测试机上有先装oracle ,就只测试第二种了

环境VMware Workstation ,rhel linux 5,oracle10g

1,关闭vm,EDIT virtual machine setting ,增加一块scsi硬盘 分配2G大小

2,以root身份做添加磁盘和分区操作

[root@localhost ~]# fdisk /dev/sdb
分两个区sdb1,sdb2

[root@oraserver ~]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 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 1044 8281507+ 8e Linux LVM

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 100 803218+ 83 Linux
/dev/sdb2 101 261 1293232+ 83 Linux

3,绑定raw device
–发现在rhel5中变化很大,没有了/etc/sysconfig/rawdevices参数文件,更没有rawdevices服务,
有两种方法,我用第二种
1,需要把下面的绑定命令放在rc.local中在系统启动自动绑定另加授权
raw /dev/raw/raw1 /dev/sdb1
raw /dev/raw/raw2 /dev/sdb2
2,redhat 5中通过udev规则进行配置

[root@oraserver ~]# vi /etc/udev/rules.d/60-raw.rules

# Enter raw device bindings here.
ACTION==”add”, KERNEL==”sdb1″, RUN+=”/bin/raw /dev/raw/raw1 %N”
ACTION==”add”, KERNEL==”sdb2″, RUN+=”/bin/raw /dev/raw/raw2 %N”
# to grant authorization oracle
ACTION==”add”, KERNEL==”raw[1-2]”,OWNER=”oracle”, GROUP=”oinstall”,MODE=640
3,重启服务
[root@centos ~]# start_udev
Starting udev: [ OK ]

4,确认
[root@oraserver ~]# raw -qa
/dev/raw/raw1: bound to major 8, minor 17
/dev/raw/raw2: bound to major 8, minor 18

[root@oraserver ~]# ls -l /dev/raw
total 0
crw——- 1 oracle oinstall 162, 1 Aug 29 10:55 raw1
crw——- 1 oracle oinstall 162, 2 Aug 29 10:55 raw2

5,环境变量
–我的机器以前装过oracle ,至于其它环境变量ORACLE_BASE\ORACLE_HOME\LD_LIBARAY_PATH\PATH自己加

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

[oracle@oraserver dbs]$ env |grep ORACLE
ORACLE_SID=+ASM
ORACLE_BASE=/oracle
ORACLE_TERM=xterm
ORACLE_HOME=/oracle/product/10.2.0/db_1

6,创建参数文件
init+ASM.ora
# ******* init script for asm instance******
*._asm_allow_only_raw_disks=false
*.asm_diskstring=’/dev/raw/raw*’
*.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’
# ******Above is init script for asm instance******

7,创建口令文件
orapwd file=orapw+ASM password=oracle

8,创建参数文件中指定的*dump的路径

9,启动css服务
$ORACLE_HOME/bin/localconfig add 启动CSS

10,开始数据库配置

[oracle@oraserver ~]$ ora

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 25 22:37:09 2011

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

idle> 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

idle> col path for a20
idle> select * from v$asm_disk

PATH                 MOUNT_STATUS
-------------------- ---------------------
/dev/raw/raw2        CLOSED
/dev/raw/raw1        CLOSED

idle> create diskgroup dkgrp1 normal redundancy
2  failgroup failgrp1 disk '/dev/raw/raw1'
3  failgroup failgrp2 disk '/dev/raw/raw2';

Diskgroup created.

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

PATH                 MOUNT_STATUS
-------------------- ---------------------
/dev/raw/raw1        CACHED
/dev/raw/raw2        CACHED

idle> show parameter spfile;

NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
spfile                               string
idle> create spfile from pfile;

File created.

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

idle> alter diskgroup dkgrp1 mount;

Diskgroup altered.
idle> show parameter diskgroup

NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
asm_diskgroups                       string                            DKGRP1
idle> show parameter asm

NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
_asm_allow_only_raw_disks            boolean                           FALSE
asm_diskgroups                       string                            DKGRP1
asm_diskstring                       string                            /dev/raw/raw*
asm_power_limit                      integer                           1
idle> shut immediate
ASM diskgroups dismounted
ASM instance shutdown
idle> 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

sql>alter system register;

这样在其它oracle instance下才能看到

idle> select name,state from v$asm_diskgroup;

NAME                                     STATE
---------------------------------------- ---------------------------------
DKGRP1                                   MOUNTED

sys@ANBOB> CREATE TABLESPACE TBSASM DATAFILE '+DKGRP1' SIZE 100M;

Tablespace created.
sys@ANBOB> CREATE TABLESPACE TBSASM2 DATAFILE '+DKGRP1/DD.DBF' SIZE 1M;

Tablespace created.

sys@ANBOB> SELECT NAME FROM V$DATAFILE;

NAME
-----------------------------------------------------------------------
/oracle/oradata/anbob/undotbs01.dbf
/oracle/oradata/anbob/sysaux01.dbf
/oracle/oradata/anbob/users01.dbf
/oracle/oradata/anbob/ORA10G_P/datafile/o1_mf_testdg_7540n60c_.dbf
+DKGRP1/ora10g_p/datafile/tbsasm.256.760227615
+DKGRP1/dd.dbf

7 rows selected.

sys@ANBOB> conn anbob/anbob
Connected.
anbob@ANBOB> create table testasm(id int,name varchar2(10)) tablespace tbsasm;

Table created.

anbob@ANBOB> insert into testasm values (1,'anbob.com');

1 row created.

anbob@ANBOB> commit;

Commit complete.

anbob@ANBOB> col segment_name  for a30
anbob@ANBOB> col segment_type  for a30
anbob@ANBOB> col tablespace_name  for a30
anbob@ANBOB> select segment_name,segment_type,tablespace_name from user_segments where segment_name='TESTASM'
2  ;

SEGMENT_NAME                   SEGMENT_TYPE                   TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
TESTASM                        TABLE                          TBSASM

配置完成,如有发现问题请留言给我

转载请声明出处anbob.com

打赏

目前这篇文章有1条评论(Rss)评论关闭。

  1. Raphael Zornes | #1
    2011-12-21 at 07:34

    Thanks for your marvelous posting! I genuinely enjoyed reading it, you are a great author.I will be sure to bookmark your blog and may come back in the foreseeable future. I want to encourage you to continue your great job, have a nice evening!