Linux安装单实例Oracle11g ASM
环境: OS:Redhat 5.5 64Bit DB:Oracle 11.2.0.3 64Bit Grid/Database VM 虚拟机 说明:在Oracle10g 版本中两种是在一个介质中,11g是分为两个介质。 步骤: 1:Linux系统磁盘管理(磁盘组、裸设备等) 2:Grid软件安装 3:Database软件安装 4:ASM管理 一
环境:
OS:Redhat 5.5 64Bit
DB:Oracle 11.2.0.3 64Bit Grid/Database
VM 虚拟机
说明:在Oracle10g 版本中两种是在一个介质中,11g是分为两个介质。
步骤:
1:Linux系统磁盘管理(磁盘组、裸设备等)
2:Grid软件安装
3:Database软件安装
4:ASM管理
一:Linux系统磁盘管理
一般情况下,我们都是在我的虚拟机做实验,所以,我一开始规划了硬盘存储比如40GB,安装完Linux操作系统,系统只有一个sda,而且默认情况下这个容量不能再分配空间了,我们需要再添加一块硬盘,使用fdisk命令如下
[root@asm ~]# fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 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 5221 41833260 8e Linux LVM Disk /dev/sdb: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 974 7823623+ 83 Linux /dev/sdb2 975 1948 7823655 83 Linux新添加的一块磁盘 sdb 20GB ,我们就在这个磁盘上进行测试,我可以在sdb磁盘上创建分区,设置分区大小比如创建sdb1(8G),sdb2(8G)
root@asm ~]# fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). ----------输入m 查看帮助 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) -------------输入p查看 Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xf9f81f26 Device Boot Start End Blocks Id System -----------输入n新建分区(e是扩展分区,p是主要分区) Command (m for help): n Command action e extended p primary partition (1-4)
-----------创建主分区,输入分区号1,设置大小+8G p Partition number (1-4): 1 First cylinder (1-2610, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +8G Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xf9f81f26 Device Boot Start End Blocks Id System /dev/sdb1 1 1045 8393931 83 Linux Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (1046-2610, default 1046): Using default value 1046 Last cylinder, +cylinders or +size{K,M,G} (1046-2610, default 2610): +8G Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xf9f81f26 Device Boot Start End Blocks Id System /dev/sdb1 1 1045 8393931 83 Linux /dev/sdb2 1046 2090 8393962+ 83 Linux -----------输入w保存 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
创建了两个分区,我们需要进行一个操作partprobe。
原因:linux上,在安装系统之后,创建分区并且在不重新启动机器的情况下系统能够识别这些分区需要使用partprobe。
到目前为止,我们的这些分区
1:可以直接Mount路径进行文件系统的存储
使用分区,要进行格式化,比如下面是格式化为ext3的文件系统mkfs.ext3 /dev/sdb1
2:Oracle数据库挂接裸设备
下面是怎么将分区文件映射为裸设备,我们需要在如下文件添加记录
[root@asm ~]# more /etc/udev/rules.d/60-raw.rules # Enter raw device bindings here. # # An example would be: # ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N" # to bind /dev/raw/raw1 to /dev/sda, or # ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw 2 %M %m" # to bind /dev/raw/raw2 to the device with major 8, minor 1. ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N" ACTION=="add", KERNEL=="sdb2", RUN+="/bin/raw /dev/raw/raw2 %N" KERNEL=="raw*", OWNER="grid" GROUP="dba", MODE="0660"前两行是将我新创建的分区映射为不同的raw
然后是将我的文件权限赋予grid用户(后面安装Grid需要创建)
执行完毕,保存文件需要重启一下服务 start_udev
然后查看raw路径
[root@asm ~]# ls /dev/raw raw1 raw2
二:安装Grid软件
其实安装Grid软件,比较简单,如果安装过DB软件,基本上一样,在安装界面有几个需要注意
1:创建grid用户 所属dba组
2:安装软件,在安装过程中需要注意如下界面
创建ASM磁盘组,名字griddg,选择相关的裸设备raw1
剩下的基本默认安装即可
3:配置一下grid用户的环境变量
安装完毕之后,可以查看操作系统是否有asm进程
[grid@asm ~]$ ps -ef | grep asm avahi 3322 1 0 11:03 ? 00:00:00 avahi-daemon: running [asm.local] grid 26982 1 0 12:51 ? 00:00:00 asm_pmon_+ASM grid 26984 1 0 12:51 ? 00:00:00 asm_psp0_+ASM grid 26986 1 0 12:51 ? 00:00:00 asm_vktm_+ASM grid 26990 1 0 12:51 ? 00:00:00 asm_gen0_+ASM grid 26992 1 0 12:51 ? 00:00:00 asm_diag_+ASM grid 26994 1 0 12:51 ? 00:00:00 asm_dia0_+ASM grid 26996 1 0 12:51 ? 00:00:00 asm_mman_+ASM grid 26998 1 0 12:51 ? 00:00:00 asm_dbw0_+ASM grid 27000 1 0 12:51 ? 00:00:00 asm_lgwr_+ASM grid 27002 1 0 12:51 ? 00:00:00 asm_ckpt_+ASM grid 27004 1 0 12:51 ? 00:00:00 asm_smon_+ASM grid 27006 1 0 12:51 ? 00:00:00 asm_rbal_+ASM grid 27008 1 0 12:51 ? 00:00:00 asm_gmon_+ASM grid 27010 1 0 12:51 ? 00:00:00 asm_mmon_+ASM grid 27012 1 0 12:51 ? 00:00:00 asm_mmnl_+ASM grid 27081 27056 0 12:56 pts/4 00:00:00 grep asm同样,也可以连接sqlplus,查询相关视图信息
login as: grid grid@192.168.100.203's password: Last login: Wed Dec 11 12:36:47 2013 from 192.168.100.111 -----------这里面必须使用sysasm来登录而不能使用sysdba [grid@asm ~]$ sqlplus / as sysasm SQL*Plus: Release 11.2.0.3.0 Production on Wed Dec 11 13:07:41 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Automatic Storage Management option SQL> set line 2000 SQL> set long 2000 ---------查看磁盘状态,现在是两个裸设备Raw1和raw2,raw1已经被使用了创建griddg磁盘组了 SQL> select name,path from v$asm_disk; NAME PATH ------------------------------ ------------------ /dev/raw/raw2 GRIDDG_0000 /dev/raw/raw1 -----------查看磁盘组状态,可以看到griddg是mounted状态 SQL> select name ,state from v$asm_diskgroup; NAME STATE ------------------------------ ----------- GRIDDG MOUNTED
关于ASM的相关视图,可以参考如下
同样,ASM也提供了ASMCMD命令来让用户更好的管理ASM
[grid@asm ~]$ asmcmd ASMCMD> help asmcmd [-V] [-v] [--privilege ] [-p] [command] asmcmd_no_conn_str Starts asmcmd or executes the command asmcmd [-V] [-v] [--privilege ] [-p] [command] The environment variables ORACLE_HOME and ORACLE_SID determine the instance to which the program connects, and ASMCMD establishes a bequeath connection to it, in the same manner as a SQLPLUS / AS SYSASM. The user must be a member of the OSASM group. Specifying the -V option prints the asmcmd version number and exits immediately. Specifying the -v option prints extra information that can help advanced users diagnose problems. Specify the --privilege option to choose the type of connection. There a re only two possibilities: connecting as SYSASM or as SYSDBA. The default value if this option is unspecified is SYSASM. Specifying the -p option allows the current directory to be displayed in the command prompt, like so: ASMCMD [+DATA/ORCL/CONTROLFILE] > [command] specifies one of the following commands, along with its parameters. Type "help [command]" to get help on a specific ASMCMD command.'; commands: -------- md_backup, md_restore lsattr, setattr cd, cp, du, find, help, ls, lsct, lsdg, lsof, mkalias mkdir, pwd, rm, rmalias chdg, chkdg, dropdg, iostat, lsdsk, lsod, mkdg, mount offline, online, rebal, remap, umount dsget, dsset, lsop, shutdown, spbackup, spcopy, spget spmove, spset, startup chtmpl, lstmpl, mktmpl, rmtmpl chgrp, chmod, chown, groups, grpmod, lsgrp, lspwusr, lsusr mkgrp, mkusr, orapwusr, passwd, rmgrp, rmusr volcreate, voldelete, voldisable, volenable, volinfo volresize, volset, volstat
三:安装DB软件
在安装DB软件之前,需要使用ASMCA来创建数据磁盘组
点击创建
创建完毕之后,我们就可以安装DB软件了
安装DB软件,我们选择先安装软件,后建库的模式
安装完软件,配置好oracle用户的环境变量,然后执行dbca,选择自定义建库模式
在选择数据库存储的时候 选择ASM,然后选择区域即可
我们可以使用sqlplus连接,查看文件存储位置来确认是否建库完毕
[oracle@asm ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Wed Dec 11 17:58:29 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- +DATADG/orcl/datafile/system.260.833896429 +DATADG/orcl/datafile/sysaux.261.833896455 +DATADG/orcl/datafile/undotbs1.262.833896477 +DATADG/orcl/datafile/users.264.833896499