oracle rac搭建
(一)环境准备
主机操作系统 | windows10 |
虚拟机平台 | vmware workstation 12 |
虚拟机操作系统 | redhat 5.5 x86(32位) :Linux.5.5.for.x86.rhel-server-5.5-i386-dvd.iso |
grid版本 | linux_11gR2_grid.zip (32位) |
oracle版本 | linux_11gR2_database_1of2 和 linux_11gR2_database_2of2(32位) |
共享存储 | ASM |
(二)操作系统安装
(2.1)操作系统安装
操作系统安装相对而言较简单,不做详述。系统的配置信息大致如下,后面还会根据需要添加和删除设备
(2.2)安装VM Tools
为了方便在主机与虚拟机之间进行文件拖拽、复制粘贴、使用共享文件夹等功能,我们需要安装VM Tools,VM Tools的安装包已经集合在了vmware workstation里面了。下面一步一步安装VM Tools。
step 1:虚拟机-> 安装Vmware Tools
step 2: mount查看是否装载 VMware Tools 虚拟 CD-ROM 映像,如果有红色部分,说明已经将VM tools安装包mount在了/media目录下
step 3:转到安装目录/tmp,解压VM tools安装包
step 4:开始安装VM Tools
[root@Redhat tmp]# cd vmware-tools-distrib
[root@Redhat vmware-tools-distrib]#./vmware-install.pl
遇到选项,直接回车即可。
step 5:安装结束,重启虚拟机
[root@rac1 ~]# reboot
step6:测试VM Tools安装是否成功
从主机拖到一个文档到虚拟机,如果拖动成功,说明VM Tools已经安装成功
(三)操作系统配置
(3.1)网络配置
(3.1.1)主机名配置
①节点1:
[root@rac1 ~]# vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=rac1
②节点2:
[root@rac2 ~]# vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=rac2
(3.1.2)IP配置
为了使用静态IP配置数据库,我又为每台虚拟机新增加了一块网卡,将其配置成only-host模式,新增网卡方式如下:
step1:添加网络
点击vmware的“编辑”-> “虚拟网络编辑器”-> “更改设置”-> “添加网络”,按下图选择,保存
step2:在两台虚拟机上添加网卡
选择虚拟机,“设置”->“添加”->“网络适配器”,选择“自定义”,这个自定义是我们上一步定义的网络,结果如下:
step3:根据网络设置,我们规划IP地址如下:
接下来就是配置IP地址了,对于节点1(主机名:rac1),我们:
①配置eth1
--或删除BOOTPROTO
--不要修改硬件地址
--设置网卡为开机启动
--增加IP和MASK
[root@rac1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
#修改下面红色部分
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth1
# BOOTPROTO
=
dhcp
HWADDR=00:0C:29:9C:DF:6A
ONBOOT
=yes IPADDR=192.168.19.10
NETMASK
=255.255.255.0
②配置eth2
[root@rac1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth2
# 修改红色部分
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth2
# BOOTPROTO
=
dhcp
ONBOOT
=
yes
HWADDR
=00:0C:29
:6G:8C:5F
IPADDR
=192.168.
15.10
NETMASK
=255.255.255.0
对于节点2(主机名:rac2),我们参照节点1即可:
①配置eth1
[root@rac2 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth1
# BOOTPROTO
=dhcp ONBOOT=
yes
HWADDR=00:0c:29:b0:4e:b6
IPADDR
=
192.168
.
19.11
NETMASK
=255.255.
255.0
②配置eth2
[root@rac2 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth2
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth2
# BOOTPROTO
=
dhcp
ONBOOT
=
yes
HWADDR=00:0c:29:b0:4e:c0
IPADDR
=192.168.
15.11
NETMASK
=255.255.
255.0
(3.1.3)hosts文件配置
在2个节点上配置hosts文件,以节点1为例
[root@rac1 ~]# vim /etc/hosts
# 在文件的最后面加上
#eth1 public
192.168.19.10 rac1
192.168.19.11 rac2
#virtual
192.168.19.12 rac1-vip
192.168.19.13 rac2-vip
#eth2 private
192.168.15.10 rac1-priv
192.168.15.11 rac2-priv
#scan
192.168.19.14 rac-scan
配置完成后,重启网卡
[root@rac1 ~]# service network restart
重启网卡时,遇到了一个小错误,提示:
Device eth2 has different MAC address than expected, ignoring.
[FAILED]
看了其他人的文章,发现是网卡配置文件里面的MAC地址与实际虚拟机的MAC地址不一样,解决办法如下:
step1:查看本机实际MAC地址(红色部分)
[root@rac1 ~]# ifconfig eth2 eth2 Link encap:Ethernet HWaddr 00:0C:29:9C:DF:7E inet addr:192.168.15.10 Bcast:192.168.15.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe9c:df7e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:30677 errors:0 dropped:0 overruns:0 frame:0 TX packets:26377 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:15839769 (15.1 MiB) TX bytes:10819637 (10.3 MiB) Interrupt:83 Base address:0x2824
step2:查看我们配置的MAC地址
[root@rac1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth2
# 修改红色部分
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth2
# BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=00:0C:29:6G:8C:5F
IPADDR=192.168.15.10
NETMASK=255.255.255.0
发现我们配置的MAC地址与实际的MAC地址不一样,修改网卡step2里面的MAC地址,重启网卡。
(3.1.4)测试网络
测试主机与虚拟机、虚拟机与虚拟机之间通讯是否正常
①在主机上执行
ping 192.168.15.10
ping 192.168.15.11
ping 192.168.19.10
ping 192.168.19.11
②在节点1上执行,其中192.168.15.1与192.168.19.1均为主机ip
ping 192.168.15.1
ping 192.168.15.11
ping 192.168.19.1
ping 192.168.19.11
③在节点2执行
ping 192.168.15.1
ping 192.168.15.10
ping 192.168.19.1
ping 192.168.19.10
如果都能够ping通,说明网络配置正确。
(3.2)共享存储配置
(3.2.1)存储规划
磁盘功能 | 个数 | 每个大小(GB) |
OCR | 3 | 1 |
DATA | 3 | 10 |
ARCHIVE | 1 | 10 |
(3.2.1)创建共享存储
step1:以管理员方式打开DOS窗口,到vmware workstation安装目录下,执行以下命令创建共享磁盘:
vmware-vdiskmanager.exe -c -s 1000MB -a lsilogic -t 2 "F:\vmwareVirtueMachine\RAC\ShareDisk\votingdisk1.vmdk"
vmware-vdiskmanager.exe -c -s 1000Mb -a lsilogic -t 2 "F:\vmwareVirtueMachine\RAC\ShareDisk\votingdisk2.vmdk"
vmware-vdiskmanager.exe -c -s 1000Mb -a lsilogic -t 2 "F:\vmwareVirtueMachine\RAC\ShareDisk\votingdisk3.vmdk"
vmware-vdiskmanager.exe -c -s 10000Mb -a lsilogic -t 2 "F:\vmwareVirtueMachine\RAC\ShareDisk\datadisk1.vmdk"
vmware-vdiskmanager.exe -c -s 10000Mb -a lsilogic -t 2 "F:\vmwareVirtueMachine\RAC\ShareDisk\datadisk2.vmdk"
vmware-vdiskmanager.exe -c -s 10000Mb -a lsilogic -t 2 "F:\vmwareVirtueMachine\RAC\ShareDisk\datadisk3.vmdk"
vmware-vdiskmanager.exe -c -s 10000Mb -a lsilogic -t 2 "F:\vmwareVirtueMachine\RAC\ShareDisk\archdisk1.vmdk"
(3)修改2个虚拟机的vmx配置文件,在虚拟机的安装目录下的.vmx文件最后加上以下信息:
scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"
scsi1.sharedBus = "virtual"
scsi1:1.present = "TRUE"
scsi1:1.mode = "independent-persistent"
scsi1:1.filename = "F:\vmwareVirtueMachine\RAC\ShareDisk\votingdisk1.vmdk"
scsi1:1.deviceType = "plainDisk"
scsi1:2.present = "TRUE"
scsi1:2.mode = "independent-persistent"
scsi1:2.filename = "F:\vmwareVirtueMachine\RAC\ShareDisk\votingdisk2.vmdk"
scsi1:2.deviceType = "plainDisk"
scsi1:3.present = "TRUE"
scsi1:3.mode = "independent-persistent"
scsi1:3.filename = "F:\vmwareVirtueMachine\RAC\ShareDisk\votingdisk3.vmdk"
scsi1:3.deviceType = "plainDisk"
scsi1:4.present = "TRUE"
scsi1:4.mode = "independent-persistent"
scsi1:4.filename = "F:\vmwareVirtueMachine\RAC\ShareDisk\datadisk1.vmdk"
scsi1:4.deviceType = "plainDisk"
scsi1:5.present = "TRUE"
scsi1:5.mode = "independent-persistent"
scsi1:5.filename = "F:\vmwareVirtueMachine\RAC\ShareDisk\datadisk2.vmdk"
scsi1:5.deviceType = "plainDisk"
scsi1:6.present = "TRUE"
scsi1:6.mode = "independent-persistent"
scsi1:6.filename = "F:\vmwareVirtueMachine\RAC\ShareDisk\datadisk3.vmdk"
scsi1:6.deviceType = "plainDisk"
scsi1:7.present = "TRUE"
scsi1:7.mode = "independent-persistent"
scsi1:7.filename = "F:\vmwareVirtueMachine\RAC\ShareDisk\archdisk1.vmdk"
scsi1:7.deviceType = "plainDisk"
disk.locking = "false"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"
重启虚拟机,2个节点都重启
[root@rac1 ~]# reboot
最终我们看到的虚拟机的硬件配置大致是这样的
(四)Oracle & Grid预配置
(4.1)创建用户
在2个节点上创建用户及安装目录:
/usr/sbin/groupadd -g 1000 oinstall
/usr/sbin/groupadd -g 1020 asmadmin
/usr/sbin/groupadd -g 1021 asmdba
/usr/sbin/groupadd -g 1022 asmoper
/usr/sbin/groupadd -g 1031 dba
/usr/sbin/groupadd -g 1032 oper
useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid
useradd -u 1101 -g oinstall -G dba,asmdba,oper oracle
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/grid
mkdir /u01/app/oracle
chown -R grid:oinstall /u01
chown oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/
安装目录结构如下:
[root@rac1 u01]# tree
.
`-- app
|-- 11.2.0
| `-- grid
|-- grid
`—oracle
(4.2)配置环境变量
(4.2.1)配置ORACLE的环境变量,ORACLE_SID需根据主机来填写
[oracle@rac1 ~]$ cd
[oracle@rac1 ~]$ vi .bash_profile
#添加下面的部分
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=rac1
# 如果是节点2,则: export ORACLE_SID=
rac2
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
(4.2.1)配置GRID的环境变量,ORACLE_SID需根据主机来填写
[grid@rac1 ~]$ cd
[grid@rac1 ~]$ vi .bash_profile
# 添加下面的部分
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+asm1 # 如果是节点2,则:export ORACLE_SID=+asm2
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
(4.3)配置节点互信
(4.3.1)配置oracle用户的节点互信
step1:2个节点执行
su - oracle
mkdir ~/.ssh
chmod 755 .ssh
/usr/bin/ssh-keygen -t rsa
/usr/bin/ssh-keygen -t dsa
step2:将所有的key文件汇总到一个总的认证文件中,在节点1上执行
su – oracle
ssh rac1 cat ~/.ssh/id_rsa.pub >> authorized_keys
ssh rac2 cat ~/.ssh/id_rsa.pub >> authorized_keys
ssh rac1 cat ~/.ssh/id_dsa.pub >> authorized_keys
ssh rac2 cat ~/.ssh/id_dsa.pub >> authorized_keys
step3:节点1上存在一份完整的key,拷贝到节点2
[oracle@rac1 ~]$ cd ~/.ssh/
[oracle@rac1 .ssh]$ scp authorized_keys rac2:~/.ssh/
[oracle@rac2 .ssh]chmod 600 authorized_keys
step4:在2个节点都执行一下命令
ssh rac1 date
ssh rac2 date
ssh rac1-priv date
ssh rac2-priv date
step5:检验是否配置成功,在节点1上不用输入密码就可以通过ssh连接节点2,说明配置成功
[oracle@rac1 ~]$ ssh rac2
[oracle@rac2 ~]$ id
uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1021(asmdba),1031(dba),1032(oper)
[oracle@rac2 ~]$ hostname
rac2
(4.3.2)配置grid用户的节点互信
与Oracle用户执行方式相同,只是执行脚本的用户变成了grid。
(4.4)配置系统内核参数
(4.4.1)内核参数设置
[root@rac1 ~]# vi /etc/sysctl.conf # 在末尾添加
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1306910720
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
net.ipv4.tcp_wmem = 262144 262144 262144
net.ipv4.tcp_rmem = 4194304 4194304 4194304
参数说明:
kernel.shmmni:整个系统共享内存段的最大数目
fs.file-max:系统中所允许的文件句柄最大数目
net.core.rmem_default:套接字接收缓冲区大小的缺省值
net.core.rmem_max:套接字接收缓冲区大小的最大值
net.core.wmem_default:套接字发送缓冲区大小的缺省值
net.core.wmem_max:套接字发送缓冲区大小的最大值
net.ipv4.ip_local_port_range:应用程序可使用的IPv4端口范围
使得修改内核参数生效
[root@rac1 ~]# sysctl -p
(4.4.2)配置oracle、grid用户的shell限制
[root@rac1 ~]# vi /etc/security/limits.conf # 在末尾添加
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
(4.5)配置共享存储
step1:查看磁盘
[root@rac1 ~]# fdisk -l
通过该命令,可看到我们后面添加上去的磁盘信息,磁盘从sdb到sdh
step2:分区、格式化磁盘。由于是共享磁盘,所以只需要在一个节点上执行即可
# 在节点1上格式化,以/dev/sdb为例:
[root@rac1 ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 3824.
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-3824, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-3824, default 3824):
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
step3:在2个节点上添加裸设备,2个节点都要执行
[root@rac2 ~]# vi /etc/udev/rules.d/60-raw.rules
# 在后面添加
ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc1", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sde1", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="sdf1", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="sdg1", RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", KERNEL=="sdh1", RUN+="/bin/raw /dev/raw/raw7 %N"
KERNEL=="raw[1]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[2]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[3]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[4]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[5]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[6]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[7]", MODE="0660", OWNER="grid", GROUP="asmadmin"
启动裸设备,2个节点都执行
[root@rac2 ~]# start_udev
查看裸设备,2个节点都要查看
[root@rac1 ~]# raw -qa
/dev/raw/raw1: bound to major 8, minor 17
/dev/raw/raw2: bound to major 8, minor 33
/dev/raw/raw3: bound to major 8, minor 49
/dev/raw/raw4: bound to major 8, minor 65
/dev/raw/raw5: bound to major 8, minor 81
/dev/raw/raw6: bound to major 8, minor 97
/dev/raw/raw7: bound to major 8, minor 113
(4.6)安装依赖软件包
(4.6.1)配置共享文件夹(2个节点都要配置)
step1:关闭虚拟机
step2: 设置”->“选项”->“共享文件夹”->“总是启用”->“添加 ”。然后添加操作系统安装包,为了方便,我们将grid、oracle安装包也添加进去。
step3:查看结果
[root@rac1 ~]# cd /mnt/hgfs/soft/
[root@rac1 soft]# ls
database linux_11gR2_database_1of2.zip Linux.5.5.for.x86.rhel-server-5.5-i386-dvd.iso
grid linux_11gR2_database_2of2.zip
(4.6.2)配置yum源
step 1:创建ISO文件的挂载目录并挂载
[root@rac1 /]# mkdir /yum
[root@rac1 /]# cd /mnt/hgfs/soft/
[root@rac1 soft]# mount -o loop Linux.5.5.for.x86.rhel-server-5.5-i386-dvd.iso /yum
step2:找到rpm包
[root@rac1 Server]# cd /yum/Server/
[root@rac1 Server]# ll
...
-r--r--r-- 433 root root 102853 Jan 19 2007 zlib-devel-1.2.3-3.i386.rpm
-r--r--r-- 368 root root 1787914 May 6 2009 zsh-4.2.6-3.el5.i386.rpm
-r--r--r-- 368 root root 369147 May 6 2009 zsh-html-4.2.6-3.el5.i386.rpm
[root@rac1 Server]# ll |wc -l
2351
step 3:配置Linux OS介质为yum源
[root@rac1 ~]# cd /etc/yum.repos.d/
[root@rac1 yum.repos.d]# ls
rhel-source.repo
[root@RedHat yum.repos.d]# rm -rf redhat.repo
[root@RedHat yum.repos.d]# vi lijiaman.repo
# 在新的yum源里面添加红色部分
[dvdinfo]
name=my_yum
baseurl=file:///yum/Server
enabled=1
gpgcheck=0
step4:收集安装包的信息
[root@rac1 yum.repos.d]# yum makecache
step5:为方便重启虚拟机之后依然可以使用yum,在rc.local里面添加:
[root@rac1 yum.repos.d]# vim /etc/rc.local
#添加红色部分
mount -o loop Linux.5.5.for.x86.rhel-server-5.5-i386-dvd.iso /yum
(4.6.3)安装依赖包
不同的操作系统安装不同的包,具体可看官方教程:
http://docs.oracle.com/cd/E11882_01/install.112/e41961/prelinux.htm#CWLIN
我这里安装的包如下:
yum install -y binutils-*
yum install -y compat-libstdc++-*
yum install -y elfutils-libelf-*
yum install -y elfutils-libelf-*
yum install -y elfutils-libelf-devel-static-0.125
yum install -y gcc-4.1.2
yum install -y gcc-c++-4.1.2
yum install -y glibc-2.5-24
yum install -y glibc-common-2.5
yum install -y glibc-devel-2.5
yum install -y glibc-headers-2.5
yum install -y kernel-headers-2.6.18
yum install -y ksh-20060214
yum install -y libaio-0.3.106
yum install -y libaio-devel-0.3.106
yum install -y libgcc-4.1.2
yum install -y libgomp-4.1.2
yum install -y libstdc++-4.1.2
yum install -y libstdc++-devel-4.1.2
yum install -y make-3.81
yum install -y sysstat-7.0.2
(五)安装Grid
(5.1)安装前的检查
step1:解压grid安装包
[root@rac1 ~]# cd /mnt/hgfs/soft/
[root@rac1 soft]# unzip linux_11gR2_grid.zip
step2:安装cvuqdisk包,用于检查RAC环境配置
[root@rac1 soft]# cd grid/
[root@rac1 grid]# ls
doc install response rpm runcluvfy.sh runInstaller sshsetup stage welcome.html
[root@rac1 grid]# cd rpm/
[root@rac1 rpm]# ls
cvuqdisk-1.0.7-1.rpm
[root@rac1 rpm]# rpm -ivh cvuqdisk-1.0.7-1.rpm
Preparing... ########################################### [100%]
Using default group oinstall to install package
1:cvuqdisk ########################################### [100%]
step3:检查环境配置,这里需要一项一项的去核对,确保没有不通过的选项,
[root@rac1 rpm]# su - grid
[grid@rac1 ~]$ cd /mnt/hgfs/soft/grid/
[grid@rac1 grid]$ ls
doc install response rpm runcluvfy.sh runInstaller sshsetup stage welcome.html
[grid@rac1 grid]$ ./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -fixup -verbose
Performing pre-checks for cluster services setup
Checking node reachability...
这里我的检查中有3项目不合格:
①用户等效性:
Checking user equivalence...
Check: User equivalence for user "grid"
Node Name Comment
------------------------------------ ------------------------
rac2 failed
rac1 failed
Result: PRVF-4007 : User equivalence check failed for user "grid"
解决方法:
安装前面的方法,重新配置grid用户互信。
②补丁包
Check: Package existence for "unixODBC-2.2.11"
Node Name Available Required Comment
------------ ------------------------ ------------------------ ----------
rac2 missing unixODBC-2.2.11 failed
Result: Package existence check failed for "unixODBC-2.2.11"
Check: Package existence for "unixODBC-devel-2.2.11"
Node Name Available Required Comment
------------ ------------------------ ------------------------ ----------
rac2 missing unixODBC-devel-2.2.11 failed
Result: Package existence check failed for "unixODBC-devel-2.2.11"
解决方法:
yum install –y unixODBC*
③NTP时钟同步
Starting Clock synchronization checks using Network Time Protocol(NTP)...
NTP Configuration file check started...
The NTP configuration file "/etc/ntp.conf" is available on all nodes
NTP Configuration file check passed
Checking daemon liveness...
Check: Liveness for "ntpd"
Node Name Running?
------------------------------------ ------------------------
rac2 no
rac1 no
Result: Liveness check failed for "ntpd"
PRVF-5415 : Check to see if NTP daemon is running failed
Result: Clock synchronization check using Network Time Protocol(NTP) failed
解决方法:
在11gr2 版本的Rac 在安装 GI软件时,需要通过2种途径实现节点间时间同步:
1.操作系统 NTP 时间同步
2.Oracle Cluster Time Synchronization Service
在oracle11G R2版本中,oracle自己增加了集群中的时间同步服务,如果操作系统没有配置NTP,就会启用oracle 自带的 Cluster Time Synchronization Service 。
故该错误可以忽略。
(5.2)安装grid
安装主需要在一个节点上进行即可,会自动同步到另一个节点,我们在rac1上执行安装工作
step1:开启安装
[root@rac1 ~]# xhost +
xhost: unable to open display ""
[root@rac1 ~]# su - grid
[grid@rac1 ~]$ cd /mnt/hgfs/soft/grid/
[grid@rac1 grid]$ ls
doc install response rpm runcluvfy.sh runInstaller sshsetup stage welcome.html
[grid@rac1 grid]$ ./runInstaller
step2:图形安装
这一步需要注意SCAN Name,我们在/etc/hosts文件里面设置为什么值,这里就填什么值
添加另一个节点
添加节点之后,点击“SSH Connectivity”,填写grid用户的密码,点击“setup”
配置网络,这里至少需要两个网络,根据前面的IP规划表选择即可
选择3块1GB的磁盘,组成一个磁盘组OCR
输入密码,这里有警告信息,看了一下,是密码不够复杂,不符合Oracle的规定,忽略不管
下面的几个图忘记截图了,从网上找了一张图,在Prerequisite Check中,NTP检查失败,忽略
开始进行安装…
安装过程中,会填出如下窗口:
按照其要求,一个节点一个节点的执行,千万不要2个节点一起执行,以我为例:
step1:在虚拟机rac1上打开一个窗口,以root用户登录
执行脚本:
[root@rac1 ~]# /u01/app/oraInventory/orainstRoot.sh
# 待上面脚本执行完成,再执行下面脚本
[root@rac1 ~]# /u01/app/11.2.0/grid/root.sh
step2:漫长的等待
step3:确认节点1上的脚本执行完成,在虚拟机rac2上打开一个窗口,以root用户登录
执行脚本:
[root@rac2 ~]# /u01/app/oraInventory/orainstRoot.sh
# 待上面脚本执行完成,再执行下面脚本
[root@rac2 ~]# /u01/app/11.2.0/grid/root.sh
step4:漫长的等待
step5:确认节点2的脚本执行完成。点击“OK”;
===================================================
安装到最后,有报错信息出现:
原因:
由于配置了/etc/hosts来解析SCAN,导致未走DNS来进行SCAN的解析,爆出此错误,可以考虑忽略掉
解决办法:
ping scan ip,如果可以ping通,忽略,跳过即可。
[grid@rac1 grid]$ ping rac-scan
PING rac-scan (192.168.19.14) 56(84) bytes of data.
64 bytes from rac-scan (192.168.19.14): icmp_seq=1 ttl=64 time=0.021 ms
64 bytes from rac-scan (192.168.19.14): icmp_seq=2 ttl=64 time=0.026 ms
至此grid安装完成。
(5.3)配置磁盘组
在节点1上执行
[grid@rac1 ~]$ asmca
点击“create”
创建磁盘组DATA
创建磁盘组ARCH
(六)安装Oracle
(6.1)安装Oracle软件
解压安装包,调出图形界面
[oracle@rac1 ~]$ cd /mnt/hgfs/soft/
[oracle@rac1 soft]$ unzip linux_11gR2_database_1of2.zip
[oracle@rac1 soft]$ unzip linux_11gR2_database_2of2.zip
[oracle@rac1 soft]$ ls
database linux_11gR2_database_1of2.zip Linux.5.5.for.x86.rhel-server-5.5-i386-dvd.iso
grid linux_11gR2_database_2of2.zip
[oracle@rac1 soft]$ cd database/
[oracle@rac1 database]$ ls
doc install response rpm runInstaller sshsetup stage welcome.html
[oracle@rac1 database]$ ./runInstall
选择第二个,只安装数据库软件
这里节点互信总是出问题,重新手动配置一下就好了,没完全搞明白 -_-
时钟同步问题,忽略
漫长的等待
结束。
(6.2)创建数据库
在oracle用户下执行命令
[oracle@rac1 ~]$ dbca
部分截图:
与安装grid一样,执行脚本,一个节点一个节点的执行,先执行完节点1,在执行节点2
结束安装。
(6.3)检查安装结果
发现arch和data磁盘组还是有问题,没有自动启动(这个问题比较奇怪,我安装了3次,在个人电脑上安装遇到2次,在服务器上安装则没有这个问题,怀疑是个人电脑I/O不足,在数据库启动时磁盘mount超时了)
[grid@rac1 ~]$ crsctl status res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
OFFLINE OFFLINE rac1
ONLINE ONLINE rac2
ora.DATA.dg
OFFLINE OFFLINE rac1
OFFLINE OFFLINE rac2
ora.LISTENER.lsnr
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.OCR.dg
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.asm
ONLINE ONLINE rac1 Started
ONLINE ONLINE rac2 Started
ora.eons
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.gsd
OFFLINE OFFLINE rac1
OFFLINE OFFLINE rac2
ora.net1.network
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.ons
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.registry.acfs
ONLINE ONLINE rac1
ONLINE ONLINE rac2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE rac1
ora.oc4j
1 OFFLINE OFFLINE
ora.rac.db
1 OFFLINE OFFLINE
2 OFFLINE OFFLINE
ora.rac1.vip
1 ONLINE ONLINE rac1
ora.rac2.vip
1 ONLINE ONLINE rac2
ora.scan1.vip
1 ONLINE ONLINE rac1
手动启动arch和data
[grid@rac1 ~]$ srvctl start diskgroup -g arch
[grid@rac1 ~]$ srvctl start diskgroup -g data
再次查看资源状态,已经启动
[grid@rac1 ~]$ crsctl status res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.DATA.dg
ONLINE ONLINE rac1
ONLINE ONLINE rac2
接下来,启动数据库
[grid@rac1 ~]$ srvctl start database -d rac
查看资源状态,数据库已经启动
ora.rac.db
1 ONLINE ONLINE rac1 Open
2 ONLINE ONLINE rac2 Open
进入数据库,
[grid@rac1 ~]$ su - oracle
Password:
[oracle@rac1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sun Oct 15 19:27:40 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
查看实例状态
SQL> col host_name format a10;
SQL> select host_name,inst_id,instance_name,version from gv$instance;
HOST_NAME INST_ID INSTANCE_NAME VERSION
---------- ---------- ---------------- -----------------
rac1 1 rac1 11.2.0.1.0
rac2 2 rac2 11.2.0.1.0
一切正常。结束
其它问题:
问题1:无法进入asm实例
在grid下,想要进入asm实例,发现asm实例状态为idle,如下:
[grid@rac1 ~]$ sqlplus / as sysasm
SQL*Plus: Release 11.2.0.1.0 Production on Tue Sep 11 18:43:36 2018
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
[grid@rac1 ~]$ asmcmd
Connected to an idle instance.
ASMCMD>
通过crsctl查看,我的asm实例明明是启动的,那么为什么状态为idle呢?从网上查找资料,发现都是grid用户环境变量的问题。查看监听,确认asm实例名称,发现asm实例名称是大写的,在前面安装grid的时候没注意,导致出现该问题。
[grid@rac2 ~]$ lsnrctl
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-SEP-2018 19:20:42
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 11-SEP-2018 18:18:12
Uptime 0 days 1 hr. 2 min. 31 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/rac2/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.141.71.102)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.141.71.104)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "rac" has 1 instance(s).
Instance "rac2", status READY, has 1 handler(s) for this service...
Service "racXDB" has 1 instance(s).
Instance "rac2", status READY, has 1 handler(s) for this service...
The command completed successfully
于是将grid用户的.bash_profile文件中的oracle_sid修改为大写即可
修改前:
[grid@rac1 ~]$ more .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 TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+asm1 # 如果是节点2,则:export ORACLE_SID=+asm2
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
修改后:
[grid@rac1 ~]$ more .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 TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+ASM1 # 如果是节点2,则:export ORACLE_SID=+asm2
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
问题2:通过scan ip连接不上数据库 (2018.09.12补充)
在我的电脑上配置了tns文件,然后连接到数据库上时,报错
ORA-12545: 因目标主机或对象不存在,连接失败
通过其它IP(public ip和vip)都可以脸上数据库,网上查找相似问题,发现是11.2.0.1的bug,只需要将初始化参数local_listener中的host的值改为vip即可。
修改方法如下:
---------节点1
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.141.71.103)(PORT=1521))))' scope=both sid='racdb1';
System altered.
SQL> alter system register;
System altered.
---------节点2
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.141.71.104)(PORT=1521))))' scope=both sid='racdb2';
System altered.
SQL> alter system register;
System altered.
修改前:
----------2个节点配置均如下
SQL> show parameter listener
NAME TYPE VALUE
----------------------- ----------- ------------------------------
listener_networks string
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=rac1-vip)(PORT=1521))))
remote_listener string rac-scan:1521
修改后:
------------节点1
SQL> show parameter listener
NAME TYPE VALUE
------------------------ ----------- ------------------------------
listener_networks string
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=10.141.71.103)(PORT=1521))))
remote_listener string rac-scan:1521
-------------节点2
SQL> show parameter listener
NAME TYPE VALUE
----------------------- ----------- ------------------------------
listener_networks string
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=10.141.71.104)(PORT=1521))))
remote_listener string rac-scan:1521