RHEL5.4+RAW+ASM+Oracle 10gR2 RAC

1. 环境

 VM虚拟机Server 1.0.7

 RED HAT ENTERPRISE 5.4 +RAW+ASM+Oracle 10gR2

2.操作步骤:

 2.1 安装虚拟机(node1,node2),基本情况是:

 2.1.1在每个节点上配置2块网卡

  eth0 and eth1,eth0用于连接公用网络,设置连接方式是Bridged,eth1用于RAC接点的私有连接用,设置连接方式是Host-only;

2.2.2添加共享硬盘4块(scsi1:1,scsi1:2,scsi1:3,scsi1:4),其中scsi1:1用于配置RAW,用来存贮RAC的表决磁盘(voting disk);其中scsi1:2用于配置RAW,用来存贮OCR;sisi1:2(scsi1:3,scsi1:4)块用于ASM

注意事项:需要手工编辑node1虚拟机的.vmx文件,添加以下内容:

 

disk.locking = "false"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"

 

scsi1:1.deviceType = "disk"
scsi1:2.deviceType = "disk"
scsi1:3.deviceType = "disk"
scsi1:4.deviceType = "disk"

 

磁盘配置代码:

 

scsi1.present = "TRUE"
scsi1:1.present = "TRUE"
scsi1:1.fileName = "Red Hat Linux (2).vmdk"
scsi1:1.mode = "independent-persistent"
scsi1:2.present = "TRUE"
scsi1:2.fileName = "Red Hat Linux (3).vmdk"
scsi1:2.mode = "independent-persistent"
scsi1:3.present = "TRUE"
scsi1:3.fileName = "Red Hat Linux (8).vmdk"
scsi1:3.mode = "independent-persistent"
scsi1:4.present = "TRUE"
scsi1:4.fileName = "Red Hat Linux (5).vmdk"

 

然后把以上内容拷贝添加到node2的 .vmx文件中

 

disk.locking = "false"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"

 

scsi1:1.deviceType = "disk"
scsi1:2.deviceType = "disk"
scsi1:3.deviceType = "disk"
scsi1:4.deviceType = "disk"

 

scsi1.present = "TRUE"
scsi1:1.present = "TRUE"
scsi1:1.fileName = "node1的位置/Red Hat Linux (2).vmdk"
scsi1:1.mode = "independent-persistent"
scsi1:2.present = "TRUE"
scsi1:2.fileName = "node1的位置/Red Hat Linux (3).vmdk"
scsi1:2.mode = "independent-persistent"
scsi1:3.present = "TRUE"
scsi1:3.fileName = "node1的位置/Red Hat Linux (8).vmdk"
scsi1:3.mode = "independent-persistent"
scsi1:4.present = "TRUE"
scsi1:4.fileName = "node1的位置/Red Hat Linux (5).vmdk"

 

node1的位置即目的使node2的硬盘指向node1的位置,这样才能达到共享的目的哦;

 

2.2.3:安装虚拟机(node1,node2)

2.2.4:安装完成后用ifconfig检查网卡IP地址,修改2个接点上的/etc/hosts 文件内容:

[root@node1 ~]# vi /etc/hosts
增加如下内容:
192.168.100.101 node1
192.168.100.102 node2
192.168.100.201 node1-vip
192.168.100.202 node2-vip
10.10.17.221 node1-priv
10.10.17.222 node2-priv

注意事项:2个网卡节点的ip段不要设置一样哦,否则虚拟机可能连接不上公网了;

2.2.5在2个节点上添加oracle用户组和oracle用户
[root@node1 ~]# groupadd  -g 1001 oinstall
[root@node1 ~]# groupadd  -g 1002 dba
[root@node1 ~]# useradd  -u 500 -d /home/oracle -g oinstall -G dba oracle

设置oracle 用户密码
[root@node1 ~]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
提示:
[root@node1 ~]# id oracle
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)
如果是非虚机安装,要注意记录下用户和组ID,在其它机器上创建同名组时,务必确认组ID 和用户
ID 与此相同。

 2.2.6修改2个节点上的oracle用户的环境变量文件

 [root@node1 ~]# vi /home/oracle/.bash_profile
增加如下内容:
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/opt/ora10g
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=RACDB1
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin/
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
ulimit -u 16384 -n 65536
umask 022
此处注意oracle_sid 的名称要与后续创建数据库时指定的sid 相同(注意大小写),不然你每次想通过
本机登录的方式进入oracle 都得重新export ORACLE_SID 了。

2.2.7在2个节点上都

创建/opt/ora10g
目录,要注意该目录所有者或oracle
用户的权限
[root@node1 ~]# mkdir /opt/ora10g
由于该目录主要由oracle 用户操作,因此我们将其所有者改为oracle
[root@node1 ~]# chown oracle.oinstall /opt/ora10g

2.2.8在2个节点配置内核参数
[root@node1 ~]# vi /etc/sysctl.conf
增加或修改下列内容
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144

提示,上述参数中通常只有一项需要我们更改,即kernel.shmmax,该参数推荐设定为物理内存的一半,
由于安装crs 的时候要求内存至少512M,因此我们此处也按照512*1024*1024 来设置。
然后:
[root@node1 Server]# sysctl -p
让设置生效
2.2.9提高Oracle用户的shell限制
设置oracle 使用的文件数权限
[root@node1 ~]# vi /etc/security/limits.conf
增加下列内容
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
修改安全限制
[root@node1 ~]# vi /etc/pam.d/login
增加:
session required /lib/security/pam_limits.so

配置Hangcheck 计时器
[root@node1 ~]# vi /etc/rc.local
增加:
modprobe hangcheck-timer hangcheck-tick=30 hangcheck_margin=180

2.2.9 依次对2个节点上的各个磁盘分区
例如:
[root@node1 ~]# fdisk /dev/sdb
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-102, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-102, default 102):
Using default value 102
Command (m for help): w
The partition table has been altered!

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

2.2.10安装oracleasmlib
程序包
所需的程序包可以到这里下载:
http://www.oracle.com/technology/software/tech/linux/asmlib/rhel5.html
http://oss.oracle.com/projects/compat-oracle/files/Enterprise_Linux/
注意一定要与操作系统版本相符。
安装示例:
[root@node1 rhel5]# rpm -ivh compat-binutils215-2.15.92.0.2-24.i386.rpm
Preparing... ########################################### [100%]
1:compat-binutils215 ########################################### [100%]
提示,如果在安装过程中提示你缺少其它包,你可以先到操作系统安装光盘中寻找并安装所需系统包,然后再来安装下载到的包。

2.2.11在2个节点上配置裸设备
由于RHEL5 中取消了rawdevices,如果不想将映射命令放到rc.local 中的话,我们就需要将其配置到
/etc/udev/rules.d/文件夹中
修改文件
[root@node1 ~]# vi /etc/udev/rules.d/60-raw.rules
增加如下内容:
ACTION=="add", KERNEL=="/dev/sdb1",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="17",RUN+="/bin/raw /dev/raw/raw1 %M %m"
ACTION=="add", KERNEL=="/dev/sdc1",RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="33",RUN+="/bin/raw /dev/raw/raw2 %M %m"
KERNEL=="raw[1-2]", OWNER="oracle", GROUP="oinstall", MODE="640"
提示:要根据你的实际情况来配置
另外关于此处的配置有一点非常奇怪,我看到red hat 官方文档中关于raw.rule 的示例中说KERNEL==..
或ENV{MAJOR}...只需要任意配置一个就可以,但我在具体配置过程中发现百试不爽,我尝试了各种组合
发现都不生效,必须二者同时配置才可以,难道是俺用的linux 内核版本太低了?百思不得其解,如有达人
已深究其内幕,望助我解惑~~~~
重启下服务:
[root@node1 ~]# start_udev
Starting udev: [ OK ]
验证一下
[root@node1 ~]# ls /dev/raw/ -l
total 0
crw-r----- 1 oracle oinstall 162, 1 Jun 6 17:57 raw1
crw-r----- 1 oracle oinstall 162, 2 Jun 6 17:57 raw2
OK,前期设置完成。En,有点儿麻烦,但运气还算不错,在这些操作上你基本不会遇到什么问题。

 2.2  配置Clusterware安装环境

1、设置ssh
在clusterware (CRS) 和Rac Database 安装过程中,Oracle Universal Installer (OUI) 必须能够以oracle
的身份自动将软件复制到所有RAC 节点。这里我们通过配置ssh 让oracle 用户拥有不输入密码即可访问
各节点的能力。
首先两个节点间互ping,要确保都是通的
[root@node1 ~]# ping 192.168.100.102
[root@node1 ~]# ping 10.10.17.222
要建立用户等效性,需要在两个节点上以oracle 用户身份生成用户的公钥和私钥,首先在node1 执行:
[root@node1 opt]# su - oracle
[oracle@node1 ~]$ mkdir ~/.ssh
[oracle@node1 ~]$ chmod 700 ~/.ssh
[oracle@node1 ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
d2:69:eb:ac:86:62:27:50:99:ff:e8:1e:a2:e6:5d:7f oracle@node1
[oracle@node1 ~]$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_dsa.
Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
0a:9a:20:46:a2:28:ec:72:23:82:f2:9d:f8:62:9b:d1 oracle@node1
然后换node2 执行
[root@node2 ~]# ping 192.168.100.102
[root@node2 ~]# ping 10.10.17.222
[root@node2 opt]# su - oracle
[oracle@node2 ~]$ mkdir ~/.ssh
[oracle@node2 ~]$ chmod 700 ~/.ssh
[oracle@node2 ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
dd:be:7a:37:e4:b5:f0:b2:24:95:50:61:ea:a1:61:07 oracle@node2
[oracle@node2 ~]$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_dsa.
Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
bc:b5:cb:43:c7:19:53:d6:f7:16:69:85:12:7f:aa:be oracle@node2
切换回node1,接着执行:
[oracle@node1 ~]$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[oracle@node1 ~]$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
提示:下列命令会提示你输入node2 的oracle 密码,按照提示输入即可,如果失败可重新尝试执行命
令。
[oracle@node1 ~]$ ssh node2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
The authenticity of host 'node2 (192.168.100.102)' can't be established.
RSA key fingerprint is 92:d1:ce:5b:c8:a1:52:d5:ac:00:5f:48:5d:12:06:e4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node2,192.168.100.102' (RSA) to the list of known hosts.
oracle@node2's password:
[oracle@node1 ~]$ ssh node2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
oracle@node2's password:
[oracle@node1 ~]$ scp ~/.ssh/authorized_keys node2:~/.ssh/authorized_keys
oracle@node2's password:
authorized_keys 100% 1992 2.0KB/s 00:00
两机相互执行,看看是否还需要输入密码
[oracle@node1 ~]$ ssh node1 date
[oracle@node1 ~]$ ssh node2 date
[oracle@node1 ~]$ ssh node1-priv date
[oracle@node1 ~]$ ssh node2-priv date
切换至node2 执行
[oracle@node2 ~]$ ssh node1 date
[oracle@node2 ~]$ ssh node2 date
[oracle@node2 ~]$ ssh node1-priv date
[oracle@node2 ~]$ ssh node2-priv date
提示:
注意命令的返回信息,由于rac 对节点间时间较敏感,因此如果此处显示节点单时间不一至,建议同
步(一般相隔超过20 秒就需要同步时间了)。

2.3、配置asm
注意:必须以root 身份进行
首先在node1 执行:
[root@node1 ~]# /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 []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
提示:如果本步执行出错(可能出错机率最高的是在Scanning system for ASM),不妨将转换一下命令行
的执行方式,改成:
[root@node1 ~]# sh /etc/init.d/oracleasm configure
有可能解决你的问题!
然后切换至node2 执行
[root@node2 ~]# /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 []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
再切换回node1 执行
[root@node1 ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk: [ OK ]
[root@node1 ~]# /etc/init.d/oracleasm createdisk VOL2 /dev/sde1
Marking disk "/dev/sde1" as an ASM disk: [ OK ]
[root@node1 linux-patch]# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
查看一下当前的磁盘组:
Scanning system for ASM disks: [ OK ]
[root@node1 ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
Node2 上也查看一下当前磁盘组:
[root@node2 ~]# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
[root@node2 ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2

Ok,配置完成,准备进入到crs 的安装阶段

3 安装Clusterware
注意,在这项配置中,除非特别说明,所有操作都是基于oracle 用户的。

3.1、检查安装环境
在安装crs 之前,建议先利用CVU(Cluster Verification Utility)检查CRS 的安装前环境
[oracle@node1 cluvfy]$ /data/rhel5/clusterware/cluvfy/runcluvfy.sh stage -pre crsinst -n node1,node2 -
verbose

3.2.执行安装程序

安装期间指定crs的存储位置为 /dev/raw/raw2

指定voting disk 的存储位置为 /dev/raw/raw1

安装完成执行相应脚本,安装结束

安装期间可能遇到的问题:

3.2.1 通常在最后一个节点执行root.sh 时会遇到错误,就我们的情况而言当然就是node2~~
提示:一般常见的错误有如下三种:
A).如果你碰到了这个错误:
/opt/ora10g/product/10.2.0/crs_1/jdk/jre//bin/java: error while loading shared libraries: libpthread.so.0:
cannot open shared object file: No such file or directory
可以按照如下方式解决:
===============================
修改vipca 文件
[root@node2 opt]# vi /opt/ora10g/product/10.2.0/crs_1/bin/vipca
找到如下内容:
Remove this workaround when the bug 3937317 is fixed
arch=`uname -m`
if [ "$arch" = "i686" -o "$arch" = "ia64" ]
then
LD_ASSUME_KERNEL=2.4.19
export LD_ASSUME_KERNEL
fi
#End workaround
在fi 后新添加一行:
unset LD_ASSUME_KERNEL
以及srvctl 文件
[root@node2 opt]# vi /opt/ora10g/product/10.2.0/crs_1/bin/srvctl
找到如下内容:
LD_ASSUME_KERNEL=2.4.19
export LD_ASSUME_KERNEL
同样在其后新增加一行:
unset LD_ASSUME_KERNEL
保存退出,然后在node2 重新执行root.sh
当然,既然我们已经知道了有这个问题,建议最好在node2 执行root.sh 之前,首先修改vipca。

其实同时需要你改的还有$ORACLE_HOME/bin/srvctl 文件,不然等装完数据库之后,srvctl 命令
也是会报这个错误地。要知道srvctl 这么常用,如果它执行老报错,那可是相当致命啊。不过呢你现
在才安装到crs,离create db 还远着呢,大可以等到创建完数据库,待到需要管理时再修改该文件。

B).如果你碰到了这个错误:
The given interface(s), "eth0" is not public. Public interfaces should be used to configure virtual IPs.
解决方式如下:
==============================
图形界面上运行$CRS_HOME/bin/vipca,手工重新配置rac1-vip 和rac2-vip。
[root@node2 opt]# xhost +
[root@node2 opt]# /opt/ora10g/product/10.2.0/crs_1/bin/vipca

C).如果你碰到了这个错误:
Error 0(Native: listNetInterfaces:[3])
[Error 0(Native: listNetInterfaces:[3])]
解决方式如下:
===============================
[root@node2 bin]# ./oifcfg iflist
eth1 10.10.17.0
virbr0 192.168.122.0
eth0 192.168.100.0
[root@node2 bin]# ./oifcfg setif -global eth0/192.168.100.0:public
[root@node2 bin]# ./oifcfg setif -global eth1/10.10.10.0:cluster_interconnect
[root@node2 bin]# ./oifcfg getif
eth0 192.168.100.0 global public
eth1 10.10.10.0 global cluster_interconnect
然后在视窗界面重新执行vipca 即可,如上b 例中所示。

3.3 结束安装

3.4  如果前面配置环境检查出错
以root 身份执行$ORA_CRS_HOME/cfgtoollogs/configToolFailedCommands.sh
然后执行:
[root@node1 ~]# /opt/ora10g/product/10.2.0/crs_1/bin/./crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.node1.gsd application ONLINE ONLINE node1
ora.node1.ons application ONLINE ONLINE node1
ora.node1.vip application ONLINE ONLINE node1
ora.node2.gsd application ONLINE ONLINE node2
ora.node2.ons application ONLINE ONLINE node2
ora.node2.vip application ONLINE ONLINE node2
结果显示正确就可以。
不报错的话当然就不需要执行了,如果没有错误你应该也找不到configToolFailedCommands.sh 文件。

4.安装oracle 数据库软件

和正常的没有什么区别了,只是中间添加一个选择集群节点的步骤

5.安装完毕用DBCA创建集群数据库,存储在ASM实例子上

ok,一切结束! 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值