首页 > 代码库 > 关于安装Oracle 11.2.0.1 RAC的笔记

关于安装Oracle 11.2.0.1 RAC的笔记

这是第一次安装RAC,参考了国外一位大神的安装文档,在安装过程中,也遇到了一些问题,从网上查了相关问题的解决方法,在此感谢。

操作系统是 Oracle Enterprise Linux 5,两个节点 rac1和rac2,网卡eth0作为public,eth1作为private,假设之前已添加一块20G容量的共享磁盘。

关于Oracle Enterprise Linux 下载,可以在https://edelivery.oracle.com/osdc/faces/Home.jspx登陆后下载。

主机配置

所有命令在root用户下执行。

配置共享存储。共享存储可视为/dev/sdb设备。将使用fdisk命令创建两个10G大小的两个分区。 两个新的分区将用于ASM。

--list devices

ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb
--add two partitions

fdisk /dev/sdb

The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):   
Using default value 1
Last cylinder or +size or +sizeM 
or +sizeK (1-2610, default 2610): +10240M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1247-2610, default 1247): 
Using default value 1247
Last cylinder or +size or +sizeM or +sizeK (1247-2610, default 2610): 
Using default value 2610

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
--list new partitions

fdisk -l /dev/sdb

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        1246    10008463+  83  Linux
/dev/sdb2            1247        2610    10956330   83  Linux

添加组

--required groups
/usr/sbin/groupadd -g 501 oinstall
/usr/sbin/groupadd -g 502 dba
/usr/sbin/groupadd -g 503 oper

添加Oracle用户

/usr/sbin/useradd -u 502 -g oinstall -G dba oracle

修改Oracle用户密码

passwd oracle

在 /etc/sysctl.conf下添加内核参数

#kernel parameters for 11g installation
kernel.shmmni = 4096 
kernel.shmmax = 4398046511104
kernel.shmall = 1073741824
kernel.sem = 250 32000 100 128

fs.aio-max-nr = 1048576
fs.file-max = 6815744
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 = 1048586

应用内核参数

/sbin/sysctl -p

为用户Oracle在/etc/security/limits.conf文件中添加以下行以设置shell限制

--shell limits for users oracle 11gR2
oracle   soft   nproc    131072
oracle   hard   nproc    131072
oracle   soft   nofile   131072
oracle   hard   nofile   131072
oracle   soft   core     unlimited
oracle   hard   core     unlimited
oracle   soft   memlock  50000000
oracle   hard   memlock  50000000

“/ etc / hosts”文件必须包含服务器的完全限定名称。

<IP-address>  <fully-qualified-machine-name>  <machine-name>

“/ etc / hosts”下输入以下数据

127.0.0.1     localhost.localdomain localhost
#public
192.168.0.50  rac1.dbaora.com      rac1
192.168.0.51  rac2.dbaora.com      rac2
#private
192.168.1.60  rac1-priv.dbaora.com rac1-priv
192.168.1.61  rac2-priv.dbaora.com rac2-priv
#virtual
192.168.0.70 rac1-vip.dbaora.com  rac1-vip
192.168.0.71 rac2-vip.dbaora.com  rac2-vip
#scan
192.168.0.20 rac-scan.dbaora.com  rac-scan

验证rac1.dbaora.com上的th0和eth1的网络响应

[root@rac1 ~]# ping rac1 -c 1
PING rac1.dbaora.com (192.168.0.50) 56(84) bytes of data.
64 bytes from rac1.dbaora.com (192.168.0.50): 
icmp_seq=1 ttl=64 time=0.032 ms

--- rac1.dbaora.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.032/0.032/0.032/0.000 ms

[root@rac1 ~]# ping rac1-priv -c 1
PING rac1-priv.dbaora.com (192.168.1.60) 56(84) bytes of data.
64 bytes from rac1-priv.dbaora.com (192.168.1.60): 
icmp_seq=1 ttl=64 time=0.036 ms

--- rac1-priv.dbaora.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.036/0.036/0.036/0.000 ms

检查哪些软件包已安装,哪些软件包缺失

rpm -q --qf %{NAME}-%{VERSION}-%{RELEASE}(%{ARCH})\n binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel

安装缺失的包。 这只是一个例子:

#directory with mounted Oracle Enterprise Linux 5 install disk

cd <path with Oracle Enterprise Linux 5>/Server/Packages

#install missed packages (example for package unixODBC*)

rpm -Uvh unixODBC*

禁用Secure Linux

要禁用Secure Linux编辑“/etc/selinux/config”文件,确保SELINUX设置如下,它需要重启才能有效。

SELINUX=disabled

禁用Firewall

可以在图形模式下或手动禁用防火墙。

执行下面的命令手动禁用

service iptables stop
chkconfig iptables off

更改NTP

需要禁用NTP(Network Time Protocol)或修改其设置,以便Oracle Cluster Time Synchronization Service(ctssd)可以同步RAC节点的时间。

选项1 - 禁用NTP

service ntpd stop
Shutting down ntpd:                                        [  OK  ]
chkconfig ntpd off
mv /etc/ntp.conf /etc/ntp.conf.orig
rm /var/run/ntpd.pid

选项2 - 更改NTP

如果要保留NTP,请在“/etc/sysconfig/ntpd”文件中添加“-x”选项。

OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

并重新启动NTP

# service ntpd restart

在操作系统安装过程中,可以禁用 SElinux、Firewall,不启动NTP,这样在主机配置中可省略。

目录

创建ORACLE_BASE

mkdir -p /ora01/app/oracle

为grid和database软件创建ORACLE_HOME

mkdir -p /ora01/app/oracle/product/11.2.0/db_1
mkdir -p /ora01/app/grid/product/11.2.0/grid

chown oracle:oinstall -R /ora01
chmod 775 /ora01/app/oracle

Oracle用户新的配置文件

修改Oracle配置文件 /home/oracle/.bash_profile

# .bash_profile

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

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

alias genv=. /home/oracle/.bash_profile_grid;envo
alias denv=. /home/oracle/.bash_profile_database;envo

. /home/oracle/.bash_profile_database

envo

 这里添加了两个别名:genv和denv,这样可以方便地切换grid和database软件环境。

为Oracle用户添加新的配置文件 /home/oracle/.bash_profile_grid。此配置文件将用于grid软件。

# Oracle Settings
export TMP=/tmp

export ORACLE_HOSTNAME=rac1.dbaora.com
export ORACLE_UNQNAME=+ASM
export ORACLE_BASE=/ora01/app/oracle
export ORACLE_HOME=/ora01/app/grid/product/11.2.0/grid
export ORACLE_SID=+ASM1

PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;

alias cdob=cd $ORACLE_BASE
alias cdoh=cd $ORACLE_HOME
alias tns=cd $ORACLE_HOME/network/admin
alias envo=env | grep ORACLE

为Oracle用户添加新的参数文件 /home/oracle/.bash_profile_database. 此配置文件将用于database软件。

# Oracle Settings
export TMP=/tmp

export ORACLE_HOSTNAME=rac1.dbaora.com
export ORACLE_UNQNAME=ORA11G
export ORACLE_BASE=/ora01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=ORA11G1

PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;

alias cdob=cd $ORACLE_BASE
alias cdoh=cd $ORACLE_HOME
alias tns=cd $ORACLE_HOME/network/admin
alias envo=env | grep ORACLE

umask 022

在rac2中,将两个参数文件的ORACLE_HOSTNAME和ORACLE_SID更改为本服务器的参数值。

记住修改所有配置文件的所有者

chown oracle:oinstall /home/oracle/.bash*
chmod 750 oracle:oinstall /home/oracle/.bash*

作为oracle用户解压database和grid软件。 创建2个目录:

  • database – database software
  • grid – grid software

切换到grid软件环境,以root用户身份安装软件包cvuqdisk-1.0.9-1.rpm

cd <install grid software>/rpm
[root@rac1 rpm]# rpm -Uvh cvuqdisk-1.0.9-1.rpm
Preparing...                ############################## [100%]
Using default group oinstall to install package
   1:cvuqdisk               ############################## [100%]

配置ASM设备

要配置ASMlib,首先需要从OTN下载ASMLib rpms。 如果使用的是UEK内核,则所有必需的rpms都已安装。

  • oracleasm-support-2.1.8-1.el5.i386.rpm
  • oracleasmlib-2.0.4-1.el5.i386.rpm
  • oracleasm-[your-kernel-version].rpm

关于oracleasm-supper和orcleasmlib软件包版本,可以根据操作系统版本从http://www.oracle.com/technetwork/server-storage/linux/asmlib/index-101839.html下载软件包。

而oracleasm软件包要根据操作系统内核参数来决定:

name -a

这里是Oracle通过配置YUM来安装oracleasm软件包的链接:

http://www.oracle.com/technetwork/server-storage/linux/downloads/rhel5-084877.html

使用以下命令安装软件包

rpm -Uvh oracleasm*.rpm

安装完成后可以通过rpm -qa | grep oracleasm命令验证。

配置SMlib

[root@rac1 ~]# /usr/sbin/oracleasm configure -i
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 []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: 
Writing Oracle ASM library driver configuration: done

加载asm内核模块

[root@rac1 ~]# /usr/sbin/oracleasm init
Loading module "oracleasm": oracleasm
Mounting ASMlib driver filesystem: /dev/oracleasm

添加ASM磁盘

[root@rac1 ~]# /usr/sbin/oracleasm createdisk DISK1 /dev/sdb1
Writing disk header: done
Instantiating disk: done
[root@rac1 ~]# /usr/sbin/oracleasm createdisk DISK2 /dev/sdb2
Writing disk header: done
Instantiating disk: done

扫描ASM磁盘

[root@rac1 ~]# /usr/sbin/oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...

列出ASM磁盘

[root@rac1 ~]# /usr/sbin/oracleasm listdisks
DISK1
DISK2

这里是使用oracleasm配置ASM磁盘,也可以同过udev来配置,在使用oracleasm时遇到一些bug,推荐使用udev。

现在在每个节点上运行下面命令验证网络:rac1.dbaora.com和rac2.dbaora.com

hostname
ping rac1 -c 1
ping rac2 -c 1
ping rac1-priv -c 1
ping rac2-priv -c 1

安装grid软件

以用户oracle启动grid软件安装,在此之前以root身份运行命令xhost +。

xhost +
access control disabled, clients can connect from any host

设置grid环境并运行grid安装软件

su - oracle

[oracle@rac1 ~]$ genv
ORACLE_UNQNAME=+ASM
ORACLE_SID=+ASM1
ORACLE_BASE=/ora01/app/oracle
ORACLE_HOSTNAME=rac1.dbaora.com
ORACLE_HOME=/ora01/app/grid/product/11.2.0/grid

--run installation 
cd <install grid software>
./runInstall

关于安装过程,可以根据实际需要选择,这里省略。

这里如果是使用linux 6以上版本,在最后执行root.sh脚本时,会用一个BUG,具体解决方法如下

1.删除配置:

/ora01/app/grid/product/11.2.0/gridl/roothas.pl -deconfig -force-verbose

路径是grid环境的ORACLE_HOME。

出现Adding daemon to inittab这条信息的时候执行dd命令

/bin/dd if=/var/tmp/.oracle/npohasd of=/dev/null bs=1024 count=1

如果是安装11.2.0.1的话,还是建议 使用 linux 5的版本。

ASM configuration assistant

到目前为止,只创建了一个ASM组DATA。下面展示如何快速添加额外的组到ASM实例。

在以Oracle用户启动ASMCA之前, 切换到root用户执行xhost +命令。

ASMCA - ASM configuration assistant是grid软件的一部分,因此必须设置正确的环境

su - oracle

[oracle@rac1 ~]$ genv
ORACLE_UNQNAME=+ASM
ORACLE_SID=+ASM1
ORACLE_BASE=/ora01/app/oracle
ORACLE_HOSTNAME=rac1.dbaora.com
ORACLE_HOME=/ora01/app/grid/product/11.2.0/grid

[oracle@rac1 ~]$ asmca

根据需要一步步执行就可以了,安装步骤省略。

在你可以在sqlplus中验证你有2个ASM组。

[oracle@rac1 ~]$ sqlplus

SQL*Plus: Release 11.2.0.3.0 Production on Sun Jun 16 22:39:11 2013
Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter user-name: / as sysasm

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit 
Production With the Automatic Storage Management option

SQL> select name from v$asm_diskgroup;

NAME
------------------------------
DATA
BACKUP

安装Database软件

作为Oracle用户开始database软件安装。设置database软件爱你环境

su - oracle

[oracle@rac1 ~]$ denv 
ORACLE_UNQNAME=ORA11G 
ORACLE_SID=ORA11G1 
ORACLE_BASE=/ora01/app/oracle 
ORACLE_HOSTNAME=rac1.dbaora.com 
ORACLE_HOME=/ora01/app/oracle/product/11.2.0/db_1

--run installation 
cd <install database software>
./runInstall

安装步骤省略。

在安装过程中,遇到一个有关监听器的问题,提示

default listener is not configured in grid infrastructure home

解决方法链接http://www.cnblogs.com/jimeper/p/3746301.html

验证RAC安装

[root@rac1 ~]# su - oracle
[oracle@rac1 ~]$ genv
ORACLE_UNQNAME=+ASM
ORACLE_SID=+ASM1
ORACLE_BASE=/ora01/app/oracle
ORACLE_HOSTNAME=rac1.dbaora.com
ORACLE_HOME=/ora01/app/grid/product/11.2.0/grid

[oracle@rac1 ~]$ srvctl config database -d ORA11G
Database unique name: ORA11G
Database name: ORA11G
Oracle home: /ora01/app/oracle/product/11.2.0/db_1
Oracle user: oracle
Spfile: +DATA/ORA11G/spfileORA11G.ora
Domain: dbaora.com
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: ORA11G
Database instances: ORA11G1,ORA11G2
Disk Groups: DATA
Mount point paths: 
Services: 
Type: RAC
Database is administrator managed

[oracle@rac1 ~]$ srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): rac2,rac1

[oracle@rac1 ~]$ srvctl status asm
ASM is running on rac2,rac1

[oracle@rac1 ~]$ srvctl status database -d ORA11G
Instance ORA11G1 is running on node rac1
Instance ORA11G2 is running on node rac2

 

葡萄美酒夜光杯,欲饮琵琶马上催;

醉卧沙场君莫笑,古来征战几人回。

 

 

 

 

 


 

 

   

 

  

  

 

关于安装Oracle 11.2.0.1 RAC的笔记