【环境说明】本文档介绍在OEL6.3的环境下安装基于ASM 11.2.0.3的ORACLE数据库的安装;
虚拟机:VMware 10
OS:Oracle Linux Server release 6.3
DB:11.2.0.3
【一】操作系统的安装:这边省略
【二】准备工作
1、运行环境包的安装,挂载系统盘
[root@idbtcsv1222 Packages]# cd /media/OL6.3 x86_64 Disc 1 20120626/Packages
rpm -ivh compat-libcap1-1.10-1.x86_64.rpm
rpm -ivh compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
rpm -ivh libgcc-4.4.6-4.el6.i686.rpm
rpm -ivh kernel-headers-2.6.32-279.el6.x86_64.rpm
rpm -ivh glibc-headers-2.12-1.80.el6.x86_64.rpm
rpm -ivh glibc-devel-2.12-1.80.el6.x86_64.rpm
rpm -ivh libgomp-4.4.6-4.el6.x86_64.rpm
rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm
rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm
rpm -ivh cpp-4.4.6-4.el6.x86_64.rpm
rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm
rpm -ivh gcc-4.4.6-4.el6.x86_64.rpm
rpm -ivh libstdc++-devel-4.4.6-4.el6.x86_64.rpm
rpm -ivh gcc-c++-4.4.6-4.el6.x86_64.rpm
rpm -ivh libaio-devel-0.3.107-10.el6.x86_64.rpm
rpm -ivh libaio-devel-0.3.107-10.el6.i686.rpm
rpm -ivh xinetd-2.3.14-34.el6.x86_64.rpm
rpm -ivh rsh-server-0.17-60.el6.x86_64.rpm
rpm -ivh ksh-20100621-16.el6.x86_64.rpm
rpm -ivh tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64.rpm
2、修改参数文件
在/etc/sysctl.conf配置文件中添加如下:
kernel.shmall = 4294967296
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
#kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
net.ipv4.ip_local_port_range = 9000 65500
然后执行以下生效:
[root@db01 ~]# sysctl -p
在/etc/security/limits.conf配置文件中添加如下:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
在/etc/pam.d/login配置文件中添加:
session required pam_limits.so
在/etc/profile配置文件中添加:
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
关闭防火墙:service iptables stop
3、创建目录
[root@db01 ~]# mkdir -p /u01/app/oracle
[root@db01 ~]# chown -R oracle:oinstall /u01
[root@db01 ~]# chmod -R 775 /u01
4、创建用户和角色
[root@db01 Packages]# groupadd oinstall
[root@db01 Packages]# groupadd dba
[root@db01 Packages]# groupadd asmadmin
[root@db01 Packages]# groupadd asmdba
[root@db01 Packages]# useradd -g oinstall -G asmdba,asmadmin,dba grid
[root@db01 Packages]# useradd -g oinstall -G dba,asmdba oracle
[root@db01 Packages]# passwd grid
oracle如下:
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=rac
export PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin:/u01/app/oracle/product/11.2.0/dbhome_1/bin:/u01/app/oracle/product/11.2.0/dbhome_1/OPatch
4
grid如下
export ORACLE_BAS=/u01/app/grid
export ORACLE_HOME=/u01/app/grid/product/11.2.0/grid
export ORACLE_SID=+ASM
export PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin:/u01/app/grid/product/11.2.0/grid/bin:/u01/app/grid/product/11.2.0/grid/OPatch
5、创建硬盘,用于做ASM
虚拟机添加三块磁盘,不需要做其他操作
[root@db01 Packages]# fdisk -l
Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x00000000
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x0005e624
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 5222 41430016 8e Linux LVM
Disk /dev/sdc: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x00000000
Disk /dev/sdd: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x00000000
显示系统已有三块硬盘
[root@db01 Packages]# vi /etc/udev/rules.d/60-raw.rules
添加如下:
ACTION=="add", KERNEL=="sdb", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd", RUN+="/bin/raw /dev/raw/raw3 %N"
KERNEL=="raw*", OWNER="grid" GROUP="dba", MODE="0660"
【三】安装GRID,ORACLE从11G开始,当需要使用ASM、RAC功能的时候就需要安装单独的GRID,ORACLE Patchset有7个文件
第一二个包表示database,升级和安装数据库,只需要这2个文件即可。
第三个包表示grid,用来升级RAC 的CRS。安装RAC和ASM需要这个文件
第四个表示客户端,
第五个表示gateways,
第六个表示 examples, 这个是我们的示例文件安装包。
第七个表示deinstall
安装截图:
[grid@db01 ~]$ sqlplus / as sysasm
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
+ASM MOUNT
【四】安装数据库,安装的步骤跟普通安装的步骤是一样的,主要是以下这个截图需要注意
【五】ASM常用SQL语句
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATA/rac/datafile/users.259.896831997
+DATA/rac/datafile/undotbs1.258.896831997
+DATA/rac/datafile/sysaux.257.896831997
+DATA/rac/datafile/system.256.896831997
SQL> select name,total_mb,state from v$asm_diskgroup;
NAME TOTAL_MB STATE
------------------------------ ---------- -----------
DATA 92160 CONNECTED
SQL> select instance_name,db_name,status from v$asm_client;
INSTANCE_NAME B_NAME STATUS
-------------------- ------------- -----------
+ASM rac CONNECTED