Cenots7.6 安装Oracle Rac 11.2.0.4

一、环境准备

系统:centos 7.6

软件:oracle 11.2.0.4 

database: p13390677_112040_Linux-x86-64_1of7.zip   p13390677_112040_Linux-x86-64_2of7.zip

grid集群: p13390677_112040_Linux-x86-64_3of7.zip

共享磁盘:系统组已配置好 iscsi。

二、前期准备

2.1 ip规划

每个节点网卡需要2个,11.2开始至少需要4种IP地址,规划如下:

rac01:134.80.101.2      公共ip

rac01-vip:134.80.101.4  虚拟ip

rac01-pip:192.100.100.2  私有ip

rac02:134.80.101.3

rac02-vip:134.80.101.5

rac02-pip:192.100.100.3

scan-cluster:134.80.101.6  集群入口

说明:3个公共ip,2个虚拟ip 需要在同一个子网!

Oracle RAC环境下每个节点都会有多个IP地址,分别为公共IP(Public IP) 、私有IP(Private IP)和虚拟IP(Virtual IP):

  私有IP(Public IP)

Private IP address is used only for internal clustering processing(Cache Fusion).

专用(私有)IP地址只用于内部群集处理,如心跳侦测,服务器间的同步数据用。

  虚拟IP(Virtual IP)

Virtual IP is used by database applications to enable fail over when one cluster node fails.

当一个群集节点出现故障时,数据库应用程序通过虚拟IP地址进行故障切换。

当一个群集节点出现故障时,数据库应用程序(包括数据库客户端)通过虚拟IP地址切换到另一个无故障节点,另一个功能是均衡负载。

  公共IP(Public IP)

Public IP adress is the normal IP address typically used by DBA and SA to manage storage, system and database.

  公共IP地址

正常的(真实的)IP地址,通常DBA和SA使用公共IP地址在来管理存储、系统和数据库。

  监听IP(SCAN IP)

从Oracle 11g R2开始,Oracle RAC网络对IP地址有特殊要求,新增了加监听IP地址(SCAN IP),所以从Oracle 11g R2开始Oracle RAC网络至少需要4种IP地址(前面介绍三种IP地址)。在Oracle 11g R2之前,如果数据库采用了RAC架构,在客户端的tnsnames中,需要配置多个节点的连接信息,从而实现诸如负载均衡、Failover等RAC的特性。因此,当数据库RAC集群需要添加或删除节点时,需要及时对客户端机器的tns进行更新,以免出现安全隐患。

在Oracle 11g R2中,为了简化该项配置工作,引入了SCAN(Single Client Access Name)的特性。该特性的好处在于,在数据库与客户端之间,添加了一层虚拟的服务层,就是所谓的SCAN IP以及SCAN IP Listener,在客户端仅需要配置SCAN IP的tns信息,通过SCAN IP Listener,连接后台集群数据库。这样,不论集群数据库是否有添加或者删除节点的操作,均不会对Client产生影响。

2.2 编辑/etc/hosts文件

rac01,rac02 同时配置 vim /etc/hosts  如下:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
#rac01
134.80.101.2   rac01
134.80.101.4   rac01-vip
192.100.100.2  rac01-pip
#rac02
134.80.101.3   rac02
134.80.101.5   rac02-vip
192.100.100.3  rac02-pip
#scan cluster
134.81.101.6 scan-cluster

2.3创建用户和组

rac01,rac02两节点 root 下执行操作:创建组、用户,并设置用户密码

groupadd -g 1000 oinstall

groupadd -g 1200 dba

groupadd -g 1201 oper

groupadd -g 1300 asmadmin

groupadd -g 1301 asmdba

groupadd -g 1302 asmoper

useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid

useradd -u 1101 -g oinstall -G dba,oper,asmdba oracle

passwd grid

passwd oracle

2.4 创建目录并授权

在rac01、rac02上进行目录的创建和授权:

root 下执行以下操作:

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/

2.5 配置用户环境变量

2.5.1配置grid用户

rac01:

[ ~]$ vim .bash_profile

export TMP=/tmp

export TMPDIR=$TMP

export ORACLE_SID=+ASM1

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

[ ~]$ source .bash_profile

rac02

[ ~]$ vim .bash_profile

export TMP=/tmp

export TMPDIR=$TMP

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

[ ~]$ source .bash_profile

2.5.2 配置oracle用户

rac01:

[ ~]$ vim .bash_profile

export TMP=/tmp

export TMPDIR=$TMP

export ORACLE_SID=orcl1

export ORACLE_UNQNAME=orcl

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

[ ~]$ source .bash_profile

rac02:

[ ~]$ vim .bash_profile

export TMP=/tmp

export TMPDIR=$TMP

export ORACLE_SID=orcl2

export ORACLE_UNQNAME=orcl

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

[ ~]$ source .bash_profile

2.6 配置grid,oracle用户ssh互信

rac01:

ssh-keygen -t rsa #一路回车

ssh-keygen -t dsa #一路回车

rac02:

ssh-keygen -t rsa #一路回车

ssh-keygen -t dsa #一路回车

先rac01、再rac02上执行过上述两条命令后,再回到rac01再继续执行下面的命令:

cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys

cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys

ssh rac02 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys

ssh rac02 cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys

scp ~/.ssh/authorized_keys rac02:~/.ssh/authorized_keys

chmod 600 .ssh/authorized_keys

两个节点互相ssh通过一次

ssh rac01 date

ssh rac02 date

ssh rac01-pip date

ssh rac02-pip date

2.7 配置系统参数

2.7.1 关闭selinux&iptables
在rac01和rac02上都要执行

[ ~]# cat /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

[ ~]#  sysctemctl stop firewalld
2.7.2修改 sysctl.conf
在rac01和rac02上都要执行

[ ~]# vim /etc/sysctl.conf ,在最后添加以下内容:

kernel.msgmnb = 65536

kernel.msgmax = 65536

kernel.shmmax = 68719476736    RAM times 0.5 

kernel.shmall = 4294967296    physical RAM size / pagesize(getconf PAGESIZE)

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

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

 [ rac01~]# sysctl -p 立即生效

2.7.3  修改 limits.conf

在rac01和rac02上都要执行

[ ~]# vim /etc/security/limits.conf ,在最后添加以下内容:

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240

2.7.4 修改 /etc/pam.d/login

在rac01和rac02上都要执行

[ ~]# vim /etc/pam.d/login,在session required pam_namespace.so下面插入:

session required pam_limits.so

2.7.5 修改/etc/profile

在rac01和rac02上都要执行

[ rac01~]# cp /etc/profile /etc/profile.bak

[ rac01~]# vim /etc/profile,在文件最后添加以下内容:

if [ $USER = "ORACLE" ] || [ $USER = "GRID" ];then

if [ $SHELL = "/bin/ksh" ];then

ulimit -p 16384

ulimit -n 65536

else

ulimit -u 16384 -n 65536

fi

umask 022

fi

2.7.6 停止并删除ntp服务

在rac01和rac02上都要执行

[~]# service ntpd status

[~]# chkconfig ntpd off

[~]# cp /etc/ntp.conf /etc/ntp.conf.bak

[ ~]# rm -rf /etc/ntp.conf

2.8 共享磁盘分区

在rac01执行 fdisk /dev/sdb 

根据提示输入 n、 p、 w 等

# 同理,重复步骤对 sdc sdd sde 完成分区。

分区完 rac02 执行

[ ~]# partprobe   分区立即生效

2.9 安装UEK核心

这里采用asmlib方式配置磁盘,需要安装oracleasm rpm包

[ ~]# yum install kmod-oracleasm

[ ~]# rpm -ivh oracleasmlib-2.0.12-1.el6.x86_64.rpm

[ ~]# rpm -ivh oracleasm-support-2.1.8-1.el6.x86_64.rpm

kmod可以直接yum安装,另外两个需要去官网下载

下载地址:https://www.oracle.com/linux/downloads/linux-asmlib-rhel7-downloads.html

2.10  创建ASM Disk Volumes

2.10.1 配置并装载ASM核心模块

rac01 rac02都要操作

[ ~]# oracleasm configure -i ,根据提示输入:

Configuringthe Oracle ASM library driver.

Thiswill configure the on-boot properties of the Oracle ASM library

driver.  The following questions will determinewhether the driver is

loadedon boot and what permissions it will have. The current values

willbe shown in brackets (‘[]‘).  Hitting<ENTER> without typing an

answerwill keep that current value.  Ctrl-Cwill abort.

Defaultuser to own the driver interface []: grid

Defaultgroup to own the driver interface []: asmadmin

StartOracle ASM library driver on boot (y/n) [n]: y

Scanfor Oracle ASM disks on boot (y/n) [y]: y

WritingOracle ASM library driver configuration: done

[ ~]# oracleasm init

    Creating/dev/oracleasm mount point: /dev/oracleasm

Loadingmodule "oracleasm": oracleasm

MountingASMlib driver filesystem: /dev/oracleasm

2.10.2 创建ASM磁盘

rac01上执行

oracleasm createdisk CRSVOL1 /dev/sdc1
oracleasm createdisk FRAVOL1 /dev/sdc2
oracleasm createdisk ARCVOL1 /dev/sdc3
oracleasm createdisk DATAVOL1 /dev/sdd1
oracleasm createdisk DATAVOL2 /dev/sde1
oracleasm createdisk DATAVOL3 /dev/sdf1
oracleasm createdisk DATAVOL4 /dev/sdg1
oracleasm createdisk DATAVOL5 /dev/sdh1

[ ~]# oracleasm listdisks

ARCVOL1

CRSVOL1

DATAVOL1

DATAVOL2

DATAVOL3

DATAVOL4

DATAVOL5

FRAVOL1

使用oracleasm-discover查找ASM磁盘,运行该命令查看是否能找到刚创建的几个磁盘。

[ ~]# oracleasm-discover

UsingASMLib from /opt/oracle/extapi/64/asm/orcl/1/libasm.so

[ASMLibrary - Generic Linux, version 2.0.4 (KABI_V2)]

Discovereddisk: ORCL:CRSVOL1 [2096753 blocks (1073537536 bytes), maxio 512]

Discovereddisk: ORCL:DATAVOL1 [41940960 blocks (21473771520 bytes), maxio 512]

Discovereddisk: ORCL:DATAVOL2 [41940960 blocks (21473771520 bytes), maxio 512]

Discovereddisk: ORCL:FRAVOL1 [62912480 blocks (32211189760 bytes), maxio 512]

rac02上使用oracleasm scandisks 扫描asm磁盘

[ ~]# oracleasm scandisks

Reloading disk partitions: done

Cleaning any stale ASM disks...

Scanning system for ASM disks...

[ ~]# oracleasm listdisks

ARCVOL1

CRSVOL1

DATAVOL1

DATAVOL2

DATAVOL3

DATAVOL4

DATAVOL5

FRAVOL1

三、安装rac 集群软件

相关推荐