设为首页 收藏本站
查看: 560|回复: 0

[经验分享] RHEL下创建ORACLE ASM数据库

[复制链接]

尚未签到

发表于 2018-9-13 11:36:28 | 显示全部楼层 |阅读模式
  在真正的生产大数据环境中,存储管理是DBA的主要工作之一,比如生产系统上表空间的监控,当一个表空间满或者使用率过高时,可能需要
  DBA添加一块磁盘到操作系统中,然后再在新加的磁盘上添加数据文件。如果这个操作作用的环境是单个磁盘,那么不是这个动作影响相对较小。
  然而,如果使用的是RAID或者LVM,那么现在大量的数据仍然分布在以前的磁盘上,如果我们在新添加磁盘之后想让数据均匀的分布在磁盘上,
  可能就要耗费很大的经历来做原先数据的导出导入。那么如果有一种方法,能实现我们就把一块磁盘加到系统里,然后告诉
  Oracle 我们要用这块盘了,剩下的工作全部由Oracle 来完成,该是多好的一件事情!幸
  运的是,Oracle1 已经提供了这个功能, 这就是ASM( Automatic Storage
  Management)。我们称为“自动存储管理”。Oracle10g 的ASM 不但帮助DBA 从繁琐的
  磁盘空间管理中解脱出来,而且更值得关注的是ASM 同时提供了条带和镜像的功能,而这
  些功能原先需要通过单独地配置RAID 来实现。正是因为ASM的这些优点,所以ASM越来越流行和推广,尤其是生产上存在大量的ASM存储RAC系统。
  本文通过实验,在RHEL 4下搭建一个ASM的单实例数据库,后续可能我会发布搭建ASM RAC的实验文章。
  首先需要查看Linux系统的内核版本,因为要针对不同的内核版本,来下载asm的驱动包,asm的驱动包包括
  oracleasm、oracleasmlib和oracleasmsupport三个版本,在RHEL下面你需要安装三个驱动包,而在Oracle自己的小企鹅版Linux中,前两个已经安装,
  只需要装support。
  uname -r查看我的系统内核如下:
  [root@localhost ~]# uname -r
  2.6.9-78.ELsmp
  [root@localhost ~]#
  所以我要下载这个内核对应的驱动包,ASM的驱动包在Oracle官网的
  Server and Storage->Oracle Linux Downloads可以下载。
  1.首先我在我的虚拟机Linux下增加4块磁盘,每个磁盘建占满整个磁盘的主分区,四块磁盘后面我将建两个ASM的组,一个主GROUP和一个冗余GROUP。
  我的系统中磁盘情况如下:
  [root@localhost ~]# fdisk -l
  Disk /dev/sda: 16.1 GB, 16106127360 bytes
  255 heads, 63 sectors/track, 1958 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 1958 15623212+ 8e Linux LVM
  Disk /dev/sdb: 10.7 GB, 10737418240 bytes
  255 heads, 63 sectors/track, 1305 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Disk /dev/sdb doesn't contain a valid partition table
  Disk /dev/sdc: 5368 MB, 5368709120 bytes
  255 heads, 63 sectors/track, 652 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Disk /dev/sdc doesn't contain a valid partition table
  Disk /dev/sdd: 5368 MB, 5368709120 bytes
  255 heads, 63 sectors/track, 652 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Disk /dev/sdd doesn't contain a valid partition table
  Disk /dev/sde: 5368 MB, 5368709120 bytes
  255 heads, 63 sectors/track, 652 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Disk /dev/sde doesn't contain a valid partition table
  Disk /dev/sdf: 5368 MB, 5368709120 bytes
  255 heads, 63 sectors/track, 652 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Disk /dev/sdf doesn't contain a valid partition table
  [root@localhost ~]#
  可以看到现在没有分区的有sdb-sdf的5块磁盘,其中sdb大小10G,我暂时不用,我对sdc、sdd、sde、sdf分区,它们都是5G.分区后如下:
  [root@localhost ~]# fdisk -l
  Disk /dev/sda: 16.1 GB, 16106127360 bytes
  255 heads, 63 sectors/track, 1958 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 1958 15623212+ 8e Linux LVM
  Disk /dev/sdb: 10.7 GB, 10737418240 bytes
  255 heads, 63 sectors/track, 1305 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Disk /dev/sdb doesn't contain a valid partition table
  Disk /dev/sdc: 5368 MB, 5368709120 bytes
  255 heads, 63 sectors/track, 652 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot Start End Blocks Id System
  /dev/sdc1 1 652 5237158+ 83 Linux
  Disk /dev/sdd: 5368 MB, 5368709120 bytes
  255 heads, 63 sectors/track, 652 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot Start End Blocks Id System
  /dev/sdd1 1 652 5237158+ 83 Linux
  Disk /dev/sde: 5368 MB, 5368709120 bytes
  255 heads, 63 sectors/track, 652 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot Start End Blocks Id System
  /dev/sde1 1 652 5237158+ 83 Linux
  Disk /dev/sdf: 5368 MB, 5368709120 bytes
  255 heads, 63 sectors/track, 652 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot Start End Blocks Id System
  /dev/sdf1 1 652 5237158+ 83 Linux
  [root@localhost ~]#
  2.安装ASM驱动包:
  [root@localhost asm]# pwd
  /oracle/asm
  [root@localhost asm]# ls -l
  鎬荤敤閲?252
  -rw-r--r-- 1 root root 134679 2013-08-18 oracleasm-2.6.9-78.ELsmp-2.0.5-1.el4.i686.rpm
  -rw-r--r-- 1 root root 13105 2013-08-18 oracleasmlib-2.0.4-1.el4.i386.rpm
  -rw-r--r-- 1 root root 83636 2013-08-18 oracleasm-support-2.1.7-1.el4.i386.rpm
  [root@localhost asm]# rpm -ivh oracleasm*
  璀﹀憡锛歰racleasm-2.6.9-78.ELsmp-2.0.5-1.el4.i686.rpm: V3 DSA 绨界珷锛歂OKEY, key ID b38a8516
  婧栧倷涓?.. ########################################### [100%]
  1:oracleasm-support ########################################### [ 33%]
  2:oracleasm-2.6.9-78.ELsm########################################### [ 67%]
  3:oracleasmlib ########################################### [100%]
  [root@localhost asm]#
  3.配置ASMLib:
  /etc/init.d/oracleasm configure
  [root@localhost asm]# /etc/init.d/oracleasm configure
  以上操作将加载 oracleasm.o 驱动,并且mount 上ASM 文件系统,同时我们还可以通过以
  下命令来手工的卸载和加载ASMLib
  # /etc/init.d/oracleasm disable
  4.创建ASM磁盘:
  /etc/init.d/oracleasm createdisk DF1 /dev/sdc1
  /etc/init.d/oracleasm createdisk DF2 /dev/sdd1
  /etc/init.d/oracleasm createdisk DF3 /dev/sde1
  /etc/init.d/oracleasm createdisk DF4 /dev/sdf1
  [root@localhost asm]# /etc/init.d/oracleasm createdisk DF1 /dev/sdc1
  Marking disk "DF1" as an ASM disk: [ OK ]
  [root@localhost asm]# /etc/init.d/oracleasm createdisk DF2 /dev/sdd1
  Marking disk "DF2" as an ASM disk: [ OK ]
  [root@localhost asm]# /etc/init.d/oracleasm createdisk DF3 /dev/sde1
  Marking disk "DF3" as an ASM disk: [ OK ]
  [root@localhost asm]# /etc/init.d/oracleasm createdisk DF4 /dev/sdf1
  Marking disk "DF4" as an ASM disk: [ OK ]
  [root@localhost asm]#
  scan并查看创建的ASM磁盘:
  /etc/init.d/oracleasm scandisks
  /etc/init.d/oracleasm listdisks
  [root@localhost asm]# /etc/init.d/oracleasm scandisks
  Scanning the system for Oracle ASMLib disks: [ OK ]
  [root@localhost asm]# /etc/init.d/oracleasm listdisks
  DF1
  DF2
  DF3
  DF4
  [root@localhost asm]#
  四块ASM磁盘创建完成。
  下面开始以oracle用户登录,来创建ASM实例和ASM的数据库。
  5.root用户运行本地配置脚本,如果这里不运行的话,在安装ASM实例的时候就会弹出提示:
  [oracle@localhost ~]$ echo $ORACLE_HOME
  /oracle/oracle/product/10.2.0
  [oracle@localhost ~]$
  #cd /oracle/oracle/product/10.2.0/bin
  #./localconfig add
  [root@localhost 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.
  localhost
  CSS is active on all nodes.
  Oracle CSS service is installed and running under init(1M)
  [root@localhost bin]#
  6.DBCA创建ASM实例
  选择创建ASM,将DF1、DF2建为DATA组,DF3、DF4建为RECO组。ASM方式选择normal,如果为external,相当于没有ASM的软RAID服务。
  7.DBCA创建ASM管理的数据库
  存储选择ASM,数据文件组选择DATA,闪回恢复区选RECO。创建完成。如果打开OEM,则可以在OEM下面查看ASM实例和数据库实例,安装完成后在ORACLE_HOME/install/readme文件中有访问OEM的地址。
  8.测试ASM:
  [oracle@localhost install]$ export ORACLE_SID=+ASM
  [oracle@localhost install]$ sqlplus / as sysdba
  SQL*Plus: Release 10.2.0.1.0 - Production on Sat Aug 17 18:56:02 2013
  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
  SQL> select instance_name,status from v$instance;
  INSTANCE_NAME STATUS
  ---------------- ------------
  +ASM STARTED
  SQL> select name,allocation_unit_size,total_mb from v$asm_diskgroup;
  NAME ALLOCATION_UNIT_SIZE TOTAL_MB
  ------------------------------ -------------------- ----------
  DATA 1048576 10228
  RECO 1048576 10228
  数据库中查看datafile:
  [oracle@localhost install]$ export ORACLE_SID=asmdb1
  [oracle@localhost install]$ sqlplus / as sysdba
  SQL*Plus: Release 10.2.0.1.0 - Production on Sat Aug 17 18:58:16 2013
  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
  SQL> select name from v$datafile;
  NAME
  --------------------------------------------------------------------------------
  +DATA/asmdb1/datafile/system.256.823718933
  +DATA/asmdb1/datafile/undotbs1.258.823718937
  +DATA/asmdb1/datafile/sysaux.257.823718933
  +DATA/asmdb1/datafile/users.259.823718937
  SQL>


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-577945-1-1.html 上篇帖子: Oracle rowid详解 下篇帖子: 改变Oracle数据库连接端口
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表