LINUX上安装ASM

    在本实验中,由于本机之前已经安装过oracle软件,数据库实例还没有创建,所以在安装ASM的时候就没有前面的一些步骤(配置yum源,安装依赖包,创建oracle用户和组,配置内核参数

/etc/sysctl.conf,配置限制/etc/security/limits.conf,关闭SELINUX 等相关的操作),这些步骤在安装oracle软件的时候就已经配置过。
    本实验主要是将新添加进来的四块磁盘设备进行udev设备映射,加入ASM,并安装ASM(数据库实例为单实例)。

1.查看新增的四块磁盘设备

点击(此处)折叠或打开

  1. [root@LINUX10 ~]# fdisk -l

  2. Disk /dev/sda: 32.2 GB, 32212254720 bytes
  3. 255 heads, 63 sectors/track, 3916 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0x000915be

  8.    Device Boot Start End Blocks Id System
  9. /dev/sda1 1 383 3072000 82 Linux swap / Solaris
  10. Partition 1 does not end on cylinder boundary.
  11. /dev/sda2 * 383 3917 28384256 83 Linux

  12. Disk /dev/sdb: 10.7 GB, 10737418240 bytes
  13. 255 heads, 63 sectors/track, 1305 cylinders
  14. Units = cylinders of 16065 * 512 = 8225280 bytes
  15. Sector size (logical/physical): 512 bytes / 512 bytes
  16. I/O size (minimum/optimal): 512 bytes / 512 bytes
  17. Disk identifier: 0x00000000


  18. Disk /dev/sdc: 10.7 GB, 10737418240 bytes
  19. 255 heads, 63 sectors/track, 1305 cylinders
  20. Units = cylinders of 16065 * 512 = 8225280 bytes
  21. Sector size (logical/physical): 512 bytes / 512 bytes
  22. I/O size (minimum/optimal): 512 bytes / 512 bytes
  23. Disk identifier: 0x00000000


  24. Disk /dev/sdd: 10.7 GB, 10737418240 bytes
  25. 255 heads, 63 sectors/track, 1305 cylinders
  26. Units = cylinders of 16065 * 512 = 8225280 bytes
  27. Sector size (logical/physical): 512 bytes / 512 bytes
  28. I/O size (minimum/optimal): 512 bytes / 512 bytes
  29. Disk identifier: 0x00000000


  30. Disk /dev/sde: 10.7 GB, 10737418240 bytes
  31. 255 heads, 63 sectors/track, 1305 cylinders
  32. Units = cylinders of 16065 * 512 = 8225280 bytes
  33. Sector size (logical/physical): 512 bytes / 512 bytes
  34. I/O size (minimum/optimal): 512 bytes / 512 bytes
  35. Disk identifier: 0x00000000
2.对四块设备进行分区

点击(此处)折叠或打开

  1. [root@LINUX10 ~]# fdisk /dev/sdb
  2. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  3. Building a new DOS disklabel with disk identifier 0x7bbbac09.
  4. Changes will remain in memory only, until you decide to write them.
  5. After that, of course, the previous content won\'t be recoverable.

  6. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

  7. WARNING: DOS-compatible mode is deprecated. It\'s strongly recommended to
  8.          switch off the mode (command \'c\') and change display units to
  9.          sectors (command \'u\').

  10. Command (for help): n
  11. Command action
  12.    e extended
  13.    p primary partition (1-4)
  14. p
  15. Partition number (1-4): 1
  16. First cylinder (1-1305, default 1): 
  17. Using default value 1
  18. Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 
  19. Using default value 1305

  20. Command (for help): w
  21. The partition table has been 

  22. Calling ioctl() to re-read partition table.
  23. Syncing disks.
  24. [root@LINUX10 ~]# fdisk /dev/sdc
  25. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  26. Building a new DOS disklabel with disk identifier 0x0138acd7.
  27. Changes will remain in memory only, until you decide to write them.
  28. After that, of course, the previous content won't be recoverable.

  29. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

  30. WARNING: DOS-compatible mode is deprecated. It\'s strongly recommended to
  31.          switch off the mode (command 'c') and change display units to
  32.          sectors (command 'u').

  33. Command (for help): n
  34. Command action
  35.    e extended
  36.    p primary partition (1-4)
  37. p
  38. Partition number (1-4): 1
  39. First cylinder (1-1305, default 1): 
  40. Using default value 1
  41. Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 
  42. Using default value 1305

  43. Command (for help): w
  44. The partition table has been 

  45. Calling ioctl() to re-read partition table.
  46. Syncing disks.
  47. [root@LINUX10 ~]# fdisk /dev/sdd
  48. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  49. Building a new DOS disklabel with disk identifier 0x39f7dc94.
  50. Changes will remain in memory only, until you decide to write them.
  51. After that, of course, the previous content won\'t be recoverable.

  52. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

  53. WARNING: DOS-compatible mode is deprecated. It\'s strongly recommended to
  54.          switch off the mode (command \'c\') and change display units to
  55.          sectors (command \'u\').

  56. Command (for help): n
  57. Command action
  58.    e extended
  59.    p primary partition (1-4)
  60. p
  61. Partition number (1-4): 1
  62. First cylinder (1-1305, default 1): 
  63. Using default value 1
  64. Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 
  65. Using default value 1305

  66. Command (for help): w
  67. The partition table has been 

  68. Calling ioctl() to re-read partition table.
  69. Syncing disks.
  70. [root@LINUX10 ~]# fdisk /dev/sde
  71. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  72. Building a new DOS disklabel with disk identifier 0x76d993a3.
  73. Changes will remain in memory only, until you decide to write them.
  74. After that, of course, the previous content won\'t be recoverable.

  75. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

  76. WARNING: DOS-compatible mode is deprecated. It\'s strongly recommended to
  77.          switch off the mode (command \'c\') and change display units to
  78.          sectors (command \'u\').

  79. Command (for help): n
  80. Command action
  81.    e extended
  82.    p primary partition (1-4)
  83. p
  84. Partition number (1-4): 1
  85. First cylinder (1-1305, default 1): 
  86. Using default value 1
  87. Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 
  88. Using default value 1305

  89. Command (for help): w
  90. The partition table has been 

  91. Calling ioctl() to re-read partition table.
  92. Syncing disks.
分区完成后,查看是否分区完成
 
[root@LINUX10 ~]# fdisk -l

3.UDEV绑定

为什么使用udev:

*不确定的设备映射。特别是那些动态设备,比如USB设备,设备文件到实际设备的映射并不可靠和确定。举一个例子:如果你有两个USB打印机。一个可能称 为/dev/usb/lp0,另外一个便是/dev/usb/lp1。但是到底哪个是哪个并不清楚,lp0,lp1和实际的设备没有一一对应的关系,因为 他可能因为发现设备的顺序,打印机本身关闭等原因而导致这种映射并不确定。理想的方式应该是:两个打印机应该采用基于他们的序列号或者其他标识信息的唯一 设备文件来映射。但是静态文件和devfs都无法做到这点。

1).获取磁盘的scsi_id
    

  1. [root@LINUX10 ~]# /sbin/scsi_id -g -u -d /dev/sdb
  2. 1ATA_VBOX_HARDDISK_VBc3828ca9-05a29ba0
  3. [root@LINUX10 ~]# /sbin/scsi_id -g -u -d /dev/sdc
  4. 1ATA_VBOX_HARDDISK_VB05afa31c-5e0063bb
  5. [root@LINUX10 ~]# /sbin/scsi_id -g -u -d /dev/sdd
  6. 1ATA_VBOX_HARDDISK_VB0af408e0-e18869b2
  7. [root@LINUX10 ~]# /sbin/scsi_id -g -u -d /dev/sde
  8. 1ATA_VBOX_HARDDISK_VB9ca80215-921bc473


2).添加SCSI设备信任关系

在/etc/scsi_id.config的结尾添加下面的内容,如果文件不存在就创建它
options=-g

3).创建UDEV规则文件

创建/etc/udev/rules.d/99-oracle-asmdevices.rules , 增加以下数据

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VBc3828ca9-05a29ba0", NAME="asm-disk1", OWNER="oracle", GROUP="dba", MODE="0660"

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VB05afa31c-5e0063bb", NAME="asm-disk2", OWNER="oracle", GROUP="dba", MODE="0660"

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VB0af408e0-e18869b2", NAME="asm-disk3", OWNER="oracle", GROUP="dba", MODE="0660"

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VB9ca80215-921bc473", NAME="asm-disk4", OWNER="oracle", GROUP="dba", MODE="0660"


注意,这里的RESULT参数后面的字符串即为 scsi_id 号,要做好对应关系



4).引导更新块设备分区(/sbin/partprobe)
  1. [root@LINUX10 ~]# /sbin/partprobe /dev/sdb1
  2. [root@LINUX10 ~]# /sbin/partprobe /dev/sdc1
  3. [root@LINUX10 ~]# /sbin/partprobe /dev/sdd1
  4. [root@LINUX10 ~]# /sbin/partprobe /dev/sde1
5).重启UDEV服务
  1. [root@LINUX10 rules.d]# /sbin/udevadm control --reload-rules
  2. [root@LINUX10 rules.d]# /sbin/start_udev
  3. Starting udev: [ OK ]
6).检查通过udev绑定后设备的宿主和权限
  1. [root@LINUX10 ~]# ls -la /dev/asm*
  2. brw-rw----. 1 oracle dba 8, 17 Apr 11 14:24 /dev/asm-disk1
  3. brw-rw----. 1 oracle dba 8, 33 Apr 11 14:24 /dev/asm-disk2
  4. brw-rw----. 1 oracle dba 8, 49 Apr 11 14:24 /dev/asm-disk3
  5. brw-rw----. 1 oracle dba 8, 65 Apr 11 14:24 /dev/asm-disk4


4.配置环境变量
    在设置环境变量之前,先创建grid_home 的目录

    [oracle@LINUX10 ~]$ mkdir /u01/app/grid

1)设置oracle用户的环境变量

  1. # .bash_profile

  2. # Get the aliases and functions
  3. if [ -f ~/.bashrc ]; then
  4.     . ~/.bashrc
  5. fi

  6. # User specific environment and startup programs

  7. PATH=$PATH:$HOME/bin

  8. export ORACLE_BASE=/u01/app/oracle
  9. export ORACLE_HOME=$ORACLE_BASE/product/11.2.3/oracle
  10. export DB_HOME=$ORACLE_BASE/product/11.2.3/oracle
  11. export ORACLE_SID=orcl

  12. export GRID_HOME=/u01/app/grid
  13. export PATH=$ORACLE_HOME/bin:$PATH

  14. alias grid_env='. /home/oracle/grid_env'
  15. alias db_env='. /home/oracle/db_env'

  16. alias sqlplus='rlwrap sqlplus'
  17. alias rman='rlwrap rman'
  18. alias lsnrctl='rlwrap lsnrctl'

2)配置grid_env
    配置该文件是方便在oracle用户的环境变量中配置了
alias grid_env='. /home/oracle/grid_env' 而直接引用grid_env就可以方便的切换到ASM实例的环境


  1. [oracle@LINUX10 ~]$ touch /home/oracle/grid_env

  2. [oracle@LINUX10 ~]$ more grid_env
  3. export ORACLE_SID=+ASM;
  4. export ORACLE_HOME=$GRID_HOME;
  5. export PATH=$PATH:$ORACLE_HOME/bin:$BASE_PATH;
  6.  
  7. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
  8. export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
3)配置db_env
    同grid_env设置一样,调用db_env方便切换到oracle实例的环境变量
  1. [oracle@LINUX10 ~]$ touch /home/oracle/db_env
  2. [oracle@LINUX10 ~]$ more db_env
  3. export ORACLE_SID=orcl;

    export ORACLE_HOME=$DB_HOME;

    export PATH=$PATH:$ORACLE_HOME/bin:$BASE_PATH;

    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;

    export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;

4)使环境变量生效

    [oracle@LINUX10 ~]$ source .bash_profile 


5 安装ASM
    将安装介质拷贝到服务器,进行解压,运行压缩包中的 runInstaller.sh文件 ,下面是一些安装的截图
step1:选择跳过,next

'


step2:选择standalone server,选择next

step3:此步骤选择英文,next


step4:这里磁盘组命名为DATA, 冗余策略为正常冗余(High即为高度冗余,冗余数据有三份,即使坏了一份,还有两份是冗余的; Normal正常冗余,冗余数据有两份,坏掉一份,还有一份是可以用的; External外部冗余,在外部设备已经做了冗余,不需要在ASM中再做冗余策略了),AU Size是ASM每次分配的最小单位,安装的时候,磁盘组DATA只选择两个磁盘,可以做正常冗余


step5:这里设置ASM的密码,后面在ASM上安装oracle实例的时候要用到的


step6:选择相关的组


step7:选择相关的路径


step8:进行一些的验证,缺包的要安装包


step9:


step10:安装过程中,有段脚本需要用root的用户执行的



到此,ASM已经安装完成。后面将介绍如何管理ASM磁盘组和磁盘。




请使用浏览器的分享功能分享到微信等