灌溉梦想,记录脚步
« »
2012 年 07 月 16 日技术合集

在RedHat上安装Oracle 11gR2 RAC

oracle版本:11.2.0.1.0
grid版本:11.2.0.1.0
redhat版本:RedHat EL5 x86_64
存储方式:iscsi + asm

安装过程分以下四个步骤

一,安装准备
二,配置安装
三,相关设置
四,常见错误

一,安装准备
1,创建oracle用户

以root用户登录,并创建oracle用户以及所属的dba组

1
2
3
4
5
6
7
8
/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 -g oinstall -G dba,asmdba,oper oracle
/usr/sbin/useradd -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid

2,配置系统参数

编辑 /etc/sysctl.conf 文件并添加下列参数:

1
2
3
4
5
6
7
8
9
10
11
12
#ORACLE SETTING
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.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

编辑 /etc/pam.d/login 文件,并添加下行参数:

1
session required pam_limits.so

编辑 /etc/security/limits.conf 并添加下行参数:

1
2
3
4
5
6
7
8
9
#ORACLE SETTING
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

3,创建目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
mkdir /opt/app/
chown -R grid:oinstall /opt/app/
chmod -R 775 /opt/app/
mkdir -p /opt/app/oraInventory
chown -R grid:oinstall /opt/app/oraInventory
chmod -R 775 /opt/app/oraInventory
mkdir -p /opt/app/grid
mkdir -p /opt/app/oracle
chown -R grid:oinstall /opt/app/grid
chown -R oracle:oinstall /opt/app/oracle
chmod -R 775 /opt/app/oracle
chmod -R 775 /opt/app/grid
passwd grid
passwd oracle

4,设置环境变量

编辑 /home/oracle/.bash_profile 并添加下列行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Oracle Settings oracle
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/opt/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0; export ORACLE_HOME
ORACLE_SID=racdb1; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
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

保存后通过下面命令是配置生效

1
2
3
su - oracle
cd ~/或者
. .bash_profile

编辑 /home/grid/.bash_profile 并添加下列行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#grid 用户配置文件 ORACLE_HOSTNAME请自行设置
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_SID=+ASM1; export ORACLE_SID
ORACLE_BASE=/opt/app/oracle; export ORACLE_BASE
ORACLE_HOME=/opt/app/grid/product/11.2.0; export ORACLE_HOME
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
THREADS_FLAG=native; export THREADS_FLAG
PATH=$ORACLE_HOME/bin:$PATH; export PATH
THREADS_FLAG=native; export THREADS_FLAG
PATH=$ORACLE_HOME/bin:$PATH; export PATH
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

保存后通过下面命令是配置生效

1
2
3
su - grid
cd ~/或者
. .bash_profile

5,NTP配置

NTP服务器端配置:

1
2
3
4
5
6
7
8
9
10
restirct 152.42.36.11
restirct 152.42.36.12
restrict 127.0.0.1 
restrict -6 ::1
server 152.42.36.11 prefer 
server 152.42.36.12
server 127.127.1.0
fudge   127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys

NTP客户端配置:

1
2
3
4
restrict 136.49.38.102
restrict 136.49.38.103
server 136.49.38.102
server 136.49.38.103

6 、IP地址规划

1
2
3
4
5
6
7
8
9
10
11
12
127.0.0.1 localhost.localdomain localhost
#public ip
192.168.1.161 rac1
192.168.1.163 rac2
#priv ip
10.0.10.161 rac1_priv
10.0.10.162 rac2_priv
#vip ip
192.168.1.162 rac1-vip
192.168.1.164 rac2-vip
#scan ip
192.168.1.165 racscan

7 、SSH信任关系

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
在主节点RAC1上以grid,oracle用户分别执行下面命令:
1).生成用户的公匙和私匙
# su - oracle
$ mkdir ~/.ssh
$ ssh-keygen -t rsa
$ ssh-keygen -t dsa
2).在副节点RAC2、RAC3上执行相同的操作,确保通信无阻
# su - oracle
$ mkdir ~/.ssh
$ ssh-keygen -t rsa
$ ssh-keygen -t dsa
3).在主节点RAC1上oracle用户执行以下操作
$ cat ~/.ssh/id_rsa.pub >> ./.ssh/authorized_keys
$ cat ~/.ssh/id_dsa.pub >> ./.ssh/authorized_keys
$ ssh rac2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ ssh rac2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
$ scp ~/.ssh/authorized_keys rac2:~/.ssh/authorized_keys
4).主节点RAC1上执行检验操作
$ ssh rac1 date
$ ssh rac2 date
 
$ ssh rac1_priv date
$ ssh rac2_priv date
 
5).在副节点RAC2上执行检验操作
$ ssh rac1 date
$ ssh rac2 date
 
$ ssh rac1priv date
$ ssh rac2priv date

8 、ISCSI客户端配置

安装iscsi-initiator-utils软件包,设置iscsi进程开机自动启动

1
2
3
4
5
6
7
8
9
10
[root@rac1 ~]# yum install -y iscsi-initiator-utils.x86_64
[root@rac1 ~]# service iscsi start
iscsid is stopped
Turning off network shutdown. Starting iSCSI daemon:       [  OK  ]
                                                           [  OK  ]
Setting up iSCSI targets: iscsiadm: No records found!
                                                           [  OK  ]
[root@rac1 ~]# chkconfig iscsi on
[root@rac1 ~]# service iscsi status
iscsid (pid  29527) is running...

自动挂载iscsi脚本内容如下,挂载和卸载之前先发现,探测一次服务器端的共享是否正常

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[root@rac1 ~]# vi /etc/init.d/iscsiadmrules    
#!/bin/bash  
# chkconfig: - 20 85  
# Source function library.  
 
. /etc/rc.d/init.d/functions  
 
start() {  
echo -e "Starting Iscsiadmrules Server:\n"  
iscsiadm --mode discovery --type sendtargets --portal 10.0.0.52  
iscsiadm --mode node --targetname iqn.2011-12-15.com.hsf.data:shareddisk --portal 10.0.0.52:3260 --login  
}  
 
stop() {  
echo -e "Stopping Iscsiadmrules Server:\n"  
iscsiadm --mode discovery --type sendtargets --portal 10.0.0.52 
iscsiadm --mode node --targetname iqn.2011-12-15.com.hsf.data:shareddisk --portal 10.0.0.52:3260 --logout  
}  
 
case "$1" in  
 start)  
 start  
 ;;  
 
 stop)  
 stop  
 ;;  
esac  
exit 0  
[root@rac1 ~]# chmod  +x /etc/rc.d/init.d/iscsiadmrules

9、ASM存储相关配置

安装ASMLIB(所有节点)
oracleasm-2.6.18-194.el5-2.0.5-1.el5.i686.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-support-2.1.3-1.el5.i386.rpm

格式化硬盘(单节点)
fdisk /dev/sd?

配置ASM(单节点)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@rac1 ~]# /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) [n]: 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 ]

初始化ASM(所有节点)

1
oracleasm init

创建asm盘(单节点)

1
2
3
4
5
6
7
oracleasm createdisk CRS01 /dev/sdh1
oracleasm createdisk CRS02 /dev/sdi1
oracleasm createdisk CRS03 /dev/sdj1
oracleasm createdisk DATA01 /dev/sdk1
oracleasm createdisk DATA02 /dev/sdl1
oracleasm createdisk DATA03 /dev/sdm1
oracleasm createdisk DATA04 /dev/sdn1

扫描并查看asm盘(所有节点)

1
2
oracleasm scandisks
oracleasm listdisks

安装cvuqdisk包并验证

1
2
3
4
5
6
7
8
9
#cvuqdisk RPM 包含在 Oracle Grid Infrastructure 安装介质上的 rpm 目录中,所有节点都要安装。
#设置环境变量 CVUQDISK_GRP,使其指向作为 cvuqdisk 的所有者所在的组(本文为 oinstall):
export CVUQDISK_GRP=oinstall
rpm -ivh cvuqdisk*
#使用 CVU 验证是否满足 Oracle 集群件要求
./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -fixup -verbose
 
#使用 CVU 验证硬件和操作系统设置
./runcluvfy.sh stage -post hwos -n rac1,rac2 -verbose

二,下载安装

1,下载并安装需要的rpm软件包

检查软件包安装情况:

1
rpm -q binutils elfutils elfutils-libelf gcc gcc-c++ glibc glibc-common glibc-devel compat-libstdc++-33 cpp make compat-db sysstat libaio libaio-devel unixODBC unixODBC-devel|sort

相应软件包下载地址

RedHat Enterprise Linux 5:ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5/Server/en/os/SRPMS/
下载后使用rpm -ivh命令安装即可

2,下载oracle 11g
下载地址:http://www.oracle.com/technology/software/products/database/index.html
解压软件包

1
2
3
unzip linux.x64_11gR2_grid.zip
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip

3,开始安装CRS

1
2
3
4
5
6
7
cd grid
./runInstaller 
#scan配置:
#cluster scan: sanclusters
#scanname: racscan
#scanport: 1521
#安装完成后执行root脚本,之后通过asmca配置asm。

4,开始安装DB

1
2
3
cd database
./runInstaller 
#先只是安装soft

5,创建数据库

1
2
3
xhost +
su - oracle
dbca

三,相关配置

1,自动挂载ISCSI

1
2
#在/etc/rc.local中添加
/etc/rc.d/init.d/iscsiadmrules start

四,常见错误

1,错误:DISPLAY not set. Please set the DISPLAY and try again.

以root用户打开终端或者ssh登录,通过下面命令均可可解决
命令一: export DISPLAY=:0.0
命令二: xhost +

2,错误:error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

安装libaio和libaio-devel软件包,如果仍重复提示错误,以root用户运行”ldconfig“命令可以解决

3,错误:Check complete. The overall result of this check is: Failed <<<< 检查缺失软件包并安装,或者修改系统参数为需要的值

日志信息 »

该日志于2012-07-16 01:29由 kevin 发表在技术合集分类下, 你可以发表评论。除了可以将这个日志以保留源地址及作者的情况下引用到你的网站或博客,还可以通过RSS 2.0订阅这个日志的所有评论。

没有评论

发表评论 »