Centos7 静默安装 Oracle RAC 11gR2
vSphere EXSi + CentOS7.4环境搭建Oracle RAC(11gR2)安装之前,先总结一下安装Oracle RAC的注意事项:如果是在vSphere EXSi环境中搭建虚机Oracle RAC需要注意:虚拟机配置RAC,如果不是挂裸盘RDM(裸磁盘映射)的话,按以下步骤进行,不影响VMotion 的功能,但是影响Storage VMotion 的功能。在数据库系统云化实施中,对
vSphere EXSi + CentOS 7.4 静默安装 Oracle RAC (11gR2)
安装之前,先总结一下安装Oracle RAC的注意事项:
如果是在vSphere EXSi环境中搭建虚机Oracle RAC需要注意:
虚拟机配置RAC,如果不是挂裸盘RDM(裸磁盘映射)的话,按以下步骤进行,不影响VMotion 的功能,但是影响Storage VMotion 的功能。在数据库系统云化实施中,对Oracle RAC要求部署在虚拟机中的场景,可以参考下面方式进行:
要点:
* 各节点均采用单独的pvscsi控制器,SCSI总线共享配置参数选择"物理"
* 添加厚制备置零磁盘置备模式的硬盘,且各节点SCSI ID要保持一致
* 每个节点双网卡或多网卡,用vmxnet3
* 如果有对VM做快照的需求,设置磁盘为独立磁盘才不会对数据盘有影响
* 为每个磁盘添加multi-wirter标记
* 每个RAC节点都做操作一遍,不同的是第一个节点是创建磁盘,而其他节点是挂载已有的磁盘
* 如果使用了DRS,可以设置DRS关联规则,让RAC节点不要同时位于单个主机上
具体操作步骤可参考后面的ESxi共享存储配置章节。
安装Oracle RAC大概步骤有三个:安装clusterware、安装Oracle和RAC、在RAC下创建数据库。其中安装clusterware最容易出错,下面几点要特别注意:
* 公共网络(Public Network)必须使用各个节点的同一个网卡
* 每个节点需要一个VIP,VIP必须和公共网络(Public Network)在一个子网中
* 如果Oracle RAC需要对外提供服务而不只是对局域网内提供服务,那么公共网络不能配置成内网地址、应该用外网地址
* 有些系统中(如Solaris),需要给VIP指定默认网关
* 硬盘分区时,要确保在所有节点上都能看到分区信息
* 要为OCR设备和VOTE设备指定正确的权限和属主
* OCR/VOTE放置于不同的LUN是为了提高保护,也可以放一份
* Oracle 11gR2开始,Vote Disk信息存储在OCR中了,只需要规划OCR磁盘、不需要单独规划VOTE磁盘了。如要分开就指定不同的asm group。
* 要为Public-IP、VIP、Scan-IP、Private-IP指定主机名(配置DNS或修改/etc/hosts),主机名中不能包含大写字母和下划线“_”,但支持中横线“-”
* Public-IP、VIP、Scan-IP要在同一个网段,VIP和Scan-IP可以随便设置但不能相同
* Public-IP和Private-IP一定要是自己虚拟机的IP,最好是将IP设置成静态IP
* 如果配置失败,重新配置,需要把之前的配置结果全部删除
* 在安装clusterware时,需要设置环境变量ORACLE_HOME,在安装Oracle和RAC时,需要重新指定这个变量,而且不能指定为同一个目录
* 正确配置节点间的信任关系
* RAC要求各节点的oracle账户、grid账户以及相应的组的id是必须相同的,创建的时候建议制定用户id和组id
其他注意事项:
* 主机名(hostname)必须和public名保持一致
* 安装完成后,hostname就不能修改了。这会涉及修改grid参数、重建grid用户互信等其他很多操作,官方的说法是如果安装完成后再修改hostname,只能先删除节点->修改Hostname->再重新添加节点
* Swap空间不够可能安装时也会报错,因此提前按照官方建议准备好Swap空间。如何分配和创建Swap,我的另外一篇有详细介绍《Centos7 安装 Oracle11g》https://blog.csdn.net/sunny05296/article/details/56840775
* 静默安装时,Oracle 11R2新增加了SCAN IP这一选项,官方文档建议必须为SCAN IP设置DNS服务器做域名解析。而在实际没有配置DNS服务器或配置了无权修改,只能添加/etc/hosts。如果图形安装是可以忽略错误继续,但静默安装必须加忽略参数,否则报错无法继续
* 静默安装时,应答文件中的配置参数: privateInterconnects 应该配置网段地址、而不是主机地址,配错安装会失败:[INS-40925]
*
通过/etc/hosts设置只能设置一个SCAN IP,无法实现轮训负载均衡。ORALCE官方文档说SCAN IP在DNS上需要解析成三个IP地址,单很多人也都只配置1个SCAN IP。
hosts文件不能将一个name对应到多个IP上,因此无法实现IP的轮询,如果要IP轮训,必须配置DNS服务器。
SCAN最明显的优点就是,当集群中新增加了节点或者删除了节点,不需要额外维护客户端。
网上说如果配置/etc/hosts scan ip可以忽略该错误,但只能在图形化安装时忽略,静默安装报错无法继续。
1.规划
环境:
VMware ESXi6.0 + Centos7.4_x86-64(4Core/8G/100G)*2个虚机
软件:
linux.x64_11gR2_database_1of2.zip //Oracle Database 11g Release 2 (11.2.0.1.0) for Linux x86-64, (1,239,269,270 bytes) (cksum - 3152418844)
linux.x64_11gR2_database_2of2.zip //(1,111,416,131 bytes) (cksum - 3669256139)
linux.x64_11gR2_grid.zip //Oracle Grid Infrastructure 11g Release 2 (11.2.0.1.0) for Linux x86-64, (1,052,897,657 bytes) (cksum - 3369676398)
官方各个Oracle版本的软件下载路径:https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
hostname规划:
rac1、rac2(节点1:hostnamectl set-hostname rac1,节点2:hostnamectl set-hostname rac1)
IP和RAC节点规划:
2个节点的Oracle RAC 11gR2,需要7个IP:
# for Oracle RAC
192.168.235.60 rac1 #rac1 Public-IP Public-Name
192.168.235.61 rac2 #rac2 Public-IP public-Name
192.168.235.62 rac1vip #rac1 VIP VIP-Name
192.168.235.63 rac2vip #rac2 VIP VIP-Name
192.168.235.64 racscan #Scan IP Scan-Name
10.0.0.1 rac1priv #rac1 Priate-IP Private-Name
10.0.0.2 rac2priv #rac2 Priate-IP Private-Name
磁盘组规划:
用途 ASM卷组名 磁盘大小*个数 总大小 冗余方式 ASM磁盘组
OCR&VOTE +OCR 4G * 3 12G normal ASMOCR01,ASMOCR02,ASMOCR03
归档文件 +ARCH 500G * 1 500G exteranl ASMARCH01
数据文件 +DATA 1T * 2 2T exteranl ASMDATA01,ASMDATA02
注意:Oracle 11gR2开始,Vote Disk信息存储在OCR中了,只需要规划OCR磁盘、不需要单独规划VOTE磁盘了。
说明:
OCR:Oracle Cluster Register(Oracle集群注册),用于维护整个集群的配置信息,包括RAC以及Clusterware资源,包括的信息有节点成员、数据库、实例、服务、监听器、应用程序等。
整个集群会有一份配置OCR,最多两分OCR(primary OCR & mirror OCR,互为镜像,以防OCR的单点故障)。
Oracle会把集群的配置文件放在共享存储上叫做OCR Disk,节点通过OCR Process读写OCR。但只有一个节点(OCR Master节点)能够读写OCR Disk,其它节点通过本节点的OCR process向Master节点的OCR process提交请求,由Master OCR Process完成物理读写,并同步所有节点OCR cache中的内容。
安装Clusterware的在选择OCR的存储位置时,如果选择"Normal Redundancy",则会存储两份相互镜像的OCR。如果选择"External Redundancy"则表明存储本身已经做了冗余配置,不需要创建mirror OCR。该位置会记录在/etc/oracle/ocr.loc(Linux)中。
注意:由于OCR的信息很重要,他是整个集群的首脑,Oracle会每4小时队其做一次备份,并且保留最后的3个备份,以及前一天、前一周的最后一个备份。这个备份由Master节点的CRSD进程完成,备份的默认位置为$CRS_HOME/crs/cdata/<cluster_name>目录下。最近一次备份为backup00.ocr。
建议OCR要多存储几份。
Oracle RAC OCR 磁盘所需空间计算方法:
total = [2 * ausize * disks] + [redundancy * (ausize * (all_client_instances + nodes + disks + 32) + (64 * nodes) + clients + 543)]
redundancy = Number of mirrors: external = 1, normal = 2, high = 3, flex = 3.
ausize = Metadata AU size in megabytes
all_client_instance = Sum of all database clients
nodes = Number of nodes in cluster.
clients - Number of database instances for each node.
disks - Number of disks in disk group.
For example:
for a four-node Oracle RAC installation, using three disks in a normal redundancy disk group, you require an additional 5293 MB of
space: [2 * 4 * 3] + [2 * (4 * (4 * (4 + 1)+ 30)+ (64 * 4)+ 533)] = 5293 MB
一般节点数不多安装的时候,OCR+VOTE分配10G也就够了,不用精确计算。
VOTE:Oracle Clusterware由2部分组成,分别是Voting Disk和 OCR。Voting Disk里面记录着节点成员的信息(包括节点信息以及节点的增删等信息)。
Voting Disk主要为了在出现故障时,决定那个Partion获得控制权,其他的Partion必须从集群中剔除。
为了保证Voting Disk的安全,需要配置多个Voting Disk,Voting Disk使用的是一种“多数可用算法”。
当有多个Voting Disk时,则必须一半以上的Vote Disk同时使用,Clusterware才能正常使用。
例如如果配置了4个Vote Disk,坏1个Vote Disk,集群仍然可以正常工作。但如果坏了2个,则不能满足半数以上,集群会立即宕掉,所有节点立即重启。
因此:添加Votedisk,尽量不要只添加1个,而应该添加3个。官方建议Voting Disk的个数应该为奇数个,如:1、3、5个,每个Voting Disk的大小约为20MB。
查看Voting Disk命令: crsctl query css votedisk
注意:
1)对Voting Disk的更改必须用root用户来操作,添加/删除Voting Disk都必须在crs资源关闭的情况下进行,同时即使在CRS关闭情况下,操作时仍然需要使用-force参数
2)从Oracle 11gR2开始,Vote Disk信息存储在OCR中了
3)Oracle 11gR2默认情况下,Oracle备份OCR时会自动一起备份Voting Disk,不需要单独备份
ARCH:用于存储归档文件,空间的划分满足每天的归档量即可。
DATA:用于存储数据。
3.ESxi共享存储配置
3.1)添加共享磁盘
step1)在ESXi中的一个虚机(rac1)关机情况下新增磁盘:
OCR+VOTE: 4G *3个
ARCH: 500G *1个
DATA: 1T *2个
编辑虚拟机设置->硬件->添加硬盘,配置参数如下:
1)添加磁盘时,rac1上创建新的虚拟磁盘(rac2添加磁盘的时候就使用现有虚拟磁盘、不需要重新创建)
2)添加的磁盘置备模式必须设置为厚置备置零模式
3)虚拟设备节点:SCSI(1:0)~SCSI(1:N)
4)位置:与虚拟机存储在同一目录中
5)虚拟设备节点:选择新的虚拟设备节点,并且保证,节点2与节点1共享磁盘选择的scsi设备一致。此处rac1上创建时选择scsi(1:0)~scsi(1:5)
6)模式:建议不要勾选独立。因为NBU在VMWare手册中已经明确写不支持独立vmdk的虚拟机备份工作。但要注意,非独立模式,对VM做快照恢复时会影响数据盘,如果有快照需求且不能影响数据盘则要使用独立模式
用上面同样的配置完成所有磁盘的添加。
step2)磁盘添加完后会自动新增SCSI 1控制器(原来只有SCSI 0控制器),修改总线共享方式:“无”==>“虚拟"(这里有两个选项:物理/虚拟,我改成了虚拟)
虚拟:虚拟磁盘可以在同一服务器上的虚拟机之间共享
物理:虚拟磁盘可以在任何服务器上的虚拟机之间共享
step3)在ESXi的节点2虚机(rac2)关机情况下新增所有磁盘,选择rac1上已添加过的虚拟磁盘而不是新建(scsi编号要保持一致)
添加时,磁盘文件路径选择定位到rac1节点对应的vmdk文件,SCSI编号和rac1的编号保持一致,模式勾选独立、持久
step4)rac2也需要将SCSI 1控制器参数进行修改,修改总线共享方式默认“无”(改为虚拟/物理)。
如果rac2遗漏修改,会导致标记multi-writer标记最终导致第二台虚机启动报错找不到磁盘。
step5)对于节点1和节点2添加的磁盘标记。选择添加的磁盘,编辑虚拟机设置->选项--高级--常规--参数配置,末尾添加行,设置每个磁盘的multi-writer标记
名称 值
scsi1:0.sharing multi-wirter
scsi1:1.sharing multi-wirter
scsi1:2.sharing multi-wirter
scsi1:3.sharing multi-wirter
scsi1:4.sharing multi-wirter
scsi1:5.sharing multi-wirter
设置磁盘标记还有一种方法,直接修改磁盘的vmx文件:
scsi1:0.sharing = "multi-writer"
scsi1:1.sharing = "multi-writer"
scsi1:2.sharing = "multi-writer"
scsi1:3.sharing = "multi-writer"
scsi1:4.sharing = "multi-writer"
scsi1:5.sharing = "multi-writer"
注意:
1.所有节点、所有添加的磁盘都要设置multi-wirter
2.所有节点自动新增SCSI 1控制器的总线共享方式一定要修改、如果不修改默认为“无”,会导致一个节点能启动、其他节点启动时报获取磁盘失败的错误、会重置清空multi-writer标记
3.启用了multi-writer参数做的共享磁盘(启用multi-writer参数的原因是在使用vmdk格式磁盘做共享磁盘时,需要启用该参数),但结合VMware KB(1034165),启用了multi-writer参数后,以下的功能将不受支持:
不支持快照功能Most snapshots and any other action which utilizes snapshots
不支持虚拟化备份软件,因为基于虚拟化备份需要依赖快照功能和 vstorage API
不支持对虚拟机的克隆
不支持vsphere replication
不支持 storage vmotion
不支持基于Change Block Tracking (CBT) 的备份
不支持Suspending 挂起暂停虚拟机。
不支持在线扩展虚拟磁盘
step6)如果使用了DRS,则RAC虚机节点建议放在不同的主机上,所以需要配置DRS。如果没有使用DRS,则可以跳过该步骤。
集群编辑->规则->新建,类型选择"单独的虚拟机",选定虚机。
最后:共享磁盘添加完毕后,开机,在所有RAC节点上检查一下,应该都能看到磁盘:
rac1 & rac2上执行命令
# fdisk -l
都可查看到添加的磁盘
[root@rac1 ~]# ls -1 /dev/sd*
/dev/sda
/dev/sda1
/dev/sda2
/dev/sdb
/dev/sdc
/dev/sdd
/dev/sde
/dev/sdf
/dev/sdg
[root@rac1 ~]# fdisk -l |grep sd[bcdefg]
Disk /dev/sdc: 4294 MB, 4294967296 bytes, 8388608 sectors
Disk /dev/sdd: 4294 MB, 4294967296 bytes, 8388608 sectors
......
3.2)对共享磁盘进行分区(只需要一个节点操作)
rac1上用root用户操作:
查看磁盘设备
ls -1 /dev/sd*
fdisk -l |grep sd[bcdefg]
磁盘分区(只需要在一个节点上分区)
# fdisk /dev/sdb
n 创建新分区
p 创建主分区,另有e键是扩展分区
1 分区数字默认从1开始,即sdb1,sdc1等
回车 分区默认从第2048个柱面开始
回车 结束柱面选择默认,即全部柱面只分在一个区
w 保存,将操作写入分区表
再依次对剩下的进行分区操作:
# fdisk /dev/sdc
# fdisk /dev/sdd
# fdisk /dev/sde
# fdisk /dev/sdf
# fdisk /dev/sdg
查看分区后的结果:
[root@rac1 ~]# fdisk -l |grep -e sd[bcdefg]1 |sort
/dev/sdb1 2048 8388607 4193280 83 Linux
/dev/sdc1 2048 8388607 4193280 83 Linux
/dev/sdd1 2048 8388607 4193280 83 Linux
/dev/sde1 2048 1048575999 524286976 83 Linux
/dev/sdf1 2048 2147483647 1073740800 83 Linux
/dev/sdg1 2048 2147483647 1073740800 83 Linux
在rac1上对磁盘进行分区后,rac2就不需要再分区了。
rac2上直接查看磁盘:
[root@rac2 ~]# fdisk -l |grep -e sd[bcdefg]1 |sort
/dev/sdb1 2048 8388607 4193280 83 Linux
/dev/sdc1 2048 8388607 4193280 83 Linux
/dev/sdd1 2048 8388607 4193280 83 Linux
/dev/sde1 2048 1048575999 524286976 83 Linux
/dev/sdf1 2048 2147483647 1073740800 83 Linux
/dev/sdg1 2048 2147483647 1073740800 83 Linux
[root@rac2 ~]#
4.关闭防火墙(所有节点上操作)
# systemctl stop firewalld
# systemctl disable firewalld
# systemctl status firewalld
# vim /etc/selinux/config
设置:SELINUX=disabled
立即生效
# setenforce 0
5.设置所有RAC节点之间的时钟同步
方法1)rac1上开启NTP Server、其他rac节点与rac1进行时钟同步
NTP时钟同步的方法,参考:《Centos7 NTP时钟同步配置》https://blog.csdn.net/sunny05296/article/details/65980897/
配置好了以后,自动同步会比较慢,先执行一次立即和NTP Server同步:
# ntpdate -u ntpServerIP
ntp配置完以后,可能需要一段时间才能进行首次同步,可以通过 ntpstat 查看:
# ntpstat
synchronised to NTP server (x.x.x.x) at stratum 4
time correct to within 38 ms
polling server every 128 s
这里遇到了一个坑,定位浪费我好长时间:
ntp时钟同步以后总是时间莫名自动改掉,而且NTP Client和NTP Server配置也正确,ntpdate -u 192.168.235.60、ntpdate -d 192.168.235.60、timedatectl 显示也都正常
但就是 ntpq -p 查询并没有使用NTP Server,而且ntpstat查看总是显示unsynchronised
# ntpstat
unsynchronised
time server re-starting
polling server every 8 s
即使我手动date修改时间以后,也会被自动改掉、时间也不是NTP Server同步来的。
最终排查定位的结果是:我ESXi虚机上启用了虚机和ESXi宿主机时钟同步导致的,之前尝试过使用方案2配置时钟同步,忘了关闭这个配置了。
方法2)只介绍一下、我最终没有使用方法2。
本来是考虑直接设置虚机和ESXi主机之间时钟同步,我刚开始给ESXi宿主机配置NTP服务,自动与时间服务器同步时间,然后再在虚机上安装VMWare Tools,并设置虚机勾选同步客户机时间和主机时间。
ESXi client配置:配置->软件.时间配置->属性->选项,
常规:启动策略配置为与主机一起启动和停止
NTP设置:添加中国的NTP域名“cn.ntp.org.cn”
勾选重启NTP服务以应用更改
设置成功后,结果发现我的ESXi宿主机系统时区是UTC、而虚机节点rac1、rac2的系统时区是CST,时区不一致,导致两者时间显示相差8小时。
官方说ESXi默认UTC时区、而且不支持修改时区。虽然网上有介绍其他方式,我这里就不折腾了,最终没有采用该方案。
ESXi相关SSH命令行修改系统时间的命令(也可以直接在vsphere ESXi client上进行时间配置,不一定非要命令行操作)
ESXi开启SSH服务方法:
ESXi客户端连接以后,配置-安全配置文件-服务-属性,打开服务属性对话框,选择SSH服务,打开选项对话框,启动。
查看ESXi系统时间:
# esxcli system time get
查看ESXi主机主板上的时间:
# esxcli hardware clock get
设置ESXi系统时间(ESXi主机是不能用date命令来设置时间的,需要使用esxcli命令设置,该命令会自从同步系统时间到ESXi主机主板硬件时钟):
# esxcli system time set -y 2020 -M 07 -d 29 -H 13 -m 17 -s 59
查看修改后的ESXi系统时间:
# esxcli system time get
# esxcli hardware clock get
配置好NTP时钟同步后,date查看一下所有RAC节点的时钟是否同步完成。
6.配置主机名(hostname)&RAC节点名称&私有网卡
rac1设置主机名:
# hostnamectl set-hostname rac1
rac2设置主机名:
# hostnamectl set-hostname rac2
rac1和rac2上修改/etc/hosts文件
# vim /etc/hosts #添加内容如下(rac1和rac2 的 /etc/hosts 添加相同的内容)
# for Oracle RAC
192.168.235.60 rac1 #rac1 public ip
192.168.235.61 rac2 #rac2 public ip
192.168.235.62 rac1vip #rac1 vip
192.168.235.63 rac2vip #rac2 vip
192.168.235.64 racscan #scan ip
10.0.0.1 rac1priv #rac1 private ip
10.0.0.2 rac2priv #rac2 private ip
添加虚拟机网卡(最初我使用1块网卡,通过系统多IP绑定的方式,后面考虑Oracle处理可能有问题,而更换了后面的方法)
rac1上添加虚拟Private-IP网卡
永久生效在网卡上绑定Private-IP(如果只是临时生效只需要执行:ifconfig ens160:0 10.0.0.1/24,但我们需要永久生效):
# echo "
#nic ens160:0
TYPE=Ethernet
NAME=ens160:0
DEVICE=ens160:0
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.0.0.1
PREFIX=24
" > /etc/sysconfig/network-scripts/ifcfg-ens160:0
重启网卡:
# service network restart
# ifconfig 查看增加了一个 ens160:0
ens160: xxxxxx
ens160:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255
ether 00:0c:29:72:12:ba txqueuelen 1000 (Ethernet)
rac2上添加虚拟Private-IP网卡:
# echo "
#nic ens160:0
TYPE=Ethernet
NAME=ens160:0
DEVICE=ens160:0
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.0.0.2
PREFIX=24
" > /etc/sysconfig/network-scripts/ifcfg-ens160:0
# service network restart
# ifconfig
ens160: xxxxxx
ens160:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.2 netmask 255.255.255.0 broadcast 10.0.0.255
ether 00:0c:29:ed:a7:c9 txqueuelen 1000 (Ethernet)
添加网卡
后面我在配置静默安装grid的应答文件参数时,注意到 privateInterconnects 参数配置可能会和ens160:0网卡名命名冲突、冒号有可能会导致Oracle解析出问题:
oracle.install.crs.config.privateInterconnects=ens160:192.168.208.0:1,ens160:0:10.0.0.0:2
所以,这里我换一种方式来配置Private-IP网卡,还是老老实实在虚机上,再添加一块网卡作为Private-IP网卡设备,步骤如下:
先删掉之前的配置:
rm -rf /etc/sysconfig/network-scripts/ifcfg-ens160:0
ESXi客户端上添加:编辑虚拟机设置->硬件.添加->添加以太网适配器(我只接了1个物理网卡,添加的网卡适配器类型和原来的网卡保持一致,我的是"VMXNET 3")
添加完毕后,CentOS系统中ifconfig可以看到新增了一个网卡设备ens192,这样我就有两个网卡:ens160, ens192了。
添加后没有自动生成网卡配置文件,手动添加修改配置文件:
cd /etc/sysconfig/network-scripts/
cp ifcfg-ens160 ifcfg-ens192
vim ifcfg-ens192
修改 NAME, DEVICE, IP
注释掉 UUID, GATEWAY, DNS
重启网卡服务
service network restart
其他节点也同样处理。
rac1和rac2的private互通确认,通过ping检查一下。
重启rac1和rac2虚机,然后再确认一下添加的ens160:0仍然存在。
检查网络通信是否正常
rac1和rac2上都测试一下:
ping -c 2 rac1
ping -c 2 rac2
ping -c 2 rac1priv
ping -c 2 rac2priv
7.进行Oracle安装的相关准备工作
7.1 Swap检查(所有节点上操作)
官方给出的配置
内存大小 Swap大小
2.5G~32G 等同内存大小
32G以上 32G
有我的内存8G,所以Swap也分配8G。如果不足,需要创建。如果已满足,则跳过。
查看内存和Swap(也可应free -h查看)
grep SwapTotal /proc/meminfo
grep MemTotal /proc/meminfo
我的Swap只有2G,大小不够,需要设置更大的Swap,root执行的命令如下:
dd if=/dev/zero of=/myswapfile bs=1M count=8192 #由于我内存8G,所以创建8G Swapfile
mkswap /myswapfile #指定作为交换区的文件
swapon /myswapfile #激活交换区文件
echo "/myswapfile swap swap defaults 0 0" >> /etc/fstab #设置开机时启用swap
swapon -s #确认swap已经被使用,另外在/目录可以看到文件swapfile
free -h #如果原来Swap分配的有,显示的值会叠加
reboot #重启虚机,确认重启后Swap大小正常
说明:关于创建Swap的详细介绍,可以参考《Centos7 安装 Oracle11g》https://blog.csdn.net/sunny05296/article/details/56840775
7.2 /tmp检查(所有节点上操作)
# df -h /tmp
官方要求至少剩余空间要大于1G
7.3 修改系统版本,绕过系统检查(所有节点上操作)
由于我是Centos7系统,需要修改系统信息,绕过Oracle安装版本检查
# vim /etc/centos-release
将原来的内容: CentOS Linux release 7.4.1708 (Core)
将内容改为:redhat-7
7.4 创建组&用户&目录(所有rac节点都要执行)
注意:RAC要求各节点的oracle账户、grid账户以及相应的组的id是必须相同的(创建后可查看/etc/passwd和/etc/group)
root执行下面命令:
groupadd -g 1000 oinstall
groupadd -g 1020 asmadmin
groupadd -g 1021 asmdba
groupadd -g 1022 asmoper
groupadd -g 1031 dba
groupadd -g 1032 oper
useradd -m -u 1100 -g oinstall -G asmdba,dba,asmadmin,asmoper grid
useradd -m -u 1101 -g oinstall -G dba,oper,asmdba oracle
mkdir -p /u01/app/grid #grid user $ORACLE_BASE
mkdir -p /u01/app/11.2.0/grid #grid user $ORACLE_HOME
chown -R grid:oinstall /u01
mkdir -p /u01/app/oracle #Oracle数据库安装目录, oracle user $ORACLE_BASE; $ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
mkdir -p /u01/app/oraInventory #Oracle数据库配置文件目录
mkdir -p /u01/app/database #Oracle数据库软件包解压目录
chown oracle:oinstall /u01/app/oracle
chown oracle:oinstall /u01/app/oraInventory
chown oracle:oinstall /u01/app/database
chmod -R 775 /u01/
修改用户密码
passwd oracle
passwd grid
关于Oracle Grid安装的目录创建,官方的原始说明如下:
Creating the Oracle Base Directory Path
The Oracle base directory for the grid installation owner is the location where diagnostic and administrative logs, and other logs associated with Oracle ASM and Oracle Clusterware are stored.
If you have created a path for the Oracle Clusterware home that is compliant with Oracle Optimal Flexible Architecture (OFA) guidelines for Oracle software paths then you do not need to create an Oracle base directory. When OUI finds an OFA-compliant path, it creates the Oracle base directory in that path.
For OUI to recognize the path as an Oracle software path, it must be in the form u[00-99]/app, and it must be writable by any member of the oraInventory (oinstall) group. The OFA path for the Oracle base is /u01/app/user, where user is the name of the software installation owner.
Oracle recommends that you create an Oracle Grid Infrastructure Grid home and Oracle base homes manually, particularly if you have separate Oracle Grid Infrastructure for a cluster and Oracle Database software owners, so that you can separate log files.
For example:
### mkdir -p /u01/app/11.2.0/grid
### mkdir -p /u01/app/grid
### mkdir -p /u01/app/oracle
### chown grid:oinstall /u01/app/11.2.0/grid
### chown grid:oinstall /u01/app/grid
### chown oracle:oinstall /u01/app/oracle
### chmod -R 775 /u01/
### chown -R grid:oinstall /u01
7.5 添加环境变量
所有rac节点上添加环境变量
修改grid和oracle用户的.bash_profile
修改root用户的/etc/profile
rac1添加环境变量:
# vi /home/grid/.bash_profile
umask 022
export ORACLE_SID=+ASM1
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export TNS_ADMIN=$ORACLE_HOME/network/admin
#export NLS_LANG=AMERICAN_AMERICA.zhs16gbk
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export ORA_NLS10=$ORACLE_HOME/nls/data
export ORACLE_TERM=xterm
export EDITOR=vi
export THREADS_FLAG=native
export TEMP=/tmp
export TMPDIR=/tmp
vi /home/oracle/.bash_profile
umask 022
export ORACLE_SID=orcl1
# ORACLE_UNQNAME是11gR2新出现的
#export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/u01/app/oracle
#export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export TNS_ADMIN=$ORACLE_HOME/network/admin
#export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export GRID_HOME=/u01/app/11.2.0/grid
export ORA_NLS10=$GRID_HOME/nls/data
export ORACLE_TERM=xterm
export EDITOR=vi
export THREADS_FLAG=native
export TEMP=/tmp
export TMPDIR=/tmp
rac2
vi /home/grid/.bash_profile
umask 022
export ORACLE_SID=+ASM2
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export TNS_ADMIN=$ORACLE_HOME/network/admin
#export NLS_LANG=AMERICAN_AMERICA.zhs16gbk
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export ORA_NLS10=$ORACLE_HOME/nls/data
export ORACLE_TERM=xterm
export EDITOR=vi
export THREADS_FLAG=native
export TEMP=/tmp
export TMPDIR=/tmp
vi /home/oracle/.bash_profile
umask 022
export ORACLE_SID=orcl2
# ORACLE_UNQNAME是11gR2新出现的
#export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/u01/app/oracle
#export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export TNS_ADMIN=$ORACLE_HOME/network/admin
#export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export GRID_HOME=/u01/app/11.2.0/grid
export ORA_NLS10=$GRID_HOME/nls/data
export ORACLE_TERM=xterm
export EDITOR=vi
export THREADS_FLAG=native
export TEMP=/tmp
export TMPDIR=/tmp
rac1 & rac2:
#用于root用户操作 crsctl 命令,如果不加操作时需要cd到对应目录下才能执行
export GRID_HOME=/u01/app/11.2.0/grid
export PATH=$PATH:$GRID_HOME/bin
退出终端重新登录
检查环境变量生效:
echo $PATH
su - oracle
echo $ORACLE_HOME && echo $ORACLE_SID && exit
su - grid
echo $ORACLE_HOME && echo $ORACLE_SID && exit
7.6 修改内核参数(所有rac节点上操作)
添加内核配置优化参数如下
vi /etc/sysctl.conf
添加下面内容:
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.rp_filter = 1
#设置最大打开文件数
fs.file-max = 6815744
fs.aio-max-nr = 1048576
#共享内存的页数,Linux共享内存页大小为4KB,8G内存设置为:8GB/4KB=8*1024*1024*1024/4KB=2097152
kernel.shmall = 2097152
#最大共享内存,官方文档建议是内存的1/2,例如:8G内存则设置为:4*1024*1024*1024
kernel.shmmax = 4294967296
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
#tcp参数设置
#可使用的IPv4端口范围(TCP/UDP协议允许使用的本地端口号)
net.ipv4.ip_local_port_range = 9000 65500
#默认&最大的TCP数据接收窗口大小(字节)
net.core.rmem_default = 262144
net.core.rmem_max= 4194304
#默认&最大的TCP数据发送窗口大小(字节)
net.core.wmem_default= 262144
net.core.wmem_max= 1048576
#信号相关参数,如果不设置Oracle RAC安装检测失败
kernel.sem = 250 3200 100 128
使内核参数立即生效
sysctl -p
7.7 修改oracle和grid用户限制设置,提高软件运行性能(所有rac节点操作)
vi /etc/security/limits.conf
在文件末尾添加配置项:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
7.8 安装依赖的包
yum install -y binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers glibc-static kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel libstdc++-static make numactl-devel sysstat unixODBC unixODBC-devel compat-libcap1 libXi libXtst
rpm -qa binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers glibc-static kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel libstdc++-static make numactl-devel sysstat unixODBC unixODBC-devel compat-libcap1 libXi libXtst
rpm -qa binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers glibc-static kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel libstdc++-static make numactl-devel sysstat unixODBC unixODBC-devel compat-libcap1 libXi libXtst |wc -l
总计29个依赖包
其中:compat-libcap1 libXi libXtst 是安装Oracle Grid and RAC必须的依赖,但如果只安装Oracle Database则不依赖
有些依赖包如果CentOS7 yum里面没有,可以去 Red Hat Enterprise Linux的yum下载,或者晚上直接wget下载后 rpm -ivh xxx.rpm 安装
注意:
1.Linux不同版本、x86-32、x86-64不同,需要安装Oracle的软件不同,所需要的依赖包也不同
2.官方的Oracle Grid安装说明:https://docs.oracle.com/cd/E11882_01/install.112/e41961/toc.htm
中有关于必须的依赖包的说明:https://docs.oracle.com/cd/E11882_01/install.112/e41961/prelinux.htm#CWLIN225
Table 2-9 Linux x86-64 Oracle Grid Infrastructure and Oracle RAC Package Requirements
Table 2-10 Linux x86-64 Oracle Database Features Package Requirements
3.pdksh只有在Linux 4上需要,Linux 5/6/7都已经被ksh取代
关于依赖包如何查询的补充说明:
不同的OS及OS版本、不同的Oracle版本,所需要的依赖包不同,详情可参考Oracle官网帮助文档(Oracle Database Documentation):
https://docs.oracle.com/en/database/oracle/oracle-database/index.html
选择对应的Oracle版本 -> 查看帮助信息:Install and Upgrade -> Linux Installation Guides
RAC参考:Grid Infrastructure Installation and Upgrade Guide for Linux
DB参考: Database Installation Guide for Linux
-> 4 Configuring Operating Systems for Oracle Database on Linux
-> Operating System Checklist for Oracle Database Installation on Linux
-> Operating System Requirements for x86-64 Linux Platforms
-> Supported Red Hat Enterprise Linux 7 Distributions for x86-64
参考:Table 4-4 x86-64 Red Hat Enterprise Linux 7 Minimum Operating System Requirements
7.9 设置节点互信关系(ssh免密登录)
oracle和grid两个用户都要设置互信(rac1&rac2)
1)对oracle用户设置节点互信关系:
su - oracle
cd ~
ssh-keygen # 这里一路默认回车就行了,在本地机器上使用ssh-keygen产生公钥私钥对
ssh-copy-id -i ~/.ssh/id_rsa.pub oracle@rac1 #将本机的公钥复制到远程机器的authorized_keys文件中(~/.ssh/authorized_key),会提示输入用户密码
ssh-copy-id -i ~/.ssh/id_rsa.pub oracle@rac2
2)对grid用户设置节点互信关系:
exit
su - grid
cd ~
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub grid@rac1
ssh-copy-id -i ~/.ssh/id_rsa.pub grid@rac2
3)测试节点互信:
首次可能会提示输入yes,直接输入yes即可完成登录,不需要密码,后续就不会提示了。
exit
su - oracle
ssh rac1 date
ssh rac2 date
ssh rac1priv date
ssh rac2priv date
exit
su - grid
ssh rac1 date
ssh rac2 date
ssh rac1priv date
ssh rac2priv date
说明:关于互信设置,还有另外一种方式,直接使用软件包解压后提供的ssh互信设置脚本(sshUserSetup.sh)来完成,如果觉得前面设置方法麻烦的话,也可尝试用脚本设置
Oacle安装包解压后,脚本位于:database/sshsetup/sshUserSetup.sh
由于我前面已经手动设置过互信,所以直接跳过下面步骤。
# su - grid
cd $GRID_HOME/deinstall # /u01/app/12.2.0/grid/deinstall
./sshUserSetup.sh -user grid -hosts "rac1 rac2 racpriv rac2priv" -advanced -noPromptPassphrase
exit
# su - oracle
cd $GRID_HOME/deinstall # /u01/app/12.2.0/grid/deinstall
./sshUserSetup.sh -user oracle -hosts "rac1 rac2 racpriv rac2priv" -advanced -noPromptPassphrase
同样的,等设置互信完成后,在所有rac节点上互信测试,能免密登录就OK了。
7.10 Centos7安装配置DNS服务器
如果不配置DNS服务器,静默安装的时候, racscan无法解析(nslookup racscan)拿到scan ip,安装无法继续下去。
7.10 设置共享磁盘(用oracleasm创建ASM磁盘)
前面步骤已经添加并格式化了共享磁盘,本步骤是用oracleasm创建ASM磁盘并完成ASM配置。
用oracleasm在rac1格式化后,rac2上只需要扫描即可。oracleasm需要三个包:kmod-oracleasm, oracleasm-support, oracleasmlib。
rac1上root用户进行操作:
下载oracleasm:
su - root
mkdir /opt/soft
cd $_
wget http://public-yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracleasm-support-2.1.11-2.el7.x86_64.rpm
wget http://download.oracle.com/otn_software/asmlib/oracleasmlib-2.0.12-1.el7.x86_64.rpm
安装oracleasm:
yum install -y kmod-oracleasm
rpm -ivh oracleasmlib-2.0.12-1.el7.x86_64.rpm oracleasm-support-2.1.11-2.el7.x86_64.rpm
rpm -qa oracleasmlib oracleasm-support
配置ASM属性:
# oracleasm configure -i
Default user to own the driver interface [ ]: grid
Default group to own the driver interface [ ]: oinstall
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
# oracleasm init
Creating /dev/oracleasm mount point: /dev/oracleasm
Loading module "oracleasm": oracleasm
Configuring "oracleasm" to use device physical block size
Mounting ASMlib driver filesystem: /dev/oracleasm
创建asm磁盘:
oracleasm createdisk asmocr01 /dev/sdb1
oracleasm createdisk asmocr02 /dev/sdc1
oracleasm createdisk asmocr03 /dev/sdd1
oracleasm createdisk asmarch01 /dev/sde1
oracleasm createdisk asmdata01 /dev/sdf1
oracleasm createdisk asmdata02 /dev/sdg1
查看创建的ASM磁盘:
[root@rac1 ~]# oracleasm listdisks
ASMARCH01
ASMDATA01
ASMDATA02
ASMOCR01
ASMOCR02
ASMOCR03
查看设备
# ls /dev/oracleasm/disks/
ASMARCH01 ASMDATA01 ASMDATA02 ASMOCR01 ASMOCR02 ASMOCR03
说明:
如果磁盘规划有误,需要删除重建,删除asm磁盘命令如下:
oracleasm deletedisk asmocr01
删除后,其他节点reboot重启重新扫描刷新磁盘
rac2上也用root用户进行操作:
下载oracleasm:直接从rac1拷贝
cd /opt
scp -r root@rac1:/opt/soft /opt
安装oracleasm:
cd /opt/soft
yum install -y kmod-oracleasm
rpm -ivh oracleasmlib-2.0.12-1.el7.x86_64.rpm oracleasm-support-2.1.11-2.el7.x86_64.rpm
rpm -qa oracleasmlib oracleasm-support
配置ASM属性:
# oracleasm configure -i
Default user to own the driver interface [ ]: grid
Default group to own the driver interface [ ]: oinstall
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
# oracleasm init
rac2不需要再重复创建ASM磁盘,直接扫描即可
# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
Instantiating disk "ASMOCR02"
Instantiating disk "ASMOCR03"
Instantiating disk "ASMARCH01"
Instantiating disk "ASMOCR01"
Instantiating disk "ASMDATA01"
Instantiating disk "ASMDATA02"
[root@rac2 ~]# oracleasm listdisks
ASMARCH01
ASMDATA01
ASMDATA02
ASMOCR01
ASMOCR02
ASMOCR03
到此,rac1和rac2节点都能看到
8.静默方式安装RAC集群
8.1 上传软件包
先将软件包上传到/u01目录下,然后授权
# chown oracle:oinstall linux.x64_11gR2_database*.zip
# chown grid:oinstall linux.x64_11gR2_grid.zip
# ls -l /u01
total 3323816
drwxrwxr-x 7 grid oinstall 82 Jul 30 23:03 app
-rw-r--r-- 1 oracle oinstall 1239269270 Nov 18 2015 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 oracle oinstall 1111416131 Nov 18 2015 linux.x64_11gR2_database_2of2.zip
-rw-r--r-- 1 grid oinstall 1052897657 Jul 21 15:45 linux.x64_11gR2_grid.zip
8.1 安装集群grid软件
注意:
1.安装时,所有软件只需要在一个节点解压,其他节点不需要。安装GI和DB软件时,安装过程中会自动将软件同步到其他节点。
2.11gR2安装是会用设置的grid用户的$ORACLE_HOME变量来作为GI的HOME目录。如果是Oracle 12c则grid安装不再会按你设置的grid用户的$ORACLE_HOME变量来作为GI的HOME目录,而是直接将你GRID软件的解压目录作为家目录,则必须解压到grid的HOME目录。
1.解压软件包
su - grid
$ echo $ORACLE_HOME # /u01/app/11.2.0/grid
$ cd /u01
$ ls -l
total 3323816
drwxrwxr-x 7 grid oinstall 82 Jul 30 23:03 app
-rw-r--r-- 1 oracle oinstall 1239269270 Nov 18 2015 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 oracle oinstall 1111416131 Nov 18 2015 linux.x64_11gR2_database_2of2.zip
-rw-r--r-- 1 grid oinstall 1052897657 Jul 21 15:45 linux.x64_11gR2_grid.zip
$ unzip linux.x64_11gR2_grid.zip -d /u01/app/11.2.0 #解压后会释放一个grid目录
解压后的目录及文件如下:
[grid@rac1 11.2.0]$ ll /u01/app/11.2.0/
total 0
drwxrwxr-x 8 grid oinstall 180 Jul 31 16:56 grid
[grid@rac1 11.2.0]$ ll /u01/app/11.2.0/grid/
total 1028244
drwxr-xr-x 9 grid oinstall 168 Aug 17 2009 doc
drwxr-xr-x 4 grid oinstall 256 Aug 15 2009 install
-rw-r--r-- 1 grid oinstall 1052897657 Jul 31 16:53 linux.x64_11gR2_grid.zip
drwxrwxr-x 2 grid oinstall 29 Aug 15 2009 response
drwxrwxr-x 2 grid oinstall 34 Aug 15 2009 rpm
-rwxrwxr-x 1 grid oinstall 3795 Jan 29 2009 runcluvfy.sh
-rwxr-xr-x 1 grid oinstall 3227 Aug 15 2009 runInstaller
drwxrwxr-x 2 grid oinstall 29 Aug 15 2009 sshsetup
drwxr-xr-x 14 grid oinstall 4096 Aug 15 2009 stage
-rw-r--r-- 1 grid oinstall 4228 Aug 18 2009 welcome.html
[grid@rac1 11.2.0]$
2.安装grid前先安装grid中cvuqdisk包
切换到root操作
$ exit #切换到root
# yum install -y smartmontools #如果不安装,cvuqdisk安装时会报错 /usr/sbin/smartctl 不存在
# rpm -ivh /u01/app/11.2.0/grid/rpm/cvuqdisk-1.0.7-1.rpm
# su - grid #再次切换到grid继续
3.grid安装前的预检查(非必须)
执行Oracle的检查脚本进行检查:
$ORACLE_HOME/runcluvfy.sh stage -pre crsinst -n rac1,rac2 -verbose #检查当前环境配置是否满足
Oracle 官方建议在安装Oracle Grid Infrastructure前运行脚本来检查各个节点是否满足GI安装的官方要求。
在部署Grid Infrastructure的过程中使用,我们不光要学会怎么用这个脚本,更应该明白其中的一些原理。
runcluvfy.sh将功能在shell中实现,并和GI的安装介质一起提供给用户,使得用户在数据库和CLUSTER安装之前就可以利用这个工具的功能。
runcluvfy.sh语法说明:
-pre: 该选项主要检查是否满足安装的需要。
-post:该选择主要检查安装后组件是否正常。
-n:该选项用于指定节点列表,这里指定了2个节点。
-verbose:该选项用于输出详细的验证信息。
-fixup:这是Oracle 11gR2中新增加的一个参数。利用这个参数,可以产生一个名为runfixup.sh的脚本。
runfixup.sh 脚本中包含一系列的操作系统命令,利用这个脚本可以对操作系统进行一定的修改,使其满足安装条件。
完成系统进行校验之后,以root用户的身份执行脚本runfixup.sh,就可以解决操作系统中一些尚不满足安装条件的情况。
我的检测结果,大部分都OK,问题如下:
1)内核小版本不一致
本来是一致的,可能是由于安装某些软件导致微小的差异,最终结果是passsed,可以忽略该告警。
WARNING:
PRVF-7524 : Kernel version is not consistent across all the nodes.
Kernel version = "3.10.0-1127.18.2.el7.x86_64" found on nodes: rac2.
Kernel version = "3.10.0-1127.13.1.el7.x86_64" found on nodes: rac1.
Result: Kernel version check passed
最终结果还是passwd,直接忽略
2)提示i386的包没有找到,如果以及安装过i686(x86_64)的包了,该类型的错误可以忽略
Check: Kernel parameter for "semmni"
Node Name Configured Required Comment
------------ ------------------------ ------------------------ ----------
rac2 0 128 failed
rac1 0 128 failed
Result: Kernel parameter check failed for "semmni"
我检测结果中提示i386没有找到、但实际x86_64已安装的有:
libaio
glibc
compat-libstdc++-33
libaio-devel
libgcc
libstdc++
unixODBC
unixODBC-devel
3)如果有遇到有些错误是因为要求的版本没有找到,但实际安装的版本比要求的版本高,也可以忽略。
4)pdksh提示没有,由于Redhat7上已经被ksh替代,rpm -qa ksh 已安装即可,可以忽略
5.NTP时钟同步检测失败,没有以"-x"参数启动(没有开启平滑同步模式)
Checking NTP daemon command line for slewing option "-x"
Check: NTP daemon command line
Node Name Slewing Option Set?
------------------------------------ ------------------------
rac2 no
rac1 no
Result:
NTP daemon slewing option check failed on some nodes
PRVF-5436 : The NTP daemon running on one or more nodes lacks the slewing option "-x"
Result: Clock synchronization check using Network Time Protocol(NTP) failed
检测出来的问题不多,直接手动修改一下(rac1 & rac2都要修改),root操作:
问题1、3、4:无需修改,忽略即可。只需要修改问题2和问题5。
问题2:修改内核优化参数
vi /etc/sysctl.conf
kernel.sem = 250 32000 100 128
立即生效:
sysctl -p
说明:
kernel.sem 内核参数是指 semmsl,semmns,semopm,semmni这4个参数。
semmsl : 指每个线号集的最大信号数,Oracle建议是设置为oracle的最大进程数+10
semmni : 指整个系统的信号集的最大数量
semmns : 指整个系统的信号总数,也就是semmni*semmsl的结果
semopm : 指每个semop系统调用可以执行的信号操作的最大数量,建议设置等于 semmsl
Oracle默认设置:semmsl=250, semmns=3200, semopm=100, semmni=128,即: kernel.sem = 250 32000 100 128
例:如果在Oracle的 init.ora 文件参数中设置 processes = 5000
则:semmsl=5010, semmni=128, semmns=semmsl*semmni=641280, semopm=semmsl=5010,即 kernel.sem=5010 641280 5010 128
问题5:修改NTP启动参数:
vi /etc/sysconfig/ntpd
OPTIONS="-g -x"
重启NTP服务
service ntpd restart
修改完毕重新检测:
su - grid
$ORACLE_HOME/runcluvfy.sh stage -pre crsinst -n rac1,rac2 -verbose #检查当前环境配置是否满足
发现其他都OK,还是有一个失败:
Check: Kernel parameter for "semmni"
Node Name Configured Required Comment
------------ ------------------------ ------------------------ ----------
rac2 0 128 failed
rac1 0 128 failed
Result: Kernel parameter check failed for "semmni"
网上找资料说是可能是因为OS是CentOS的缘故,虽然OS已经生效(sysctl -p),但Oracle检测脚本不认为通过。估计是Oracle检测脚本对CentOS7的不兼容吧,不管了,直接忽略,继续往下安装。
如果检测问题比较多,也可以考虑执行下面命令生成修复脚本(我没有使用):
$ORACLE_HOME/runcluvfy.sh stage -pre crsinst -n rac1,rac2 -fixup -verbose
4.静默安装grid(Oracle Grid Infrastructure)
先介绍一下关于disk group和fail group的概念
ASM有几个难理解的概念:ASM磁盘,故障组(FAILGROUP),磁盘组(disk group)。
asm disk: 磁盘比较好裂解,就是我们的磁盘,这个磁盘一般都是做raid以后看到的磁盘。
FAILGROUP: 故障组就是asm disk的一个逻辑组合,如果不指定哪些asm disk属于哪个FAILGROUP,那么可以理解每个asm disk都是一个FAILGROUP。
disk group: 磁盘组比较好理解,就是asm disk的组合。
磁盘组有3种镜像的方式:External redundancy, Normal redundancy, High redundancy。
External:不镜像ASM中的数据
Normal:镜像ASM中的数据一次
High:镜像ASM中的数据两次
这三种镜像的方式,就是针对故障组来说的。如果有2个故障组,就是Normal方式镜像;如果有3个故障组就是High方式镜像。
接下来正式开始 To install and configure 'Grid Infrastructure for Cluster'。
由于是静默安装,所以在安装时安装程序需要找应答文件(response file),根据response file里面配置的内容来进行安装。
response file可以通过一次图形界面安装的配置来生成,该方式需要至少有过一次图形界面的安装。另外还有一种方式是可以直接使用Oracle安装介质(解压后的目录)中提供的标准的response file来进行相应参数修改,安装是指定修改后的response file。
response file存在于解压后的response目录下的crs_install.rsp(网上很多介绍都说是 grid_install.rsp 文件,但我解压后的response下只有crs_install.rsp)
先备份一下原来的响应文件,然后再编辑修改。
cd $ORACLE_HOME/response
cp crs_install.rsp back.crs_install.rsp
vim crs_install.rsp
修改后的关键参数内容如下:
# Do not change the following system generated value.
oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v11_2_0 #响应文件版本、不用修改
ORACLE_HOSTNAME=rac1
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
oracle.install.option=CRS_CONFIG
ORACLE_BASE=/u01/app/grid
ORACLE_HOME=/u01/app/11.2.0/grid
oracle.install.asm.OSDBA=asmdba
oracle.install.asm.OSOPER=asmoper
oracle.install.asm.OSASM=asmadmin
oracle.install.crs.config.gpnp.scanName=racscan
oracle.install.crs.config.gpnp.scanPort=1521
oracle.install.crs.config.clusterName=cluster
oracle.install.crs.config.gpnp.configureGNS=false
oracle.install.crs.config.gpnp.gnsSubDomain=
oracle.install.crs.config.gpnp.gnsVIPAddress=
oracle.install.crs.config.autoConfigureClusterNodeVIP=false
oracle.install.crs.config.clusterNodes=rac1:rac1vip,rac2:rac2vip
# 1代表public,2代表private,如果是一个网卡绑定多IP(ens160, ens160:0)可能填法还不一样,没找到如何解决,后来改成了添加物理网卡。注意:这里配置的是网段地址
oracle.install.crs.config.privateInterconnects=ens160:192.168.235.0:1,ens192:10.0.0.0:2
oracle.install.crs.config.storageOption=ASM_STORAGE
# 这项只和windows有关,Linux不设置
oracle.install.crs.config.sharedFileSystemStorage.diskDriveMapping=
#-------------------------------------------------------------------------------
# These properties are applicable only if FILE_SYSTEM_STORAGE is chosen for
# storing OCR and voting disk //只有存储类型使用文件系统时才需要配置OCR & voting disk,asm无需配置
# Specify the location(s) and redundancy for OCR and voting disks
# In case of windows, mention the drive location that is specified to be
# formatted for DATA in the above property.
# Multiple locations can be specified, separated by commas
# Redundancy can be one of these:
# EXTERNAL - one(1) location should be specified for OCR and voting disk
# NORMAL - three(3) locations should be specified for OCR and voting disk
#-------------------------------------------------------------------------------
oracle.install.crs.config.sharedFileSystemStorage.votingDiskLocations=
oracle.install.crs.config.sharedFileSystemStorage.votingDiskRedundancy=NORMAL
oracle.install.crs.config.sharedFileSystemStorage.ocrLocations=
oracle.install.crs.config.sharedFileSystemStorage.ocrRedundancy=NORMAL
oracle.install.crs.config.useIPMI=false
oracle.install.crs.config.ipmi.bmcUsername=
oracle.install.crs.config.ipmi.bmcPassword=
# ASM相关配置,使用ASM需要配置,使用文件系统则不需要
oracle.install.asm.SYSASMPassword=1q2w3e
oracle.install.asm.diskGroup.name=ocr
#-------------------------------------------------------------------------------
# Redundancy level to be used by ASM.
# It can be one of the following
# - NORMAL
# - HIGH
# - EXTERNAL
# Example: oracle.install.asm.diskGroup.redundancy=NORMAL
#
#-------------------------------------------------------------------------------
oracle.install.asm.diskGroup.redundancy=NORMAL
#-------------------------------------------------------------------------------
# List of disks to create a ASM DiskGroup
#
# Example: oracle.install.asm.diskGroup.disks=/oracle/asm/disk1,/oracle/asm/disk2
#
#-------------------------------------------------------------------------------
#oracle.install.asm.diskGroup.disks=ORCL:ASMOCR01,ORCL:ASMOCR02,ORCL:ASMOCR03 网上有的介绍用的是该方式,我没有尝试
oracle.install.asm.diskGroup.disks=/dev/oracleasm/disks/ASMOCR01,/dev/oracleasm/disks/ASMOCR02,/dev/oracleasm/disks/ASMOCR03
oracle.install.asm.diskGroup.diskDiscoveryString=/dev/oracleasm/disks/*
oracle.install.asm.monitorPassword=1q2w3e
oracle.install.crs.upgrade.clusterNodes=
oracle.install.asm.upgradeASM=false
5.执行静默安装命令
[grid@rac1 grid]$ cd $ORACLE_HOME
[grid@rac1 grid]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile $ORACLE_HOME/response/crs_install.rsp
参数说明:
-silent 静默安装
-ignorePrereq 忽略预检测告警信息
-ignoreSysPrereqs 忽略系统的安装前检查的结果
-responseFile 指定应答文件
-force 强制安装
注意:网上很多介绍安装是都指定了参数 -showProgress (显示安装进度),刚开始我带上该参数报错:
The command line arguments '-showProgress' are not valid options.
后面通过 runInstaller -help 查看,我的runInstaller并不支持 -showProgress 参数,需要删除该参数。
如果安装过程中出错终止,查看日志目录/tmp/OraInstall2020-08-02_12-25-11AM下的日志文件,获取错误详情。日志目录由 .log, .err, .out 三个日志文件。
我遇到的问题如下:
问题1:
[grid@rac1 grid]$ [WARNING] [INS-08109] Unexpected error occurred while validating inputs at state 'CRSNodeInformationUI'.
CAUSE: No additional information available.
ACTION: Contact Oracle Support Services or refer to the software manual.
SUMMARY:
- For input string: "10.0.0.1"
A log of this session is currently saved as: /tmp/OraInstall2020-08-02_12-25-11AM/installActions2020-08-02_12-25-11AM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.
[root@rac1 ~]# tail -100f /tmp/OraInstall2020-08-02_12-25-11AM/oraInstall2020-08-02_12-25-11AM.err
---# Begin Stacktrace #---------------------------
ID: oracle.install.commons.util.exception.DefaultErrorAdvisor:439
oracle.install.commons.flow.FlowException: [INS-08109] Unexpected error occurred while validating inputs at state 'CRSNodeInformationUI'.
at oracle.install.commons.flow.AbstractFlowExecutor.validate(AbstractFlowExecutor.java:399)
at oracle.install.commons.flow.AbstractFlowExecutor.leaveVertex(AbstractFlowExecutor.java:607)
at oracle.install.commons.flow.AbstractFlowExecutor.transition(AbstractFlowExecutor.java:321)
at oracle.install.commons.flow.AbstractFlowExecutor.nextState(AbstractFlowExecutor.java:261)
at oracle.install.commons.flow.SilentFlowExecutor.execute(SilentFlowExecutor.java:67)
at oracle.install.commons.flow.AbstractFlowExecutor.execute(AbstractFlowExecutor.java:206)
at oracle.install.commons.flow.FlowApplication.executeFlow(FlowApplication.java:144)
at oracle.install.commons.flow.FlowApplication.run(FlowApplication.java:150)
at oracle.install.commons.base.driver.common.Installer.run(Installer.java:260)
at oracle.install.commons.util.Application.startup(Application.java:869)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:164)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)
at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:265)
at oracle.install.ivw.crs.driver.CRSInstaller.startup(CRSInstaller.java:96)
at oracle.install.ivw.crs.driver.CRSInstaller.main(CRSInstaller.java:103)
Caused by: java.lang.NumberFormatException: For input string: "10.0.0.1"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:456)
at java.lang.Integer.parseInt(Integer.java:497)
at oracle.install.ivw.crs.validator.CRSValidationHelper._getDefaultSubnets(CRSValidationHelper.java:405)
at oracle.install.ivw.crs.validator.CRSValidationHelper._validateNodes(CRSValidationHelper.java:510)
at oracle.install.ivw.crs.validator.CRSValidationHelper.validateNodeVIPs(CRSValidationHelper.java:638)
at oracle.install.ivw.crs.validator.CRSNodeInformationValidator.validate(CRSNodeInformationValidator.java:152)
at oracle.install.commons.flow.validation.ValidationHelper.validateState(ValidationHelper.java:178)
at oracle.install.commons.flow.AbstractFlowExecutor.validate(AbstractFlowExecutor.java:394)
... 14 more
定位&解决办法:
网上找了好久,没有找到有效信息,问题依旧。
最终仔细思考,"10.0.0.1"引起了我的注意,猜测这个可能是一个配置参数,Oracle期望的是一个整数值,而拿到的是一个字符串,导致处理失败。
因此,联想到可能是应答文件参数配置有误,查找应答文件中的字符串"10.0.0.1":
[grid@rac1 grid]$ cat response/crs_install.rsp |grep "10.0.0.1"
oracle.install.crs.config.privateInterconnects=ens160:192.168.235.60:1,ens192:0:10.0.0.1:2
[grid@rac1 grid]$
问题找到了,原来是配置网卡设备&IP地址的时候,中间多写了一个"0"导致参数解析失败。
修改后问题解决。
问题2:
[FATAL] [INS-40925] One or more nodes have interfaces not configured with a subnet that is common across all cluster nodes.
CAUSE: Not all nodes have network interfaces that are configured on subnets that are common to all nodes in the cluster.
ACTION: Ensure all cluster nodes have a public interface defined with the same subnet accessible by all nodes in the cluster.
A log of this session is currently saved as: /tmp/OraInstall2020-08-01_04-48-01PM/installActions2020-08-01_04-48-01PM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.
定位&解决办法:
最终定位原因是 响应文件中的参数 privateInterconnects 应该配置网段地址、而不是主机地址,配错安装会失败:[INS-40925]
问题3:
[WARNING] [INS-30011] The password entered does not conform to the Oracle recommended standards.
CAUSE: Oracle recommends that the SYS password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
ACTION: Provide a password that conforms to the Oracle recommended standards.
[WARNING] [INS-30011] The password entered does not conform to the Oracle recommended standards.
CAUSE: Oracle recommends that the ASMSNMP password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
ACTION: Provide a password that conforms to the Oracle recommended standards.
[WARNING] [INS-32016] The selected Oracle home contains directories or files.
CAUSE: The selected Oracle home contained directories or files.
ACTION: To start with an empty Oracle home, either remove its contents or choose another location.
SEVERE:OUI-10182:The effective user ID does not match the owner of the file, or the process is not the super-user; the system indicates that super-user privilege is required.
[root@rac1 /]#
前面几个WARNING都没有关系可以忽略,关键错误:
SEVERE:OUI-10182:The effective user ID does not match the owner of the file, or the process is not the super-user; the system indicates that super-user privilege is required.
解决办法:
用户权限问题,解决方法:用root帐户在/etc下建立文件oraInst.loc,并写入以下内容:
# vi /etc/oraInst.loc
inventory_loc=/u01/app/oraInventory
inst_group=oinstall
重新执行安装。
$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile $ORACLE_HOME/response/crs_install.rsp
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 81543 MB Passed
Checking swap space: must be greater than 150 MB. Actual 10239 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-08-01_07-39-26PM. Please wait ...[grid@rac1 grid]$
[grid@rac1 grid]$
[grid@rac1 grid]$
[grid@rac1 grid]$
[grid@rac1 grid]$ [WARNING] [INS-30011] The password entered does not conform to the Oracle recommended standards.
CAUSE: Oracle recommends that the SYS password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
ACTION: Provide a password that conforms to the Oracle recommended standards.
[WARNING] [INS-30011] The password entered does not conform to the Oracle recommended standards.
CAUSE: Oracle recommends that the ASMSNMP password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
ACTION: Provide a password that conforms to the Oracle recommended standards.
[WARNING] [INS-32016] The selected Oracle home contains directories or files.
CAUSE: The selected Oracle home contained directories or files.
ACTION: To start with an empty Oracle home, either remove its contents or choose another location.
[WARNING] [INS-30011] The password entered does not conform to the Oracle recommended standards.
CAUSE: Oracle recommends that the SYS password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
ACTION: Provide a password that conforms to the Oracle recommended standards.
[WARNING] [INS-30011] The password entered does not conform to the Oracle recommended standards.
CAUSE: Oracle recommends that the ASMSNMP password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
ACTION: Provide a password that conforms to the Oracle recommended standards.
[WARNING] [INS-32016] The selected Oracle home contains directories or files.
CAUSE: The selected Oracle home contained directories or files.
ACTION: To start with an empty Oracle home, either remove its contents or choose another location.
You can find the log of this install session at:
/u01/app/oraInventory/logs/installActions2020-08-01_07-39-26PM.log
[WARNING] [INS-30011] The password entered does not conform to the Oracle recommended standards.
CAUSE: Oracle recommends that the SYS password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
ACTION: Provide a password that conforms to the Oracle recommended standards.
[WARNING] [INS-30011] The password entered does not conform to the Oracle recommended standards.
CAUSE: Oracle recommends that the ASMSNMP password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
ACTION: Provide a password that conforms to the Oracle recommended standards.
[WARNING] [INS-32016] The selected Oracle home contains directories or files.
CAUSE: The selected Oracle home contained directories or files.
ACTION: To start with an empty Oracle home, either remove its contents or choose another location.
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/u01/app/oraInventory/orainstRoot.sh
/u01/app/11.2.0/grid/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Configuration assistants have not been run. This can happen for following reasons - either root.sh is to be run before config or Oracle Universal Installer was invoked with the -noConfig option.
"/u01/app/11.2.0/grid/cfgtoollogs/configToolAllCommands" script contains all commands to be executed by the configuration assistants. This file may be used to run the configuration assistants outside of OUI. Note that you may have to update this script with passwords (if any) before executing the same.
Successfully Setup Software.
安装完成,正常会提示执行两个脚本:
/u01/app/oraInventory/orainstRoot.sh
/u01/app/11.2.0/grid/root.sh
另开会话分别在各节点上依次执行这两个脚本,执行完后会要求在运行安装程序的节点上以root帐户执行/u01/app/11.2/grid/cfgtoollogs/configToolAllCommands
安要求执行完即可。
按照提示以root用户运行脚本,rac1上执行完后,还需要在rac2上执行
[root@rac1 /]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@rac1 /]# /u01/app/11.2.0/grid/root.sh
Check /u01/app/11.2.0/grid/install/root_rac1_2020-08-01_19-45-46.log for the output of root script
[root@rac1 /]#
我执行第二脚本 /u01/app/11.2.0/grid/root.sh 的时候卡住了,日志如下
[root@rac1 /]# tail /u01/app/11.2.0/grid/install/root_rac1_2020-08-01_19-45-46.log
peer pa cert TP
pa peer cert TP
profile reader pa cert TP
profile reader peer cert TP
peer user cert
pa user cert
Adding daemon to inittab
CRS-4124: Oracle High Availability Services startup failed.
CRS-4000: Command Start failed, or completed with errors.
ohasd failed to start: Inappropriate ioctl for device
[root@rac1 /]#
网上搜索,原来这个错误:
CRS-4124: Oracle High Availability Services startup failed.
CRS-4000: Command Start failed, or completed with errors.
ohasd failed to start: Inappropriate ioctl for device
还是11gR2 RAC (11.2.0.1) 的一个经典bug。
解决办法如下:
# ls -l /var/tmp/.oracle/npohasd
# chown root:oinstall /var/tmp/.oracle/npohasd #修改该文件权限,将root:root修改为root:oinstall
# /u01/app/11.2.0/grid/crs/install/roothas.pl -deconfig -force -verbose #重新执行root.sh之前先删除配置
# /u01/app/11.2.0/grid/root.sh #重新执行root.sh,等执行过程提示:Adding daemon to inittab 时,同步执行dd命令
# /bin/dd if=/var/tmp/.oracle/npohasd of=/dev/null bs=1024 count=1
如果出现 /bin/dd: opening`/var/tmp/.oracle/npohasd': No such file or directory 的时候文件还没生成就继续执行,重复操作,直到成功为止,一般出现 Adding daemon to inittab 这条信息的时候执行 dd 命令。
最终root.sh脚本执行成功:
rac2 2020/08/01 20:42:07 /u01/app/11.2.0/grid/cdata/rac2/backup_20200801_204207.olr
Preparing packages...
Configure Oracle Grid Infrastructure for a Cluster ... succeeded
Oracle 11gR2 的这个bug对于首次安装的人来说,真是坑死人啊。
6.grid安装完成,执行下列命令,验证一下状态:
su - grid
$ crsctl query css votedisk #检查表决磁盘(Voting disk)
$ ocrcheck #检查Oracle集群注册表(OCR)
$ crsctl check crs #检查CRS状态
$ crsctl check cluster #检查集群信息(本节点)
$ crsctl check cluster -all #检查集群信息(所有节点)
$ crsctl check cluster -n rac1 rac2 #检查集群信息(指定的节点)
$ olsnodes -n #检查集群节点状态
$ srvctl status asm -a #检查Oracle ASM功能
$ ps -ef | grep lsnr | grep -v 'grep' | grep -v 'ocfs' | awk '{print $9}' #检查两个节点上的 Oracle TNS 监听器服务
$ crsctl check ctss #检查时间CTSS
执行结果如下:
[grid@rac1 ~]$ crsctl query css votedisk #检查表决磁盘(Voting disk)
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 2646211ae83a4f1fbfa3f3e71054b31c (/dev/oracleasm/disks/ASMOCR01) [OCR]
2. ONLINE 9b03444e5c014fbcbf9d178aed7af3b2 (/dev/oracleasm/disks/ASMOCR02) [OCR]
3. ONLINE 9770bf3077264f73bfb8e54f4cea07c2 (/dev/oracleasm/disks/ASMOCR03) [OCR]
Located 3 voting disk(s).
[grid@rac1 ~]$ ocrcheck #检查Oracle集群注册表(OCR)
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 1984
Available space (kbytes) : 260136
ID : 870882427
Device/File Name : +ocr
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check bypassed due to non-privileged user
[grid@rac1 ~]$
[grid@rac1 ~]$ crsctl check crs #检查CRS状态
CRS-4638: Oracle High Availability Services is online
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
[grid@rac1 ~]$
[grid@rac1 ~]$ crsctl check cluster #检查集群信息(本节点)
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
[grid@rac1 ~]$
[grid@rac1 ~]$ crsctl check cluster -all #检查集群信息(所有节点)
**************************************************************
rac1:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
rac2:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
[grid@rac1 ~]$
[grid@rac1 ~]$ crsctl check cluster -n rac1 rac2 #检查集群信息(指定的节点)
**************************************************************
rac1:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
rac2:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
[grid@rac1 ~]$
[grid@rac1 ~]$ olsnodes -n #检查集群节点状态
rac1 1
rac2 2
[grid@rac1 ~]$
[grid@rac1 ~]$ srvctl status asm -a #检查Oracle ASM功能
ASM is running on rac1,rac2
ASM is enabled.
[grid@rac1 ~]$
[grid@rac1 ~]$ ps -ef | grep lsnr | grep -v 'grep' | grep -v 'ocfs' | awk '{print $9}' #检查两个节点上的 Oracle TNS 监听器服务
LISTENER_SCAN1
[grid@rac1 ~]$
[grid@rac1 ~]$ crsctl check ctss #检查时间CTSS
CRS-4700: The Cluster Time Synchronization Service is in Observer mode.
[grid@rac1 ~]$
7.创建磁盘组(disk group)
查看表决磁盘
$ crsctl query css votedisk
创建磁盘组
方法1)
su - grid
sqlplus / as sysasm
-- 先查看一下全局磁盘和磁盘组信息
set linesize 200
col path for a30
select name,path,state,group_number from v$asm_disk;
SQL> select name,path,state,group_number from v$asm_disk;
NAME PATH STATE GROUP_NUMBER
------------------------------------------------------------------------------------------ ------------------------------ ------------------------ ------------
/dev/oracleasm/disks/ASMDATA01 NORMAL 0
/dev/oracleasm/disks/ASMDATA02 NORMAL 0
/dev/oracleasm/disks/ASMARCH01 NORMAL 0
OCR_0000 /dev/oracleasm/disks/ASMOCR01 NORMAL 1
OCR_0001 /dev/oracleasm/disks/ASMOCR02 NORMAL 1
OCR_0002 /dev/oracleasm/disks/ASMOCR03 NORMAL 1
select INST_ID,name,free_mb,state from gv$asm_diskgroup;
SQL> select INST_ID,name,free_mb,state from gv$asm_diskgroup;
INST_ID NAME FREE_MB STATE
---------- ------------------------------------------------------------------------------------------ ---------- ---------------------------------
1 OCR 11359 MOUNTED
2 OCR 11359 MOUNTED
--创建磁盘组
-- for DATA
create diskgroup DATA external redundancy disk '/dev/oracleasm/disks/ASMDATA01';
alter diskgroup DATA add disk '/dev/oracleasm/disks/ASMDATA02';
-- for ARCH
create diskgroup ARCH external redundancy disk '/dev/oracleasm/disks/ASMARCH01';
--再查看全局磁盘和磁盘组
select name,path,state,group_number from v$asm_disk;
NAME PATH STATE GROUP_NUMBER
------------------------------------------------------------------------------------------ ------------------------------ ------------------------ ------------
DATA_0000 /dev/oracleasm/disks/ASMDATA01 NORMAL 2
DATA_0001 /dev/oracleasm/disks/ASMDATA02 NORMAL 2
OCR_0000 /dev/oracleasm/disks/ASMOCR01 NORMAL 1
ARCH_0000 /dev/oracleasm/disks/ASMARCH01 NORMAL 3
OCR_0001 /dev/oracleasm/disks/ASMOCR02 NORMAL 1
OCR_0002 /dev/oracleasm/disks/ASMOCR03 NORMAL 1
select INST_ID,name,free_mb,state from gv$asm_diskgroup;
INST_ID NAME FREE_MB STATE
---------- ------------------------------------------------------------------------------------------ ---------- ---------------------------------
2 OCR 11359 MOUNTED
2 DATA 0 DISMOUNTED
2 ARCH 0 DISMOUNTED
1 OCR 11359 MOUNTED
1 DATA 2097080 MOUNTED
1 ARCH 511945 MOUNTED
添加磁盘组后,其他节点需要mount才能将状态unmount->mount
rac2上查看磁盘和磁盘组:
# su - grid
SQL> sqlplus / as sysasm
SQL> set linesize 200
SQL> col path for a30
SQL> select name,path,state,group_number from v$asm_disk;
NAME PATH STATE GROUP_NUMBER
------------------------------------------------------------------------------------------ ------------------------------ ------------------------ ------------
/dev/oracleasm/disks/ASMDATA02 NORMAL 0
/dev/oracleasm/disks/ASMDATA01 NORMAL 0
/dev/oracleasm/disks/ASMARCH01 NORMAL 0
OCR_0000 /dev/oracleasm/disks/ASMOCR01 NORMAL 1
OCR_0002 /dev/oracleasm/disks/ASMOCR03 NORMAL 1
OCR_0001 /dev/oracleasm/disks/ASMOCR02 NORMAL 1
6 rows selected.
SQL> select INST_ID,name,free_mb,state from gv$asm_diskgroup;
INST_ID NAME FREE_MB STATE
---------- ------------------------------------------------------------------------------------------ ---------- ---------------------------------
1 OCR 11359 MOUNTED
1 DATA 2097080 MOUNTED
1 ARCH 511945 MOUNTED
2 OCR 11359 MOUNTED
2 DATA 0 DISMOUNTED
2 ARCH 0 DISMOUNTED
6 rows selected.
SQL>
rac2上mount操作:
alter diskgroup DATA mount;
alter diskgroup ARCH mount;
然后再查看全局磁盘组,都已经mount了:
SQL> select INST_ID,name,free_mb,state from gv$asm_diskgroup;
INST_ID NAME FREE_MB STATE
---------- ------------------------------------------------------------------------------------------ ---------- ---------------------------------
1 OCR 11359 MOUNTED
1 DATA 2097037 MOUNTED
1 ARCH 511902 MOUNTED
2 OCR 11359 MOUNTED
2 DATA 2097037 MOUNTED
2 ARCH 511902 MOUNTED
SQL> exit
$ srvctl enable diskgroup -g ARCH #最初我没有设置,重启后丢失了ARCH,手动能启动,不知是否必须手动设置enable
======== 到此 grid 安装完毕、磁盘组也添加好了,后面剩下安装 Oracle Database软件 ========
退出到grid用户shell命令行
$ crsctl status res -t #查看集群状态
[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
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
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE rac1
ora.oc4j
1 OFFLINE OFFLINE
ora.rac1.vip
1 ONLINE ONLINE rac1
ora.rac2.vip
1 ONLINE ONLINE rac2
ora.scan1.vip
1 ONLINE ONLINE rac1
[grid@rac1 ~]$
$ crs_stat -t #查看ASM状态
[grid@rac1 ~]$ crs_stat -t #查看ASM状态
Name Type Target State Host
------------------------------------------------------------
ora.ARCH.dg ora....up.type ONLINE ONLINE rac1
ora.DATA.dg ora....up.type ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type ONLINE ONLINE rac1
ora.OCR.dg ora....up.type ONLINE ONLINE rac1
ora.asm ora.asm.type ONLINE ONLINE rac1
ora.eons ora.eons.type ONLINE ONLINE rac1
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE rac1
ora.oc4j ora.oc4j.type OFFLINE OFFLINE
ora.ons ora.ons.type ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac1
ora.rac1.gsd application OFFLINE OFFLINE
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip ora....t1.type ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora.rac2.gsd application OFFLINE OFFLINE
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip ora....t1.type ONLINE ONLINE rac2
ora.scan1.vip ora....ip.type ONLINE ONLINE rac1
[grid@rac1 ~]$
8.安装Oracle数据库软件(Oracle Database)
8.1 rac1上用oracle用户操作
su - oracle
cd /u01/
unzip linux.x64_11gR2_database_1of2.zip -d /u01/app
unzip linux.x64_11gR2_database_2of2.zip -d /u01/app
ls -l /u01/app |grep database
drwxrwxr-x 8 oracle oinstall 128 Aug 1 22:20 database
ls -l /u01/app/database
total 16
drwxr-xr-x 12 oracle oinstall 203 Aug 17 2009 doc
drwxr-xr-x 4 oracle oinstall 223 Aug 15 2009 install
drwxrwxr-x 2 oracle oinstall 61 Aug 15 2009 response
drwxr-xr-x 2 oracle oinstall 34 Aug 15 2009 rpm
-rwxr-xr-x 1 oracle oinstall 3226 Aug 15 2009 runInstaller
drwxrwxr-x 2 oracle oinstall 29 Aug 15 2009 sshsetup
drwxr-xr-x 14 oracle oinstall 4096 Aug 15 2009 stage
-rw-r--r-- 1 oracle oinstall 5402 Aug 18 2009 welcome.html
解压会释放database目录,如果释放的目录和文件权限不对的话需要执行: chown –R oracle:oinstall /u01/app/database
8.2 安装前执行检查脚本验证环境(我直接跳过该步骤,由于我安装grid时已经都同步配置过了,应该不会有问题,就不检测了,直接跳到8.3)
/home/grid/grid/runcluvfy.sh stage -pre dbinst -n oracle-rac1,oracle-rac2 -verbose
8.3 静默安装前编辑应答文件
cd /u01/app/database
cp -r response bak.response
vim response/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
#------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# 1. INSTALL_DB_SWONLY //只安装数据库软件
# 2. INSTALL_DB_AND_CONFIG //安装数据库软件 & 建库
# 3. UPGRADE_DB //升级数据库
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_SWONLY
#主机名,如果没有设置,则填localhost
ORACLE_HOSTNAME=rac1
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
#ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_HOME=/opt/oracle/product/11.2.0
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle
.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,or
acle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.CLUSTER_NODES=rac1,rac2
#下列参数建库的话需要填、不建库也可以不填
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
#所有用户名的密码
oracle.install.db.config.starterdb.password.ALL=1q2w3e
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
#是否自动备份
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=ASM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
#使用ASM存储数据库文件才需要指定
oracle.install.db.config.asm.diskGroup=DATA
#使用ASM存储数据库文件才需要指定
oracle.install.db.config.asm.ASMSNMPPassword=1q2w3e
#上面参数,建库需要填,不建库可以不填
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
#11g的一个bug,这里必须设置为true,否则安装会报错
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
8.4 执行静默安装数据库
./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /u01/app/database/response/db_install.rsp
rac1安装过程中会自动将软件拷贝到rac2节点。安装成功后,会提示执行root.sh脚本:
[oracle@rac1 database]$ The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/u01/app/oracle/product/11.2.0/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
分别在rac1, rac2上以root执行脚本:
/u01/app/oracle/product/11.2.0/root.sh
[root@rac1 ~]# /u01/app/oracle/product/11.2.0/root.sh
Check /u01/app/oracle/product/11.2.0/install/root_rac1_2020-08-02_00-00-55.log for the output of root script
[root@rac1 ~]#
[root@rac1 ~]# cat /u01/app/oracle/product/11.2.0/install/root_rac1_2020-08-02_00-00-55.log
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.2.0
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
[root@rac1 ~]#
到此,Oracle Database软件安装完毕。接下来建库。
9.dbca静默建库(db)
9.1 执行dbca命令静默建库(orcl)
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName orcl -sid orcl -sysPassword 1q2w3e -systemPassword 1q2w3e -storageType ASM -diskGroupName DATA -nationalCharacterSet "AL16UTF16" -characterSet "AL32UTF8" -nodeinfo rac1,rac2 -sampleSchema false -asmSysPassword 1q2w3e -obfuscatedPasswords false
参数说明:
-silent : 静默安装
-createDatabase : 创建数据库
-templateName : 模板 General_Purpose.dbc
-gdbName : 全局名称
-sid : 实例名
-sysPassword : sys 用户的密码
-systemPassword : system 用户的密码
-storageType : 存储类型,此处是 ASM
-diskGroupName : 卷组名称
-nationalCharacterSet : 国家字符集,Valid values : "UTF8" or "AL16UTF16",如果不设,默认值为 "AL16UTF16"
-characterSet : 字符集
-nodeinfo : 节点信息,此处应填节点名称
-sampleSchema : 是否需要 sample 实例,此处填 false
-asmSysPassword : asm 用户密码
-obfuscatedPasswords : Set to true if passwords are encrypted,默认为false
关于 characterSet 和 nationalCharacterSet
characterSet : 影响 char,varchar,varchar2 等数据类型
nationalCharacterSet :影响 nchar,nvarchar,nvarchar2 等数据类型
建库报错:找不到 listener 监听服务
# tail -f /u01/app/oracle/cfgtoollogs/dbca/orcl.log
Cluster database creation requires Default listener configured and running in Grid Infrastructure home. Use NETCA in Grid Infrastructure home - "/u01/app/11.2.0/grid" to configure a listener before proceeding.
定位排查:
我还没有启动监听服务?
[oracle@rac1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 02-AUG-2020 00:45:26
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
[oracle@rac1 ~]$
直接通过 lsnrctl status 查看监听服务不存在。
但发现 1521 端口已经监听中了:
$ netstat -an |grep 1521
tcp 0 0 192.168.235.64:1521 0.0.0.0:* LISTEN
问题原因,应该是:没有 listener 服务添加入 crs 中。
将监听服务 listener 服务添加入 crs 中:
$ exit
[root@rac1 ~]# su - grid
Last login: Sat Aug 1 21:52:50 CST 2020 on pts/1
先查看一下 crs 状态
[grid@rac1 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.ARCH.dg ora....up.type ONLINE ONLINE rac1
ora.DATA.dg ora....up.type ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type ONLINE ONLINE rac1
ora.OCR.dg ora....up.type ONLINE ONLINE rac1
ora.asm ora.asm.type ONLINE ONLINE rac1
ora.eons ora.eons.type ONLINE ONLINE rac1
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE rac1
ora.oc4j ora.oc4j.type OFFLINE OFFLINE
ora.ons ora.ons.type ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac1
ora.rac1.gsd application OFFLINE OFFLINE
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip ora....t1.type ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora.rac2.gsd application OFFLINE OFFLINE
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip ora....t1.type ONLINE ONLINE rac2
ora.scan1.vip ora....ip.type ONLINE ONLINE rac1
[grid@rac1 ~]$
使用srvctl指令查看listener服务
[grid@oel11g ~]$ srvctl status listener
PRCN-2044 : No listener exists
没有listener服务添加入crs中,通过如下指令加 listener 加入到 crs 服务中:
[grid@oel11g ~]$ srvctl add listener
[grid@oel11g ~]$ srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is not running
监听服务已加入 crs 服务中
启动 listener 服务
[grid@oel11g ~]$ srvctl start listener
[grid@oel11g ~]$ srvctl status listener
查看监听服务状态
[grid@rac1 ~]$ srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): rac1,rac2
查看集群状态
[grid@rac1 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.ARCH.dg ora....up.type ONLINE ONLINE rac1
ora.DATA.dg ora....up.type ONLINE ONLINE rac1
ora....ER.lsnr ora....er.type ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type ONLINE ONLINE rac1
ora.OCR.dg ora....up.type ONLINE ONLINE rac1
ora.asm ora.asm.type ONLINE ONLINE rac1
ora.eons ora.eons.type ONLINE ONLINE rac1
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE rac1
ora.oc4j ora.oc4j.type OFFLINE OFFLINE
ora.ons ora.ons.type ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application OFFLINE OFFLINE
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip ora....t1.type ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application OFFLINE OFFLINE
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip ora....t1.type ONLINE ONLINE rac2
ora.scan1.vip ora....ip.type ONLINE ONLINE rac1
[grid@rac1 ~]$
监听服务起来后,此时便可以继续建库了。
重新执行静默建库成功。
查看集群状态(db服务: ora.orcl.db)
SQL> exit
[root@rac1 ~]# su - grid
[grid@rac1 ~]$ crsctl stat res ora.orcl.db -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.orcl.db
1 ONLINE ONLINE rac1 Open
2 ONLINE ONLINE rac2 Open
[grid@rac1 ~]$
看到集群中已有 db 服务,状态 online。说明刚刚操作都正常了。
通过dbca创建的库,会自动将数据库资源添加到CRS管理,无需手动再添加。
srvctl查看Oracle实例(数据库)状态:
[grid@rac1 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node rac1
Instance orcl2 is running on node rac2
srvctl查询当个数据库实例状态:
[grid@rac1 ~]$ srvctl status instance -d orcl -i orcl1
Instance orcl1 is running on node rac1
显示所有配置的数据库
[grid@rac1 ~]$ srvctl config database
orcl
查看数据库配置
[grid@rac1 ~]$ srvctl config database -d orcl -a
Database unique name: orcl
Database name: orcl
Oracle home: /u01/app/oracle/product/11.2.0
Oracle user: oracle
Spfile: +DATA/orcl/spfileorcl.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: orcl
Database instances: orcl1,orcl2
Disk Groups: DATA
Services:
Database is enabled
Database is administrator managed
[grid@rac1 ~]$
查看scan状态
[grid@rac1 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac1
[grid@rac1 ~]$
节点应用程序状态
srvctl status nodeapps
sys 登录数据库
[oracle@rac1 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Sun Aug 2 03:53:02 2020
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected.
SQL>
9.2 rac1创建数据库默认表空间 user_data
create tablespace user_data datafile '+data/orcl/datafile/my_data01.dbf' size 100m
autoextend on next 50m maxsize unlimited segment space management auto;
alter database default tablespace user_data;
9.3 rac1创建数据库临时表空间
create temporary tablespace user_temp tempfile '+data/orcl/datafile/my_temp01.dbf' size 200M REUSE
autoextend on next 50M MAXSIZE Unlimited
extent management local uniform size 256K;
9.4 rac1创建undo表空间 undotbs2
create undo tablespace undotbs2 datafile '+data/orcl/datafile/my_undotbs2_01.dbf' size 100m
autoextend on next 10m maxsize unlimited segment space management auto;
9.5 创建用户和授权
create user test identified by "1q2w3e" default tablespace user_data temporary tablespace user_temp;
grant connect,resource,dba to test;
如果不想授予dba权限、仅授予常规权限,可以根据自己实际情况授相应的权限:
grant connect,resource,select any table, create session, create table, create view, unlimited tablespace to test;
create user jack identified by "1q2w3e" default tablespace user_data temporary tablespace user_temp;
grant connect,resource,dba to jack;
如果不想授予dba权限、仅授予常规权限,可以根据自己实际情况授相应的权限:
grant connect,resource,select any table, create session, create table, create view, unlimited tablespace to jack;
查询表空间的文件路径
select * from dba_data_files;
查看当前用户的缺省表空间
select username,default_tablespace from user_users;
9.6 远程连接数据库测试
通过Public IP连接
jdbc:oracle:thin:@//192.168.235.60:1521:orcl #ServiceName
jdbc:oracle:thin:@192.168.235.60:1521:orcl1 #rac1 SID
jdbc:oracle:thin:@//192.168.235.61:1521:orcl #ServiceName
jdbc:oracle:thin:@192.168.235.61:1521:orcl2 #rac2 SID
通过VIP连接:
jdbc:oracle:thin:@//192.168.235.62:1521:orcl #ServiceName
jdbc:oracle:thin:@192.168.235.62:1521:orcl1 #rac2 SID
jdbc:oracle:thin:@//192.168.235.63:1521:orcl #ServiceName
jdbc:oracle:thin:@192.168.235.63:1521:orcl2 #rac2 SID
通过SCAN连接
jdbc:oracle:thin:@//racscan:1521:orcl
jdbc:oracle:thin:@//192.168.235.64:1521:orcl
如果要通过SCAN连接注意:如果没有配置DNS,需要客户端hosts文件中添加,才能连接:
# connect RAC by SCAN
192.168.235.64 racscan
192.168.235.62 rac1vip
192.168.235.63 rac2vip
至此手动建库结束!
------ 到此全部安装完毕(grid -> Oracle Database -> DB) ------
==============================================================================
附:
Oracle RAC 常用命令
待后续补充
Oracle RAC的启动和关闭
默认安装后,Oracle RAC会自动启动。如果要手动关闭和启动操作,相关顺序和命令参考如下
启动顺序:节点集群服务->ASM实例->数据库(实例)->监听服务
关闭顺序:监听服务->数据库(实例)->ASM实例->节点集群服务
Oracle RAC 启动&关闭:
注意:
1.Oracle 11g开始,如果在ASM磁盘组中存储OCR和VOTEDISK,那么不能单独启动或关闭Oracle RAC数据库系统中的 asm 实例,必须使用 crsctl 命令来启动或停止crs(会自动同步启动/停止ASM实例和nodeapps),因此 and 和 nodeapps 不需要单独启动/关闭了。
2.crsctl stop crs -all 必须以root执行。
3.crsctl stop cluster 加了 -all 参数,则只需要在1个节点执行
4.crsctl strat/stop cluster 和 crsctl strat/stop crs 的区别:
crsctl strat/stop cluster 既可以管理本地clusterware stack( -n rac1),也可以管理整个集群( -all )
crsctl start/stop crs 仅管理本地节点的clusterware stack的启停,包含启动ohasd进程
关闭Oracle RAC:
crsctl status server
crsctl status resource -t
su - grid
srvctl stop listener #listener, srvctl status listener. 也可执行 srvctl stop listener -n rac1,rac2
srvctl stop database -d orcl #database, 查询数据库实例可以通过:select instance_name from v$instance; srvctl status database -d orcl
#也可以执行 srvctl stop instance -d orcl -i rac1,rac2
su - root
crsctl stop cluster -all #停止crs集群软件,必须root执行。停止集群软件时还会同步停止 asm & nodeapps(crs 集群服务)。也可执行 crs_stop -all
crsctl status server
crs_stat -t -v
启动Oracle RAC
su - root
crsctl start cluster -all #启动CRS集群软件,必须root执行。停止集群软件时还会同步停止 asm(ASM服务) & nodeapps(CRS集群服务)。也可执行 crs_start -all
crsctl status server #或执行 crs_stat -t -v
su - grid
srvctl start database -d orcl #database, 查询数据库实例可以通过:select instance_name from v$instance; srvctl status database -d orcl
#也可以执行: srvctl start instance -d orcl -i rac1,rac2
srvctl start listener #listener, srvctl status listener
crsctl status resource -t
如果启动Oracle RAC报错:
[root@rac1 ~]# crsctl start cluster -all
CRS-4639: Could not contact Oracle High Availability Services
CRS-4000: Command Start failed, or completed with errors.
原因:crs没有启动,Oracle的bug。
解决办法:启动之前需要执行:
/bin/dd if=/var/tmp/.oracle/npohasd of=/dev/null bs=1024 count=1
然后再执行启动命令
需要查看相关日志,可以到grid目录下$ORACLE_HOME找
其他常用命令
查看Oracle实例(数据库)状态
$ srvctl status database -d orcl
Instance orcl1 is running on node rac1
Instance orcl2 is running on node rac2
#查看Oracle单个实例(instance)状态
$ srvctl status instance -d orcl -i orcl1
Instance orcl1 is running on node rac1
显示配置的所有数据库
$ srvctl config database
orcl
查看数据库配置
$ srvctl config database -d orcl -a
Database unique name: orcl
Database name: orcl
Oracle home: /u01/app/oracle/product/11.2.0
Oracle user: oracle
Spfile: +DATA/orcl/spfileorcl.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: orcl
Database instances: orcl1,orcl2
Disk Groups: DATA
Services:
Database is enabled
Database is administrator managed
查看scan状态
$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac1
查看节点应用程序状态
srvctl status nodeapps
更多推荐
所有评论(0)