11g oracle database installation with oracle grid infrastructure on linux
一、预装oracle database 准备
安装11g oracle database所需的linux软件包
binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-common-2.5
glibc-devel-2.5
glibc-headers-2.5
ksh-20060214
libaio-0.3.106
libaio-devel-0.3.106
libgcc-4.1.2
libstdc++-4.1.2
libstdc++-devel 4.1.2
make-3.81
sysstat-7.0.2
官档地址:
http://docs.oracle.com/cd/E11882_01/install.112/e24321/pre_install.htm#i1011296
安装命令执行
yum install binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibcglibc-common glibc-devel glibc-headers ksh-20060214 libaio libaio-devel libgcc libstdc++- libstdc++-devel make-3.81 sysstat unixODBC unixODBC-devel
(unixODBC,unixODBC-devel是ODBC的支持包;ODBC更多解释:http://zh.wikipedia.org/zh-cn/ODBC)
安装cvuqdisk包(Cluster Verification Utility find shared disks)
[root@doudou-32bit tmp]# cd /opt/grid/rpm/
[root@doudou-32bit rpm]# export CVUQDISK_GRP=oinstall
[root@doudou-32bit rpm]# rpm -iv cvuqdisk-1.0.7-1.rpm
建立oracle产品组,root用户
vi /etc/oraInst.loc
inventory_loc=/u01/app/oraInventory
inst_group=oinstall
DNS解析,直接配置hosts文件
vi /etc/hosts
192.168.1.217 doudou doudou
磁盘要求,请看附表
内存和SWAP要求
--oracle database--
Minimum: 1 GB of RAM
Recommended: 2 GB of RAM or more
SWAP建议
RAM |
Swap Space |
Between 1 GB and 2 GB |
1.5 times the size of the RAM |
Between 2 GB and 16 GB |
Equal to the size of the RAM |
More than 16 GB |
16 GB |
--Oracle grid infrastructure--
RAM>=1.5G oracle grid
RAM>=2.5G oracle grid + oracle database
RAM>=4G oracle grid + oracle rac
SWAP建议
Available RAM |
Swap Space Required |
Between 2.5 GB and 32 GB |
Equal to the size of RAM |
More than 32 GB |
32 GB of RAM |
查看当前swap
grep SwapTotal /proc/meminfo
注:在线增加swap,请看附表增加swap
查看当前shmfs
df -h /dev/shm
注:oracle 11g AMM 使用内存需要通过更多的共享内存
(如需增加/dev/shm请看附表增加/dev/shm)
建立组
/usr/sbin/groupadd -g 501 oinstall
/usr/sbin/groupadd -g 502 dba
/usr/sbin/groupadd -g 503 oper
/usr/sbin/groupadd -g 504 asmadmin
/usr/sbin/groupadd -g 505 asmoper
/usr/sbin/groupadd -g 506 asmdba
建立用户
/usr/sbin/useradd -u 501 -g oinstall -G dba,oper,asmdba oracle
/usr/sbin/useradd -u 8001 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
修改密码
passwd oracle
passwd grid
注:具体组和用户含义请看附表Overview of Groups and Users
用户环境变量
--oracle---
vi .bash_profile
export ORACLE_SID=doudou
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export TMP=/tmp
export TMPDIR=/u01/tmp
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:
umask 022
--grid--
vi .bash_profile
export ORACLE_SID=+ASM
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=$ORACLE_BASE/11.2.0/dbhome_1
export TMP=/tmp
export TMPDIR=/u01/tmp
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:
umask 022
注:tmp空间不足时,添加TMPDIR;可以看附表增大tmp
建立目录
--oracle database--
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01/app/oracle
chown oracle:oinstall /u01/app/oraInventory
--oracle grid infrastructure--
mkdir -p /u01/app/grid
mkdir -p /u01/app/11.2.0/grid
chown -R grid:oinstall /u01/app/grid
chmod -R 775 /u01
注:具体目录含义请看附表Overview of directories
安装用户资源限制
vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
对默认的shell启动文件进行更改,以便oracle安装所有者的 ulimit设置
[root@doudou-32bit ~]# vi /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
umask 022
fi
更改内核参数值
vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 524288
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
执行sysctl -p 立即生效
注: shmall and shmmax解释请看附表 shmall and shmmax
二、ASM DISK(openfiler模拟存储服务器)
1、 使用udev制作ASM DISK
2、 使用asmlib制作 ASM DISK
制作partitions
fdisk -l --(查看识别的硬盘)
具体制作partition具体步骤如下:
fdisk /dev/sda
n
p
1
回车
回车
w
partprobe /dev/sda1
其他分区省略
1、 使用udev制作ASM DISK
制作完分区后,使用udev固化iscsi磁盘设备名称
查看存储磁盘scsi_id(scsi_id具有唯一性)
[root@localhost rules.d]# scsi_id -g -u -s /block/sdb
14f504e46494c4500764a6b65714e2d416b5a432d314d6753
[root@localhost rules.d]# scsi_id -g -u -s /block/sdc
14f504e46494c45004532476568362d566f35702d35303470
创建新的 vi /etc/udev/rules.d/99-oracle-asmdevices.rules
[root@localhost rules.d]# cat /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="14f504e46494c4500764a6b65714e2d416b5a432d314d6753", NAME="asm_data-1", WNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="14f504e46494c45004532476568362d566f35702d35303470", NAME="asm_data-2", WNER="grid", GROUP="asmadmin", MODE="0660"
[root@doudou ~]# start_udev start
启动 udev:[确定]
[root@localhost rules.d]# ls -l /dev/asm*
brw-rw---- 1 grid asmadmin 8, 16 05-03 17:58 /dev/asm_data-1
brw-rw---- 1 grid asmadmin 8, 32 05-03 17:58 /dev/asm_data-2
OK到此我们使用udev制作的ASM DISK完成
注:个人推荐使用udev制作ASM DISK
至于什么不使用asmlib?可以看看maclean liu的见解
http://www.askmaclean.com/archives/why-asmlib-and-why-not.html
2、使用asmlib制作 ASM DISK
2-1.查看操作系统版本
[root@doudou-32bit ~]# uname -rm
2.6.18-348.3.1.el5 i686
2-2.下载相关的asmlib包
http://www.oracle.com/technetwork/topics/linux/asmlib/index-101839.html
oracleasm-2.6.18-348.3.1.el5-2.0.5-1.el5.i686.rpm
oracleasm-2.6.18-348.3.1.el5debug-2.0.5-1.el5.i686.rpm
oracleasm-2.6.18-348.3.1.el5PAE-2.0.5-1.el5.i686.rpm
oracleasm-2.6.18-348.3.1.el5xen-2.0.5-1.el5.i686.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-support-2.1.8-1.el5.i386.rpm
安装包过程省略
2-3.配置oracleasm
[root@doudou-32bit ~]# /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 []: grid
Default group to own the driver interface []: asmadmin
Start Oracle ASM library driver on boot (y/n) [y]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [ OK ]
Scanning the system for Oracle ASMLib disks: [ OK ]
2-4.使用oracleasm创建ASM DISK
[root@doudou-32bit ~]# /etc/init.d/oracleasm createdisk DISK1 /dev/sda1
其余省略
[root@doudou-32bit ~]# /etc/init.d/oracleasm listdisks
DISK1
DISK2
DISK3
DISK4
DISK5
DISK6
DISK7
DISK8
OK到此使用asmlib制作ASM DISK完成
安装oracle grid infrastructure
[root@doudou-32bit ~]# su – grid
[grid@doudou-32bit ~]$ export DISPLAY=192.168.1.25:0.0
[grid@doudou-32bit grid]$ ./runInstaller
图形安装过程省略
需要注意的是,oracle asm 提供了3种冗余
External redundancy --1个ASM DISK即可(磁盘有raid支持情况下)每个磁盘无大小要求
Normal redundancy --2个ASM DISK必须(没有raid建议使用)EACH ASM DISK SIZE 1:1
High redundancy --3个ASM DISK必须(没有raid建议使用) EACH ASM DISK SIZE 1:1:1
[grid@doudou-32bit grid]$ sqlplus / as sysasm
SQL*Plus: Release 11.2.0.1.0 Production on Thu Apr 18 14:26:05 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Automatic Storage Management option
SQL> select name,state,type,total_mb,free_mb,usable_file_mb from v$asm_diskgroup;
NAME STATE TYPE TOTAL_MB FREE_MB USABLE_FILE_MB
---------- ----------- ------ ---------- ---------- --------------
DATA MOUNTED NORMAL 30708 30529 15234 --为可用空间
REDO MOUNTED EXTERN 511 459 459
注:USABLE_FILE_MB 为ASM DISK 磁盘组真实可用空间
安装oracle database
[root@doudou-32bit ~]# su - oracle
[oracle@doudou-32bit ~]$ export DISPLAY=192.168.1.25:0.0
[oracle@doudou-32bit database]$ ./runInstaller
图形安装过程省略
需要注意的是:database 字符集的选择
附表
11g Oracle Database installation with Oracle grid infrastructure
磁盘要求
oracle database磁盘最小需求
The following tables describe the disk space requirements for software files and data files for each installation type on Linux x86:
Installation Type |
Requirement for Software Files (GB) |
Enterprise Edition |
3.95 |
Standard Edition |
3.88 |
Installation Type |
Disk Space for Data Files (GB) |
Enterprise Edition |
1.7 |
Standard Edition |
1.5 |
官档地址:
http://docs.oracle.com/cd/E11882_01/install.112/e24321/pre_install.htm#autoId12
oracle grid infrastructure磁盘最小要求
At least 5.5 GB of disk space.
At least 1 GB of space in the /tmp directory.
Overview of Groups and Users
功能 |
操作系统组名 |
备注 |
Oracle Inventory Group |
oinstall |
|
OSDBA Group for Database Installations |
dba |
|
OSOPER Group for Database Installations |
oper |
|
OSASM Group for Oracle Automatic Storage Management |
asmadmin |
连接Oracle ASM 实例 |
OSDBA Group for Oracle Automatic Storage Management |
asmdba |
必须组 |
OSOPER Group for Oracle Automatic Storage Management |
asmoper |
可选组 |
*********************************************** |
************ |
******************* |
功能 |
操作系统用户 |
备注 |
Oracle Software Owner User |
oracle |
|
Oracle grid infrastructure Software Owner User |
grid |
|
官档地址:
http://docs.oracle.com/cd/E11882_01/install.112/e24321/pre_install.htm#BABHHEJD
下面是oracle技术文档中的解释更为详细精准
Description |
OS Group Name |
OS Users Assigned to this Group |
Oracle Privilege |
Oracle Group Name |
Oracle Inventory and Software Owner |
oinstall |
grid, oracle |
|
|
Oracle Automatic Storage Management Group |
asmadmin |
grid |
SYSASM |
OSASM |
ASM Database Administrator Group |
asmdba |
grid, oracle |
SYSDBA for ASM |
OSDBA for ASM |
ASM Operator Group |
asmoper |
grid |
SYSOPER for ASM |
OSOPER for ASM |
Database Administrator |
dba |
oracle |
SYSDBA |
OSDBA |
Database Operator |
oper |
oracle |
SYSOPER |
OSOPER |
Overview of directories
目录名 |
模版 |
建立的目录 |
Oracle base directory |
/mount_point/app/software_owner |
/u01/app/oracle |
Oracle inventory directory |
ORACLE_BASE/oraInventory |
/u01/app/oracle/oraInventory |
Oracle home directory |
ORACLE_BASE/product/11.2.0/dbhome_1 |
/u01/app/oracle/product/11.2.0/dbhome_1 |
************************* |
*********************************** |
**************** |
Oracle Grid Infrastructure base directory |
/mount_point/app/software_owner |
/u01/app/grid |
Oracle Grid Infrastructure inventory directory |
ORACLE_BASE/oraInventory |
/u01/app/grid/oraInventory |
Oracle Grid Infrastructure home directory |
/u01/app/11.2.0/grid |
/u01/app/11.2.0/grid |
官档地址:
http://docs.oracle.com/cd/E11882_01/install.112/e24321/pre_install.htm#autoId52
增加/dev/shm
共享内存的标准:The size of the shared memory must be at least the greater of the MEMORY_MAX_TARGET and MEMORY_TARGET parameters for each Oracle instance on the computer.
[root@doudou-32bit ~]# df -h /dev/shm
文件系统 容量 已用 可用 已用% 挂载点
tmpfs 990M 154M 836M 16% /dev/shm
如果/dev/shm太小,我们可以添加/dev/shm
①暂时添加/dev/shm方法:mount -t tmpfs shmfs -o size=2g /dev/shm
②永久添加/dev/shm方法:vi /etc/fstab
尾部添加一行 shmfs /dev/shm tmpfs size=2g 0
我使用的永久添加方法,可以不重启机器直接mount –a 立即生效/etc/fstab的内容
[root@doudou-32bit grid]# mount –a
增大/dev/shm的结果展示
[root@doudou-32bit ~]# df -h /dev/shm
文件系统 容量 已用 可用 已用% 挂载点
shmfs 2.0G 0 2.0G 0% /dev/shm
官档地址:
http://docs.oracle.com/cd/E11882_01/install.112/e24321/pre_install.htm#autoId10
shmall and shmmax
shmall:physical memory/PAGESIZE
shmmax:Recommended: More than half the physical memory
这个shmmax参数是限制shared memory segments (mos 567506.1),可不要认为这个参数是限制SGA或memory_max_target
官档地址:
http://docs.oracle.com/cd/E11882_01/install.112/e24321/pre_install.htm#autoId50
增大tmp
mkdir -p /u01/tmp
chmod -R a+wr /u01/tmp
用户环境变量
export TMPDIR=/u01/tmp
在线增加swap
1、建立交换分区目录
mkdir -p /opt/image
2、建立swap所需文件(以2G为例)
dd if=/dev/zero f=/opt/image/swap bs=1024 count=2048000
3、创建交换空间,使用命令nkswap
nkswap /opt/image/swap
4、启动新增交换空间,使用命令swapon
swapon /opt/image/swap
5、查看是否添加成功
free -m
6、修改/etc/fstab文件,设置永久型swap即开机自动挂载
vi /etc/fstab
尾部添加
/opt/image/swap swap swap defaults 0 0
7、不重启,直接挂载验证/etc/fstab修改结果
mount -a
free -m