Oracle RAC + ASM + Grid安装
Posted 满格
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle RAC + ASM + Grid安装相关的知识,希望对你有一定的参考价值。
(一)环境准备
主机操作系统 | 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 = 2002012160 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="asmadminOracle12c 中RAC功能增强新特性之ASM&Grid完美解决oracle11gR2安装grid检查ASM报错PRVG-10122