温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么理解Oracle ASM

发布时间:2021-11-03 16:07:57 来源:亿速云 阅读:112 作者:柒染 栏目:建站服务器

这篇文章给大家介绍怎么理解Oracle ASM,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

Oracle 10g在安装的时候必须要选择的一个文件存储方式的选项,可以选择“文件系统”、“ASM”、“裸设备”。其中ASM现在已经越来越多的应用到实践中。ASM的时候,可以使Oracle脱离OS文件系统的约束,使得对文件管理时更加方便,同时也改善了很多的硬件属性。当然,使用ASM需要专门配置、创建一个ASM磁盘组。下面找了些文章介绍一下,初步了解ASM。

Oracle数据库自动存储管理(ASM)

   关于ASM的讨论很多,但是到底什么是ASM?ASM是一个有效的抽象层,使你的Oracle数据库可以与叫做DiskGroups的抽象空间一起使用,而不是直接使用DataFiles。这带来了很多好处,但是也要求学习一些新的概念、命令、使用和管理任务。所以在投入你的生产系统之前,看看它解决什么、管理什么,以及对它的正反面评价。

为什么创建它?

  回答这个问题的最好方式是直接追溯源头,Bill Bridge——自动存储管理的最初架构师。在Oracle Press标题中的Oracle ASM,Bill提供了一个链接,他在那里讨论了使用供应商特定操作系统的文件系统来管理Oracle数据文件放置所遇到的问题:

  1. 对于归档日志和备份,操作系统供应商不提供共享磁盘文件系统。

  2. 逻辑卷管理器隐藏了文件的位置,使得很难管理磁盘I/O和提供良好的统计。

  3. 当磁盘数超过100时,现有的lvm不能工作得很好。

  4. 当数据库有1000以上的数据文件时,操作系统和Oracle不能很好地处理数据库。

  5. 当有大量数据文件时命名就变得很困难了。

  6. 特性和文件系统限制随操作系统的不同而不同。

  7. 操作系统级的用户可以通过标准使用接触到Oracle文件,而Oracle并不知道。

  所以,他通过建立Oracle自己的文件系统开始解决这些问题。他的目标是提供这些特性:

  1. 与Oracle紧密集成,并与集群一起使用(并行服务器)。

  2. 自动使用新的存储,作为磁盘单元或磁盘组来管理。

  3. 支持成千上万的磁盘。

  4. 文件不会名字,并会在操作系统中隐藏起来。

谁需要它?

  现在快速浏览一下上面那些问题和解决方案会帮助你确定谁需要ASM。起初,它是用来处理现在很大型的联机数据库。所以如果它包括你的商店,那么你可能已经在关注它了,或者开始执行ASM。如果你的数据库较小,数据文件也不多,那么你可能需要再一些理由使你考虑采用它。

  1. 你将要熟悉一些新技术,并且应该从在你的开发环境中建立它开始,并测试几个月。

  2. 如果你想从你现有的磁盘子系统中获得更高的性能,并获得更好的统计用于预测磁盘I/O。

  3. 如果你正在使用RAC,那么就需要考虑ASM了。

开始

  ASM是由一个实例管理,非常类似于Oracle数据库。但是初始参数是非常有限的,而且启动过程也简单得多。

  a. 将你的ORACLE_SID设置为+ASM1

  b. 编辑init.ora

  # as opposed to RDBMS for a normal Oracle instance 

  INSTANCE_TYPE=ASM 

  # these names will be used in place of datafile names when you create tablespaces 

  ASM_DISKGROUPS=SEAN, AARON 

  processes=100 

  # this parameter is platform. specific and is the path to the raw disk device 

  ASM_DISKSTRING='/dev/cciss/c0d0p1' 

  # on 11g you should use diagnostic_dest instead of these 

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

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

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

  c. 启动ASM实例

  $ sqlplus / as sysdba 

  SQL> startup

  d. 创建磁盘组

  SQL> create diskgroup SEAN disk '/dev/cciss/c0d0p1';

  e. 检查表空间的创建

  你可能会猜测,创建一个表空间会有轻微的改变。默认方法如下所示:

  SQL> create tablespace sean_space datafile '+SEAN' size 1GB;

  不过想一下这个很好的特性。如果在你的数据库中init.ora文件你设置参数为:

   db_create_file_dest=+SEAN

  那么你可以这样做:

  SQL> create tablespace sean_space;

  然后让Oracle做其余的工作。在这两种情形下,你将发现在v$datafile中列出的文件路径是和抽象的+SEAN 磁盘组有关,而不是与一个实际的操作系统数据文件。

  f. 更多的

  当然简化文件名称和表空间的创建只是ASM可以为你做的工作的冰山一角。它还可以提供一个冗余级别。

  在数据库方面,外部冗余能力主要是当你在硬件级别(RAID)上或Oracle可以看到的其它外部方法中具有冗余。换句话说,如果asm_diskstring设备是它们自己的逻辑,隐藏物理磁盘于一些冗余的硬件层后面,那么你就会有外部冗余能力。

  但是,如果你没有这个冗余能力,那么ASM可以提供。你可以指定冗余、失败组和一组其它的选项来防止损失一个或多个磁盘、控制器或甚至是整个SAM失效。ASM还提供了在磁盘组中均匀分布的I/O。因为ASM很好的了解背后发生了什么,所以Oracle可以自动的为你提供I/O到磁盘的一个更好的平衡。

使用ASM遇到的挑战

  ASM当然是一个具有很大潜能的强大技术。但是对于每一个技术解决方案,都会有很多的挑战。对于ASM,它潜在地破坏了Unix系统管理组和数据库/数据库管理员组间力量的普通平衡。以前的组管理磁盘、硬件和操作系统级别,使数据库管理员与它们协作获取新的资源。这将在某种程度上挑战这个平衡,而这会引起一些来自于这个组的阻力。

  最后,应该是业务需求促使了它的采用。还要注意到ASM仍然是处于企业计算认识阶段,相对还比较新。有一些供应商他们的核心业务已经放在逻辑空间管理器/文件系统空间中很多年了。一般来说,对于软件系统和可靠性来说成熟是很重要的。

总结

  ASM很强大,它为目前部署的不断发展的大型数据库系统提供了解决方案。它还可以为较小数据库安装或者那些使用集群的数据库提供解决方案。如同对于任何新技术一样,评估、测试,然后更多的测试。

再转一篇ASM的配置文章

********************************************************************************************

配置Oracle 10g ASM磁盘

总结一下ASM的磁盘创建过程

此次实验是基于CentOS 4.6系统的实验,

1.首先,我需要在Oracle的网站上download的一些ASM的lib包 

http://www.oracle.com/technology/tech/linux/asmlib/install.html 

因为自己实验的环境是基于Linux的,而且是RHEL AS 4所以会根据当前的kernel和OS的版本下载三个包

分别是:

oracleasm-2.6.9-67.EL-2.0.3-1.i686.rpm

oracleasmlib-2.0.2-1.i386.rpm

oracleasm-support-2.0.3-1.i386.rpm

2.之后可以通过RPM的软件对他们分别进行安装 

[root@orahost01 ASM]# rpm -Uvh oracleasm-support-2.0.3-1.i386.rpm

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

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

[root@orahost01 ASM]# rpm -Uvh oracleasm-2.6.9-67.EL-2.0.3-1.i686.rpm

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

  1:oracleasm-2.6.9-67.EL  ########################################### [100%]

[root@orahost01 ASM]# rpm -Uvn oracleasmlib-2.0.2-1.i386.rpm

-Uvn: unknown option

[root@orahost01 ASM]# rpm -Uvh oracleasmlib-2.0.2-1.i386.rpm

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

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

并且创建相应的Oracle用户和组

[root@orahost01 ASM]# groupadd oinstall

[root@orahost01 ASM]# groupadd dba

[root@orahost01 ASM]# mkdir -p /opt/oracle/product

[root@orahost01 ASM]# mkdir -p /home/oracle

[root@orahost01 ASM]# useradd -g oinstall -G dba -d /home/oracle oracle

[root@orahost01 ASM]# passwd oracle

Changing password for user oracle.

New UNIX password:

BAD PASSWORD: it is based on a dictionary word

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

[root@orahost01 ASM]# id oracle

uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)

[root@orahost01 ASM]# chown -R oracle:oinstall /opt/oracle

[root@orahost01 ASM]# cd /home

[root@orahost01 home]# chown -R oracle:oinstall oracle

3.配置ASM的库文件 

[root@orahost01 home]#/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 <ENTER> 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

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  ]

以上操作会加载和ASM相关的一些.o的驱动.并且mount上asm的文件系统

4.如何disable和enable ASM

[root@orahost01 home]#/etc/init.d/oracleasm disable

Writing Oracle ASM library driver configuration: [  OK  ]

Unmounting ASMlib driver filesystem: [  OK  ]

Unloading module "oracleasm": [  OK   ]

[root@orahost01 home]#/etc/init.d/oracleasm enable

Writing Oracle ASM library driver configuration: [  OK  ]

Loading module "oracleasm": [  OK   ]

Mounting ASMlib driver filesystem: [  OK  ]

Scanning system for ASM disks: [  OK  ]

5.创建ASM磁盘

首先先将一些磁盘(4块)插入我们的Server

之后

[root@orahost01 home]# /etc/init.d/oracleasm createdisk myVol1 /dev/sdb

Marking disk "/dev/sdb" as an ASM disk: asmtool: Device "/dev/sdb" is not a partition

[FAILED]

这里出现错误的原因是由于我们还没有对/dev/sdb这个设备文件所加载的磁盘进行分区,而且sdb也不是一个partition

因此我们先对sdb磁盘进行分区

[root@orahost01 dev]#fdisk 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): m

Command action

  a   toggle a bootable flag

  b   edit bsd disklabel

  c   toggle the dos compatibility flag

  d   delete a partition

  l   list known partition types

  m   print this menu

  n   add a new partition

  o   create a new empty DOS partition table

  p   print the partition table

  q   quit without saving changes

  s   create a new empty Sun disklabel

  t   change a partition's system id

  u   change display/entry units

  v   verify the partition table

  w   write table to disk and exit

  x   extra functionality (experts only)

Command (m for help): n

Command action

  e   extended

  p   primary partition (1-4)

p

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!

Calling ioctl() to re-read partition table.

Syncing disks.

这个时候系统中会出现一个sdb1这个设备文件

之后我们继续对sdc,sdd,sde以上面同样的方法来进行分区。

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

重新创建ASM磁盘

[root@orahost01 dev]# /etc/init.d/oracleasm createdisk myVol1 /dev/sdb1

Marking disk "/dev/sdb1" as an ASM disk: [  OK  ]

[root@orahost01 dev]# /etc/init.d/oracleasm listdisks

MYVOL1

[root@orahost01 dev]# /etc/init.d/oracleasm createdisk myVol2 /dev/sdc1

Marking disk "/dev/sdc1" as an ASM disk: [  OK  ]

[root@orahost01 dev]# /etc/init.d/oracleasm createdisk myVol3 /dev/sde1

Marking disk "/dev/sde1" as an ASM disk: [  OK   ]

[root@orahost01 dev]# /etc/init.d/oracleasm createdisk myVol4 /dev/sdd1

Marking disk "/dev/sdd1" as an ASM disk: [  OK   ]

[root@orahost01 dev]#/etc/init.d/oracleasm listdisks

MYVOL1

MYVOL2

MYVOL3

MYVOL4

需要注意的是如果是在RAC环境中呢,如果在一个节点添加了ASM磁盘,在其他节点上要用过scandisks命令来获得这种变化。

如:

[root@orahost01 dev]#/etc/init.d/oracleasm scandisks

Scanning system for ASM disks: [  OK   ]

就此ASM环境的物理基础就已经搭建成功.

其他OS类似于此,很简单,只要按照这个思路走就可以了:)

关于怎么理解Oracle ASM就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI