两个机器的系统初始化(略)参考
https://blog.csdn.net/sudahai102448567/article/details/119611507
一、安装Grid
1.安装软件包
yum install -y binutils* compat-libcap1 compat-libstdc* gcc* gcc-c++* glibc* ksh* libgcc* libstdc++* libaio* make* sysstat* elfutils-libelf-devel* xterm smartmontools xorg-x11-xauth net-tools psmisc
这三个包yum
源没有,单独安装
rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm --nodeps --force
rpm -ivh rlwrap-0.42-1.el6.x86_64.rpm --nodeps --force
2.创建用户、组、目录
groupadd -g 1005 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
3.配置grid
、oracle
密码
echo "grid" | passwd --stdin grid
echo "oracle" | passwd --stdin oracle
mkdir -p /u01/app/grid
mkdir -p /u01/app/11.2.0.4/grid
mkdir -p /u01/app/oracle/product/11.2.0.4/db_1
chown -R oracle:oinstall /u01
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/11.2.0.4
chmod -R 775 /u01/
5.配置共享磁盘(略)参考
https://blog.csdn.net/sudahai102448567/article/details/108123811
6.配置系统参数
/etc/hosts
192.168.168.71 rdrac1
192.168.168.72 rdrac2
#PRIVATE IP
192.168.168.73 rdrac1-vip
192.168.168.74 rdrac2-vip
#VIRTUAL IP
4.4.4.1 rdrac1-priv
4.4.4.2 rdrac2-priv
#SCAN IP
192.168.168.75 rdrac-scan
192.168.168.76 rdrac-scan
7.配置系统文件
vi /etc/security/limits.conf
#添加
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
为使上述参数生效在/etc/pam.d/login
添加
session required pam_limits.so
8.设置内核参数(数值大小仅供参考)
/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 #物理内存/4k,See Note: 301830.1 for more information.
kernel.shmmax = 50251117363 #物理内存*0.6 (or higher at customer's discretion - see Note:567506.1)
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.aio-max-nr=3145728 #(as per Note 579108.1)
9.配置生效,在全部节点操作
sysctl -p
/etc/profile
添加
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -u 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
10.关于ntp
服务看实际情况是禁用还是启用,我这里两个节点都禁用
systemctl stop ntpd
systemctl disable ntpd
mv /etc/ntp.conf /etc/ntp.conf_bak
11.配置所有用户的互信
cd /usr/local/src/grid/sshsetup
root
./sshUserSetup.sh -user root -hosts "rdrac1 rdrac2" -advanced -noPromptPassphrase
su - oracle
./sshUserSetup.sh -user oracle -hosts "rdrac1 rdrac2" -advanced -noPromptPassphrase
su - grid
./sshUserSetup.sh -user grid -hosts "rdrac1 rdrac2" -advanced -noPromptPassphrase
12.oracle、grid
用户环境变量配置
oracle
用户,2
个节点上配置:
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 LC_ALL="en_US.UTF-8"
export NLS_LANG="AMERICAN_AMERICA.UTF8"
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
alias sqlplus="/usr/bin/rlwrap sqlplus"
alias rman="/usr/bin/rlwrap rman"
alias lsnrctl="/usr/bin/rlwrap lsnrctl"
grid
用户,2
个节点上配置:
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/app/11.2.0.4/grid
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LC_ALL="en_US.UTF-8"
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
alias sqlplus="/usr/bin/rlwrap sqlplus"
alias asmcmd="/usr/bin/rlwrap asmcmd"
alias lsnrctl="/usr/bin/rlwrap lsnrctl"
配置共享磁盘
节点一填写文件然后传给节点二,两个节点重启生效
[root@rdrac2 ~]# vim /usr/lib/udev/rules.d/60-raw.rules
ACTION=="add", KERNEL=="sdb", RUN+="/usr/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc", RUN+="/usr/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd", RUN+="/usr/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="raw1", OWNER="grid", GROUP="asmadmin", MODE="0660"
ACTION=="add", KERNEL=="raw2", OWNER="grid", GROUP="asmadmin", MODE="0660"
ACTION=="add", KERNEL=="raw3", OWNER="grid", GROUP="asmadmin", MODE="0660"
13.安装grid 11.2.0.4
将三个压缩包上传到节点一上并解压,注意权限
[root@rdrac1 /usr/local/src]# pwd
/usr/local/src
[root@rdrac1 /usr/local/src]# ls -lrth
total 3.5G
drwxr-xr-x 7 grid oinstall 156 Aug 27 2013 grid
drwxr-xr-x 7 oracle oinstall 136 Aug 27 2013 database
-rw-r--r-- 1 root root 1.1G Aug 12 09:29 p13390677_112040_Linux-x86-64_2of7.zip
-rw-r--r-- 1 root root 1.3G Aug 12 09:29 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r-- 1 root root 1.2G Aug 12 09:30 p13390677_112040_Linux-x86-64_3of7.zip
[root@rdrac1 /usr/local/src]#
在Linux 7
上安装11.2.0.4
会有个BUG
:
“Patch 19404309: BLR BACKPORT OF BUG 18658211 ON TOP OF 11.2.0.4.0 (BLR #3975140)
”
需要下载补丁p19404309
并上传p19404309_112040_Linux-x86-64.zip
,后解压
[root@rdrac1 /usr/local/src]# ll
total 24
drwxr-xr-x 6 root root 92 Aug 14 2014 b19404309
-rw-r--r-- 1 root root 19848 Jan 20 2021 p19404309_112040_Linux-x86-64.zip
-rw-rw-r-- 1 root root 2132 Aug 28 2014 PatchSearch.xml
[root@rdrac1 /usr/local/src]# cp b19404309/grid/cvu_prereq.xml grid/stage/cvu/
cp: overwrite ‘grid/stage/cvu/cvu_prereq.xml’? y
[root@rdrac1 /usr/local/src/grid/stage/cvu]# chown -R grid:oinstall /usr/local/src/grid/
安装rpm
包
在节点1
grid
安装目录下的rpm
目录下有cvuqdisk-1.0.9-1.rpm
的安装包。
[root@rdrac1 /usr/local/src/grid/rpm]# ls
cvuqdisk-1.0.9-1.rpm
[root@rdrac1 /usr/local/src/grid/rpm]# rpm -ivh cvuqdisk-1.0.9-1.rpm
Preparing... ################################# [100%]
Using default group oinstall to install package
Updating / installing...
1:cvuqdisk-1.0.9-1 ################################# [100%]
[root@rdrac1 /usr/local/src/grid/rpm]# scp cvuqdisk-1.0.9-1.rpm
rdrac2:/root
--然后节点2安装(略)
检查安装条件是否满足
节点1
运行以下脚本进行检查,输出很多不粘贴了。有问题的地方就修改,一般NTP
和DNS
的错误可以忽略
[grid@rdrac1 /usr/local/src/grid]$ ./runcluvfy.sh stage -pre crsinst -n rdrac1,rdrac2 -fixup -verbose
图形化安装GRID
由于图片很占篇幅这里只贴出需要注意的地方,安装GRID
完整的截图参考:
https://blog.csdn.net/sudahai102448567/article/details/104833628
因为Linux 7
开始服务都是由systemd
进行管理了,所以ohas
没有办法顺利启动,两个节点在执行root.sh
之前分别打补丁p18370031
:
上传补丁该权限然后解压
[root@rdrac1 ~]# chown -R grid:oinstall /usr/local/src/p18370031_112040_Linux-x86-64.zip
[root@rdrac1 ~]# scp /usr/local/src/p18370031_112040_Linux-x86-64.zip rdrac2:/usr/local/src/
[root@rdrac2 ~]# chown grid:oinstall /usr/local/src/p18370031_112040_Linux-x86-64.zip
[root@rdrac1 /usr/local/src]# unzip p18370031_112040_Linux-x86-64.zip
[root@rdrac1 /usr/local/src]# chown -R grid:oinstall 18370031/
[grid@rdrac1 ~]$ /u01/app/11.2.0.4/grid/OPatch/opatch napply -oh /u01/app/11.2.0.4/grid/ -local /usr/local/src/18370031/
Oracle Interim Patch Installer version 11.2.0.3.4
Copyright (c) 2012, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/11.2.0.4/grid
Central Inventory : /u01/app/oraInventory
from : /u01/app/11.2.0.4/grid//oraInst.loc
OPatch version : 11.2.0.3.4
OUI version : 11.2.0.4.0
Log file location : /u01/app/11.2.0.4/grid/cfgtoollogs/opatch/opatch2021-08-12_11-35-57AM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 18370031
Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/11.2.0.4/grid')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '18370031' to OH '/u01/app/11.2.0.4/grid'
Patching component oracle.crs, 11.2.0.4.0...
Verifying the update...
Patch 18370031 successfully applied.
Log file location: /u01/app/11.2.0.4/grid/cfgtoollogs/opatch/opatch2021-08-12_11-35-57AM_1.log
OPatch succeeded.
查看应用补丁情况
[grid@rdrac1 ~]$ /u01/app/11.2.0.4/grid/OPatch/opatch lsinventory
节点二重复上面步骤,略
补丁成功后,用root
用户运行脚本:
两个节点先执行脚本一,然后两个节点执行脚本二:
1./u01/app/oraInventory/orainstRoot.sh
2./u01/app/11.2.0.4/grid/root.sh
最后会有两个错误查看日志如果是关于scanip
解析的问题ping
一下scanip
能通就可以忽略
二、ASMCA创建磁盘组
图形化操作,共享磁盘没有问题就没啥问题,略
升级grid
到最新PSU
(打补丁之前确认磁盘空间足够)
现在是20210812
,能够有权限下载到的最新的PSU
如下:
GRID INFRASTRUCTURE PATCH SET UPDATE 11.2.0.4.201020 (Patch)
p31718723_112040_Linux-x86-64
DATABASE PATCH SET UPDATE 11.2.0.4.201020 (Patch)
p31537677_112040_Linux-x86-64
两个节点的grid
用户都更新Opatch
[grid@rdrac1 ~]$ pwd
/home/grid
[grid@rdrac1 ~]$ ll
-rw-r--r-- 1 grid oinstall 123959496 Aug 12 16:41 p6880880_112000_Linux-x86-64.zip
[grid@rdrac1 ~]$ mv /u01/app/11.2.0.4/grid/OPatch /u01/app/11.2.0.4/grid/OPatch_bak
[grid@rdrac1 ~]$ unzip p6880880_112000_Linux-x86-64.zip -d /u01/app/11.2.0.4/grid/
[grid@rdrac1 ~]$ $ORACLE_HOME/OPatch/opatch version
OPatch Version: 11.2.0.3.29
OPatch succeeded.
节点二操作相同,略
上传PSU
并解压,注意权限
[grid@rdrac1 ~]$ ll
total 1288492
drwxr-xr-x 5 grid oinstall 147 Sep 24 2020 31718723
-rw-r--r-- 1 grid oinstall 1319414278 Aug 12 15:39 p31718723_112040_Linux-x86-64.zip
创建OCM
响应文件
从opatch 12.2.0.1.5
及11.2.0.1.1
4开始,我们的opatch
工具目录下,再没有 ocm/bin/emocmrsp
文件,原因是这个已经被毁弃。
但一些打补丁的note
中,还未更新,还在使用这种语法:
# opatch auto apply /31718723-ocmrf
遇到 这种,我们不用管 ocmrf
部分即可,即修改为以下 :
# opatch auto apply /31718723
检查 Inventory
有效性,输出很多,不贴出
[grid@rdrac1 ~]$ $ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME
root
执行输出很多,不贴出,注意看日志
[root@rdrac1 ~]# /u01/app/11.2.0.4/grid/OPatch/opatch auto /home/grid/31718723/ -oh /u01/app/11.2.0.4/grid/
检查打补丁情况
[grid@rdrac1 ~]$ $ORACLE_HOME/OPatch/opatch lspatches
29509309;ACFS Patch Set Update : 11.2.0.4.190716 (29509309)
31537677;Database Patch Set Update : 11.2.0.4.201020 (31537677)
29938455;OCW Patch Set Update : 11.2.0.4.191015 (29938455)
OPatch succeeded.
节点二操作相同,略
三、安装数据库软件
安装前建议打上补丁p19404309
[root@rdrac1 /usr/local/src]# cp b19404309/database/cvu_prereq.xml database/stage/cvu/
cp: overwrite ‘database/stage/cvu/cvu_prereq.xml’? y
oracle
用户runInstaller
图形化安装,同样只是贴出需要注意的地方
下面这个是EM
的BUG
,先选Continue
跳过。后面打补丁
上面安装完成之后安装OEM
补丁patch 19692824(for oem)
上传并解压
[oracle@rdrac1 ~]$ pwd
/home/oracle
[oracle@rdrac1 ~]$ ll
total 44
drwxr-xr-x 5 oracle oinstall 81 Dec 1 2014 19692824
-rw-r--r-- 1 oracle oinstall 44600 Aug 13 10:15 p19692824_112040_Linux-x86-64.zip
[oracle@rdrac1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/OPatch/opatch apply /home/oracle/19692824/ -oh /u01/app/oracle/product/11.2.0.4/db_1/
节点二同样的操作,略,或者使用下面的方式,一起把两个节点补丁都打了
区别就是命令中没有指定-oh
[oracle@rdrac1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/OPatch/opatch apply /home/oracle/19692824/
升级oracle
到最新的PSU
升级OPatch
备份
[oracle@rdrac1 ~]$ mv /u01/app/oracle/product/11.2.0.4/db_1/OPatch/ /u01/app/oracle/product/11.2.0.4/db_1/OPatch_bak
上传并解压
[oracle@rdrac1 ~]$ pwd
/home/oracle
[oracle@rdrac1 ~]$ ll
-rw-r--r-- 1 oracle oinstall 123959496 Aug 12 16:41 p6880880_112000_Linux-x86-64.zip
[oracle@rdrac1 ~]$ unzip p6880880_112000_Linux-x86-64.zip
[oracle@rdrac1 ~]$ mv OPatch/ /u01/app/oracle/product/11.2.0.4/db_1/
验证
[oracle@rdrac1 ~]$ $ORACLE_HOME/OPatch/opatch version
OPatch Version: 11.2.0.3.29
OPatch succeeded.
节点二操作相同,略
上传并解压PSU
[oracle@rdrac1 ~]$ pwd
/home/oracle
[oracle@rdrac1 ~]$ ll
total 382744
drwxr-xr-x 30 oracle oinstall 4096 Sep 24 2020 31537677
-rw-r--r-- 1 oracle oinstall 391781147 Aug 12 15:29 p31537677_112040_Linux-x86-64.zip
升级
[oracle@rdrac1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/OPatch/opatch apply /home/oracle/31537677/ -oh /u01/app/oracle/product/11.2.0.4/db_1/
验证
[oracle@rdrac1 ~]$ $ORACLE_HOME/OPatch/opatch lsinventory
节点二操作相同,略
四、创建数据库
DBCA
图形化创建数据库,略