系统环境:
VMware Workstation14.5 +linux 6.8(65位)+Oracle 11.2.0.4.0 
两个节点rac1(节点1)和rac22(节点2)

hosts:
192.168.174.121  rac1
192.168.174.122  rac2
192.168.160.121 rac1priv
192.168.160.122  rac2priv
192.168.174.123  rac1vip
192.168.174.124  rac2vip
192.168.174.125 racscanip

节点1:
hostname:rac1  ip:192.168.174.121   scanip:192.168.174.125   dbname=racdb   instance_name=racdb1

节点2:
hostname:rac1  ip:192.168.174.122   scanip:192.168.174.125   dbname=racdb   instance_name=racdb2

测试环境RAC安装部署

0.配置网络、调整时区、各类安装前的问题解决
预先准备:配置双网卡,固定ip
网卡1(public ip):vi /etc/sysconfig/network-scripts/ifcfg-eth0     
BOOTPROTO=static
IPADDR=192.168.0.116(填你的ip)                   
NETMASK=255.255.255.0  (填你的掩码值)          
GATEWAY=192.168.0.1    (默认网关)
网卡2(心跳ip):vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=10.0.0.101
NETMASK=255.255.255.0

重启网络:service network restart

修改时间,date-R(展示时间)date -s "2017-11-15 16:56:00"(修改时间)
注:时区也要顺带修改     ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

实际安装需要主要的要求:
1.检查网络,有两个不同的网段。
2.检查linux系统版本。
3.检查安装所需的磁盘
4.调整好时区和时间
5.检查iso镜像是否挂上。

swap空间:

RAM              Swap 空间
1 GB ~ 2 GB      1.5 倍 RAM 大小
2 GB ~ 16 GB     RAM 大小
> 32 GB           16 GB
使用命令查看:# grep SwapTotal /proc/meminfo

通过swap分区文件增加swap空间,swap吃的是磁盘空间,例子:

关闭所有交换分区
命令如下:
swapoff -a

1. 创建swap分区的文件
dd if=/dev/zero of=/home/swapfile bs=1M count=2048
其中bs是每块的大小,count是块的数量;bs*count,就是swap文件的大小:这里1M*1024=1G。可以根据需要自行调整。

此外,swapfile是swap文件的路径,可以根据需求修改。

2. 格式化交换分区文件
mkswap /home/swapfile
这里的路径和之前的路径要对应起来。

3. 启用swap分区文件
swapon /home/swapfile
free -h

4. 添加开机启动
修改/etc/fstab这个文件,添加或者修改这一行:
vi /etc/fstab
/home/swapfile swap swap defaults 0 0
注意,路径还是要对应,而且必须是全路径。最后两个是零,不是大写字母O。
此项不是必须的。如果不修改开机启动配置,重启之后的swap空间会重置,之前配置丢失。

[root@raclhr-11gR2-N1 ~]# grep SwapTotal /proc/meminfo

配置/dev/shm空间:

不配置的话会报错:ORA-00845: MEMORY_TARGET not supported on this system,简单来说就
是 MEMORY_MAX_TARGET 的设置不能超过 /dev/shm 的大小。
解决:
vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=2G 0 0
重新挂载:
mount -o remount /dev/shm

中文环境切换成英文环境

编辑 i18n:
vi /etc/sysconfig/i18n
把 zh_CN 换成 en_US 即可。
然后重启 shell 环境或 OS 系统。
[root@RHEL6LHR ~]# echo $LANG
[root@RHEL6LHR ~]# more /etc/sysconfig/i18n
#LANG="zh_CN.UTF-8"
LANG="en_US.UTF-8"

安装 rlwrap

rlwrap-0.37.tar.gz
yum install -y gcc
yum install -y libtermcap-devel
yum install -y readline
yum install -y readline-devel

安装:
tar -zxvf rlwrap-0.37.tar.gz
cd rlwrap-0.37
./configure; make install
ldconfig

配置:
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias asmcmd='rlwrap asmcmd'

1、安装软件包

mount  /dev/cdrom /mnt

(1)配置yum源
mount  /dev/sr0 /mnt

cd /etc/yum.repos.d/
rm -rf *

vi /etc/yum.repos.d/ol.repo   --rehat6以上
[local-source]
name=ol
baseurl=file:///mnt/
ebabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

vi /etc/yum.repos.d/ol.repo  --rehat5
[local-source]
name=ol
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0

设置开机自动挂载:
vi /etc/fstab
/dev/sr0 /mnt iso9660 defaults 0 0
(2)安装rpm依赖包
yum install binutils compat-libstdc++-33 compat-libstdc++-296 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make openmotif sysstat unixODBC unixODBC-devel compat-libcap1 ksh -y
yum install -y xterm

2、创建用户、组、目录

groupadd -g 1000 oinstall
groupadd -g 1001 dba
groupadd -g 1002 asmadmin
groupadd -g 1003 asmdba
groupadd -g 1004 asmoper
useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
useradd -u 1101 -g oinstall -G dba,asmdba,asmadmin,asmoper oracle

passwd grid
passwd oracle

mkdir -p  /u01/app/11.2.0.4/grid
mkdir -p  /u01/app/grid
mkdir -p  /u01/grid/11.2.0.4/
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01
chown -R grid:oinstall /u01/grid
chmod -R 775 /u01/

作用     路径
grid软件  /u01/grid
grid_base   /u01/app/grid
oracle_base /u01/app/oracle

3、配置共享磁盘(多路径+udev)

虚拟机建立共享磁盘:
切换到vmware安装目录   cd D:\VMware\vmware
cmd  命令
.\vmware-vdiskmanager.exe -c -s 2G -a lsilogic -t 2 "D:\VMware\vmware\sharedisks\OCR.vmdk"
.\vmware-vdiskmanager.exe -c -s 30G -a lsilogic -t 2 "D:\VMware\vmware\sharedisks\DATA.vmdk"
.\vmware-vdiskmanager.exe -c -s 10G -a lsilogic -t 2 "D:\VMware\vmware\sharedisks\FRD.vmdk"
分别打开两台虚拟机目录中的vmx文件,在最后一行添加:
scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"
scsi1.sharedBus = "virtual"

scsi1:1.present = "TRUE"
scsi1:1.mode = "independent-persistent"
scsi1:1.filename = "D:\VMware\vmware\sharedisks\11g\OCR.vmdk"
scsi1:1.deviceType = "Disk"

scsi1:2.present = "TRUE"
scsi1:2.mode = "independent-persistent"
scsi1:2.filename = "D:\VMware\vmware\sharedisks\11g\DATA.vmdk"
scsi1:2.deviceType = "Disk"

scsi1:3.present = "TRUE"
scsi1:3.mode = "independent-persistent"
scsi1:3.filename = "D:\VMware\vmware\sharedisks\11g\FRD.vmdk"
scsi1:3.deviceType = "Disk" 

disk.locking = "false"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"

multipath +udev 配置共享存储:
1.双节点安装multipath的包,先后顺序不能乱:
rpm -ivh device-mapper-multipath-libs-0.4.9-93.el6.x86_64.rpm
rpm -ivh device-mapper-multipath-0.4.9-93.el6.x86_64.rpm
2.启动multipath(rac1、rac2都跑)
modprobe dm-multipath
modprobe dm-round-robin
检查内核添加情况:
lsmod |grep multipath
将多路径软件multipath设置未开机自启动
chkconfig --level 2345 multipathd on // chkconfig multipathd on
chkconfig --list|grep multipathd
multipathd   0:关闭 1:关闭 2:启用 3:启用 4:启用  5:启用  6:关闭
启动multipath服务:
service multipathd restart
3.多路径配置(rac、rac2)
oracle RAC所需多路径配置要点是一个RAC节点一个RAC节点一次执行如下操作(如果需要再添加使用多路径的存储,也需遵循如下步骤):
service multipathd stop
multipath -F

所得所有存储的lun的wwid:
for i in `cat /proc/partitions | awk {'print $4'} |grep sd`; do val=`/sbin/blockdev --getsize64 /dev/$i` ; val2=`expr $val / 1073741824`; echo "/dev/$i: $val2 `scsi_id -gud /dev/$i`" ; done
sdb:36000c29bdd94929a47b6a38ea9b12d60
sdc:36000c29775143b36ade2a2621dd9e80a
sdd:36000c290131d7518b48f7eab0f927e5d
先查看是否存在/etc/multipath.conf,不存在
方法1:创建配置文件:cp /etc/multipath_bak.conf   /etc/multipath.conf
vi /etc/multipath.conf

defaults {
user_friendly_names yes
}

devices {
device {  
vendor "(COMPAQ|HP)"
product "HSV1[01]1|HSV2[01]0|HSV300|HSV4[05]0"
#getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
features "0"
hardware_handler "0"
path_selector "round-robin 0"
path_grouping_policy group_by_prio
failback immediate
rr_weight uniform
no_path_retry 12
rr_min_io 1000
path_checker tur
prio alua
}
}

multipaths {

        multipath {                                                                              
                wwid                    36000c29bdd94929a47b6a38ea9b12d60
                alias                   OCR
                path_grouping_policy    multibus
                path_selector           "round-robin 0"
                failback                immediate
                rr_weight               priorities
                no_path_retry           queue
    }
}
multipaths {

        multipath {                                                                              
                wwid                    36000c29775143b36ade2a2621dd9e80a
                alias                   DATA
                path_grouping_policy    multibus
                path_selector           "round-robin 0"
                failback                immediate
                rr_weight               priorities
                no_path_retry           queue
    }
}
multipaths {

        multipath {                                                                              
                wwid                    36000c290131d7518b48f7eab0f927e5d
                alias                   FRA
                path_grouping_policy    multibus
                path_selector           "round-robin 0"
                failback                immediate
                rr_weight               priorities
                no_path_retry           queue
    }
}

blacklist {
        devnode "^(sda|ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
        devnode "^hd[a-z]"
        devnode "^asm/*"         # Here
        devnode "ofsctl"             # Here
}

#启动多路径:
service multipathd restart

启动multipath配置后,会在/dev/mapper下生成多路径逻辑盘
cd /dev/mapper
ll
#查看多路径的状态:multipath -ll

4.配置udev,更改属组。
vi /etc/udev/rules.d/99-oracle-asmdevices.rules
ENV{DM_NAME}=="OCR", OWNER:="grid", GROUP:="asmadmin", MODE:="0660", SYMLINK+="iscsi/oraasm-$env{DM_NAME}"
ENV{DM_NAME}=="DATA", OWNER:="grid", GROUP:="asmadmin", MODE:="0660", SYMLINK+="iscsi/oraasm-$env{DM_NAME}"
ENV{DM_NAME}=="FRA", OWNER:="grid", GROUP:="asmadmin", MODE:="0660", SYMLINK+="iscsi/oraasm-$env{DM_NAME}"

重启udev
[root@sanan1 rules.d]# start_udev
正在启动 udev:                                            [确定]
[root@whepi2 ~]# ls /dev/iscsi/
oraasm-arch1   oraasm-mes1.2  oraasm-mes1.4  oraasm-mes2.2  oraasm-ocr2
oraasm-mes1.1  oraasm-mes1.3  oraasm-mes2.1  oraasm-ocr1    oraasm-ocr3
---验证权限
 ls -l /dev/dm-*
---验证命名结果
ls -l /dev/mapper/*

4、配置系统参数

4.1修改主机名

vi /etc/hosts
192.168.174.121  rac1
192.168.174.122  rac2
192.168.160.121 rac1priv
192.168.160.122  rac2priv
192.168.174.123  rac1vip
192.168.174.124  rac2vip
192.168.174.125 racscanip
vi /etc/sysconfig/network   
 rac1   rac2
hostname  rac1
hostname  rac2

4.2、配置系统文件

--/etc/security/limits.conf 是 Linux 资源使用配置文件,用来限制用户对系统资源的使用 
--https://www.cnblogs.com/pzk7788/p/7250723.html

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

vi /etc/pam.d/login添加:
session required pam_limits.so

设置内核参数,编辑文件并使之生效,其值不小于如下设置。
以下是参考内容
/etc/sysctl.conf:
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744   512 x processes (for example 6815744 for 13312 processes_)
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 = 1048576
kernel.shmall = 20447232 # physical RAM size / pagesize For most systems,物理内存/4k
kernel.shmmax = 50251117363 # 1/2 of physical RAM. This would be the value 2147483648 for a system with 4GB of physical RAM 即内存的60%
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.aio-max-nr=3145728 (as per Note 579108.1)

以下是生产正式环境中用的
mv /etc/sysctl.conf /etc/sysctl.conf.bak
vi /etc/sysctl.conf
节点1:
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
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 = 1048576
kernel.shmall = 33030144
kernel.shmmax = 81174881894
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.aio-max-nr=3145728

节点2:

kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
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 = 1048576
kernel.shmall = 20447232
kernel.shmmax = 50251117363
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.aio-max-nr=3145728

配置生效,在全部节点操作
sysctl -p

vi /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

4.3、禁用SELinux、iptable

建议禁用此功能。
vi /etc/selinux/config
SELINUX=disabled
需要重启。

service iptables stop
chkconfig iptables off

4.4、停止ntp服务和删除配置文件及pid文件(看情况配置)

service ntpd stop
chkconfig ntpd off
rm -rf /etc/ntpd.conf 
rm -rf /var/run/ntpd.pid

4.5、 oracle、grid用户环境变量配置

oracle用户,2个节点上配置:
vi ~/.bash_profile  编辑后source ~/.bash_profile
export TMP=/tmp 
export TMPDIR=$TMP 
export ORACLE_SID=rac1   #节点1的配置
#export ORACLE_SID=rac2  #节点2的配置
export ORACLE_BASE=/u01/app/oracle 
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/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
export NLS_LANG=AMERICAN_AMERICA.UTF8

grid用户,2个节点上配置:
vi ~/.bash_profile  编辑后source ~/.bash_profile
export TMP=/tmp 
export TMPDIR=$TMP 
export ORACLE_SID=+ASM1   #节点1的配置
#export ORACLE_SID=+ASM2  #节点2的配置
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/grid/11.2.0.4/
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
export NLS_LANG=AMERICAN_AMERICA.UTF8

4.6、上传软件包,建立互信。

解压安装包
[root@whepi1 ~]$ cd /soft
[root@whepi1 soft]$ unzip p13390677_112040_Linux-x86-64_3of7.zip

建立互信
rac1   root用户下执行
解压grid   cd grid    
cd sshUserc'dSetup
 ./sshUserSetup.sh -user grid -hosts "rac1 rac2 " -advanced -noPromptPassphrase
 ./sshUserSetup.sh -user oracle -hosts "rac1 rac2 " -advanced -noPromptPassphrase

Related Posts