手把手教你用vmware安装oracle10g RAC(三)

来源:互联网 发布:凌凯短信软件 编辑:程序博客网 时间:2024/05/23 00:09

四、配置linux环境
以下脚本操作较多,不再频繁截图,仅贴出操作脚本供参考。
另,所有操作如非特别注明,均为root用户(注意看操作符前缀),建议通过ssh远程操作。

修改虚拟机配置
在配置linux系统之前,首先到你的虚拟机工作目录,打开.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"

提示:如果你创建有磁盘有多个,注意要按照你的实际情况修改。

编辑/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

提示:192.168.100.201,202为指定的虚IP,供CRS使用,不需要我们配置。

创建组oinstall,dba,用户oracle
[root@node1 ~]# groupadd oinstall
[root@node1 ~]# groupadd dba
[root@node1 ~]# useradd -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与此相同。

修改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了。

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

配置内核参数
[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
让设置生效

提高 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

磁盘分区
例如:
[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.

需要你输入的依次是"n/p/1/回车/回车/w"。
就本例而言,需要我们进行分区的有4个:sdb,sdc,sde,sdf

全分完后fdisk -l看一下,应该是这种形式:
[root@node1 ~]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         166     1228972+  82  Linux swap / Solaris
/dev/sda3             167        1044     7052535   83  Linux

Disk /dev/sdb: 107 MB, 107374080 bytes
64 heads, 32 sectors/track, 102 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         102      104432   83  Linux

Disk /dev/sdc: 322 MB, 322122240 bytes
64 heads, 32 sectors/track, 307 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         307      314352   83  Linux

Disk /dev/sdd: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         261     2096451   83  Linux

Disk /dev/sde: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1         261     2096451   83  Linux

安装 oracleasmlib 程序包
所需的程序包可以到这里下载:
http://www.oracle.com/technology ... x/asmlib/rhel5.html
http://oss.oracle.com/projects/c ... s/Enterprise_Linux/
注意一定要与操作系统版本相符。

包还真不少,本着宁可无用,不能无有的原则,能下到的统统装上
俺装的包有下列:
[root@node1 rhel5]# ls -l
total 225376
-rwxr--r-- 1 oracle oinstall    410476 May 29 15:16 compat-binutils215-2.15.92.0.2-24.i386.rpm
-rwxr--r-- 1 oracle oinstall      4256 May 29 15:16 compat-libcwait-2.1-1.i386.rpm
-rwxr--r-- 1 oracle oinstall     88787 May 29 15:17 compat-libstdc++-egcs-1.1.2-1.i386.rpm
-rwxr--r-- 1 oracle oinstall      3840 May 29 15:17 compat-oracle-el5-1.0-5.i386.rpm
-rwxr--r-- 1 oracle oinstall   1079629 May 29 15:17 openmotif21-2.1.30-11.EL5.i386.rpm
-rwxr--r-- 1 oracle oinstall    122314 May 29 15:17 openmotif21-debuginfo-2.1.30-11.EL5.i386.rpm
-rwxr--r-- 1 oracle oinstall    125313 May 30 15:02 oracleasm-2.6.18-53.el5-2.0.4-1.el5.i686.rpm
-rwxr--r-- 1 oracle oinstall    126085 May 30 15:02 oracleasm-2.6.18-53.el5debug-2.0.4-1.el5.i686.rpm
-rwxr--r-- 1 oracle oinstall    125927 May 30 15:02 oracleasm-2.6.18-53.el5PAE-2.0.4-1.el5.i686.rpm
-rwxr--r-- 1 oracle oinstall    123346 May 30 15:02 oracleasm-2.6.18-53.el5xen-2.0.4-1.el5.i686.rpm
-rwxr--r-- 1 oracle oinstall     13658 May 30 15:13 oracleasmlib-2.0.3-1.el5.i386.rpm
-rwxr--r-- 1 oracle oinstall     22936 May 30 15:13 oracleasm-support-2.0.4-1.el5.i386.rpm
-rwxr--r-- 1 oracle oinstall     10662 May 29 15:17 xorg-x11-libs-compat-6.8.2-1.EL.33.0.1.i386.rpm

安装示例:
[root@node1 rhel5]# rpm -ivh compat-binutils215-2.15.92.0.2-24.i386.rpm
Preparing...                ########################################### [100%]
   1:compat-binutils215     ########################################### [100%]

提示,如果在安装过程中提示你缺少其它包,你可以先到操作系统安装光盘中寻找并安装所需系统包,然后再来安装下载到的包。

配置裸设备
由于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"
ACTION=="add", KERNEL=="/dev/sdd1",RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="49",RUN+="/bin/raw /dev/raw/raw3 %M %m"
ACTION=="add", KERNEL=="/dev/sde1",RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="65",RUN+="/bin/raw /dev/raw/raw4 %M %m"
KERNEL=="raw[1-4]", 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
crw-r----- 1 oracle oinstall 162, 3 Jun  6 17:57 raw3
crw-r----- 1 oracle oinstall 162, 4 Jun  6 17:57 raw4

OK,前期设置完成。En,有点儿麻烦,但运气还算不错,在这些操作上你基本不会遇到什么问题。

五、配置第2台节点-NODE2

关闭节点1,通过vmware复制一个新节点出来,操作非常简单,如果希望界面方式的话,就点击Clone this virtual machine,按照提示下一步即可。如果希望更快捷,直接将rac1目录复制一份到rac2,然后修改.vmx文件中的配置,将路径rac1相关的改成rac2,将RHEL5_NODE1改成RHEL5_NODE2,然后用vmware打开rac2目录中的vmx文件即可,这里三思采用的就是这种方式。

将你启动RHEL5_NODE2的时候,系统会弹出这个提示,一个要选择Create。该选项是说vmware发现配置发生了变化,如果该虚机是复制出来的,需要创建一个唯一的身份标识,让你来选择是否创建,当然要选择Create,如图:


提示:注意下列操作符中提示是node1,这是因为该虚机是由node1复制出来的,千万不要以为下列操作是要在node1上设置哟。

修改hostname
将node1改成node2
[root@node1 ~]# hostname node2
[root@node1 ~]# vi /etc/sysconfig/network
这样重启之后机器名称就会变成node2了。

修改ip地址
先ifconfig看一下:
[root@node1 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:290:48:9D  
          inet addr:172.25.0.59  Bcast:172.25.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fed0:489d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2032 errors:0 dropped:0 overruns:0 frame:0
          TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:238791 (233.1 KiB)  TX bytes:8111 (7.9 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:290:48:A7  
          inet addr:172.25.0.60  Bcast:172.25.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fed0:48a7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1847 errors:0 dropped:0 overruns:0 frame:0
          TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:201063 (196.3 KiB)  TX bytes:8958 (8.7 KiB)
          Interrupt:19 Base address:0x1800
...................
...................
这一步主要是为了记录下两个网卡的mac地址。

[root@node1 ~]# cd /etc/sysconfig/network-scripts/
[root@node1 network-scripts]# mv ifcfg-eth0.bak ifcfg-eth0 -f
[root@node1 network-scripts]# mv ifcfg-eth1.bak ifcfg-eth1 -f
[root@node1 network-scripts]# vi ifcfg-eth0
修改IP地址,192.168.100.101为192.168.100.102
注意修改HWADDR的值为前面ifconfig中查看到的eth0的HWaddr:00:0C:290:48:9D

[root@node1 network-scripts]# vi ifcfg-eth1
同理做修改,HWADDR的值要修改为eth1中的HWaddr:00:0C:290:48:A7

最后重启一下网络服务
[root@node1 network-scripts]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Disabling IPv4 packet forwarding:  net.ipv4.ip_forward = 0
                                                           [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
Bringing up interface eth1:                                [  OK  ]

提示:此时两机使用4个IP或4个别名互ping应该都是通的了,如果不通,建议按照上述的操作步骤,检查一下网络的配置。

修改oracle用户下的环境变量等
[root@node2 network-scripts]# vi /home/oracle/.bash_profile
将ORACLE_SID=RACDB1改为ORACLE_SID=RACDB2

统统设置完成后,建议重启一下第2个节点。
六、配置Clusterware安装环境

设置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秒就需要同步时间了)。

配置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的安装阶段

原创粉丝点击