Oracel RAC 21C 21.3.0.0 OEL8.6 最佳实践
1 背景知识
本章介绍如何在 Oracle Linux 8.6 上安装 Oracle 21C RAC
集群。
请根据 VMware Vsphere Oracle 虚拟机环境准备两节点RAC 环境。
2 操作系统准备
Note
以下操作都需要在 rac1
节点和 rac2
节点执行。
2.1 DNS 解析设置
cat >> /etc/hosts << EOF
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 localhost
#public ip
192.168.10.221 rac1
192.168.10.222 rac2
#vip
192.168.10.219 rac1-vip
192.168.10.220 rac2-vip
#private ip
192.168.122.41 rac1-priv
192.168.122.42 rac2-priv
#scanip
192.168.10.218 scan-ip
EOF
2.2 执行操作系统优化
#rac1#root>
#rac2#root>
bash optimize_system_conf_oracle.sh
2.3 创建目录
#rac1#root>
#rac2#root>
mkdir -p /u01/app/grid/product/21.3.0/db_1
mkdir -p /u01/app/oracle/product/21.3.0/db_1
mkdir -p /u01/app/grid
chown -R oracle:dba /u01/app/oracle
chown -R grid:dba /u01/app/grid
chmod -R 775 /u01/app/oracle
chmod -R 775 /u01/app/grid
2.4 安装依赖包
Note
Oracle Linux 操作系统。
yum install oracle-database-preinstall-21c -y
yum install unzip gcc elfutils-libelf-devel gcc-c++ chrony -y
Note
其他Linux 操作系统。
#rac1#root>
#rac2#root>
yum install -y binutils elfutils-libelf elfutils-libelf-devel glibc \
glibc-common glibc-devel gcc gcc-c++ libaio libgcc libstdc++ libstdc++-devel \
make sysstat unixODBC-devel libaio-devel lrzsz compat-libstdc libcap.so.1 \
compat-libcap1 compat-libstdc++* lrzsz oracleasm* libXext* unzip \
gcc elfutils-libelf-devel gcc-c++
2.5 打开ol8_addons yum 源
#rac1#root>
#rac2#root>
vi +84 /etc/yum.repos.d/oracle-linux-ol8.repo
[ol8_addons]
name=Oracle Linux 8 Addons ($basearch)
baseurl=https://yum$ociregion.$ocidomain/repo/OracleLinux/OL8/addons/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
2.6 安装oracleasm工具包
#rac1#root>
#rac2#root>
yum install oracleasm* -y
2.7 设置Oracle环境变量
Note
请参考 11G 环境变量。
2.7.1 rac1
su - oracle
cat >> ~/.bash_profile << EOF
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/21.3.0/db_1
export ORACLE_SID=citdb1
export ORACLE_UNQNAME=citdb1
export PATH=\$ORACLE_HOME/bin:\$PATH
export LANG=C
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:
export DISPLAY=192.168.10.130:0.0
export CVUQDISK_GRP=dba
EOF
2.7.2 rac2
su - oracle
cat >> ~/.bash_profile << EOF
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/21.3.0/db_1
export ORACLE_SID=citdb2
export ORACLE_UNQNAME=citdb2
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:
export DISPLAY=192.168.10.130:0.0
export CVUQDISK_GRP=dba
export LANG=C
EOF
2.8 设置GRID 环境变量
2.8.1 rac1
su - grid
cat >> ~/.bash_profile << EOF
export ORACLE_BASE=/u01/app/grid/base
export ORACLE_HOME=/u01/app/grid/product/21.3.0/db_1
export ORACLE_SID=+ASM1
export PATH=\$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:
export DISPLAY=192.168.10.130:0.0
export CVUQDISK_GRP=dba
export LANG=C
EOF
2.8.2 rac2
su - grid
cat >> ~/.bash_profile << EOF
export ORACLE_BASE=/u01/app/grid/base
export ORACLE_HOME=/u01/app/grid/product/21.3.0/db_1
export ORACLE_SID=+ASM2
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:
export DISPLAY=192.168.10.130:0.0
export CVUQDISK_GRP=dba
export LANG=C
EOF
2.9 ROOT 的环境变量
cat >> ~/.bash_profile << EOF
export PATH=/u01/app/grid/product/21.3.0/db_1/bin:\$PATH
export LANG=C
EOF
2.10 准备共享磁盘
2.10.1 oracleasm 初始化
#rac1#root>
#rac2#root>
oracleasm init
oracleasm configure -i
grid
dba
y
y
2.10.2 磁盘分区
#rac1#root>
for i in {b..m};
do fdisk /dev/sd$i << EOF
n
p
w
EOF
done
2.10.3 创建ASM 磁盘
2.10.3.1 创建OCR 磁盘
#rac1#root>
count=1;
for i in {b..d};
do oracleasm createdisk OCR$count /dev/sd$i'1';
let count+=1;
done
2.10.3.2 创建DATA 磁盘
#rac1#root>
count=1;
for i in {e..g};
do oracleasm createdisk DATA$count /dev/sd$i'1';
let count+=1;
done
2.10.3.3 创建快速恢复目录
#rac1#root>
count=1;
for i in {h..j};
do oracleasm createdisk FRA$count /dev/sd$i'1';
let count+=1;
done
2.10.3.4 创建MGAT 目录
#rac1#root>
count=1;
for i in {k..m};
do oracleasm createdisk MGT$count /dev/sd$i'1';
let count+=1;
done
2.10.4 检查磁盘是否创建成功
#rac1#root>
oracleasm listdisks
//屏幕输出:
DATA1
DATA2
DATA3
FRA1
FRA2
FRA3
MGT1
MGT2
MGT3
OCR1
OCR2
OCR3
2.11 磁盘信息同步
#rac2#root>
oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
Instantiating disk "OCR3"
Instantiating disk "MGT1"
Instantiating disk "FRA2"
Instantiating disk "FRA3"
Instantiating disk "OCR2"
Instantiating disk "DATA3"
Instantiating disk "FRA1"
Instantiating disk "DATA2"
Instantiating disk "DATA1"
Instantiating disk "OCR1"
Instantiating disk "MGT3"
Instantiating disk "MGT2"
2.12 调整/dev/shm
- 增大 tmpfs 文件系统大小。
#rac1#root>
#rac2#root>
cat >> /etc/fstab << EOF
tmpfs /dev/shm tmpfs defaults,size=8192M 0 0
EOF
- 重新挂载 tmpfs 文件系统。
#rac1#root>
#rac2#root>
mount -o remount /dev/shm
3 NTP 服务
3.1 rac1 节点作为 NTP 服务端
- 编辑
/etc/chrony.conf
配置文件。
#rac1#root>
vi /etc/chrony.conf
- 修改第
3
行和第23
行。
server 192.168.10.206 prefer
allow 192.168.10.0/24
- 重启NTP服务。
#rac1#root>
systemctl restart chronyd
systemctl status chronyd
systemctl enable chronyd
3.2 rac2 节点作为 NTP 客户端
-
编辑
/etc/chrony.conf
配置文件。 -
修改第
3
行和。
server 192.168.10.216 iburst
- 重启服务
#rac2#root>
systemctl restart chronyd
systemctl enable chronyd
systemctl status chronyd
3.3 验证时间同步
#rac2#root>
chronyc sources
chronyc sourcestats
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? rac1 0 6 0 - +0ns[ +0ns] +/- 0ns
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
rac1 0 0 0 +0.000 2000.000 +0ns 4000ms
Note
只要确定 Offset
为 0ns
即可。说明两台服务器时间一致。
4 准备安装介质
4.1 创建目录
#rac1#root>
cd /app
mkdir setup
mkdir db
mkdir grid
chown -R grid:dba grid/
chown -R oracle:dba db/
4.2 上传解压软件
上传GI+DB软件到 setup
目录,并解压到本地目录。
V1011496-01.zip
V1011504-01.zip
#rac1#root>
chown oracle:dba /app/setup
chmod 775 /app/setup
su - oracle
#rac1#oracle>
cd /app/setup
unzip -q V1011496-01.zip -d $ORACLE_HOME
su - grid
#rac1#grid>
cd /app/setup
unzip -q V1011504-01.zip -d $ORACLE_HOME
Note
到 此为止时,请打快照 DB_INSTALL_ENV 。
5 启动GI安装
su - grid
#grid>
cd $ORACLE_HOME
export DISPLAY=192.168.10.130:0.0
./gridSetup.sh
5.1 GI软件安装参数
参数 | 值 |
---|---|
安装选项 | Install and configure oracele grid for a cluster |
集群配置 | Configure an oracleA_standalone cluster |
cluster name | ASM |
scan name | scan-ip |
csan port | 1521 |
新加节点 | rac2,rac2-vip,密码grid ,并点击 setup . |
不勾选 | reuseprivate and publuic keys . |
是否使用ASM磁盘 | Use Oracle flex asm for storage |
是否使用GIMR | Use a local GIMR database |
是否创建ASM GIMR 磁盘组 | 是 |
ASM 磁盘组 | OCR |
AU size | 4MB |
Redundancy | External |
ASM 磁盘组 | MGMT |
AU size | 4MB |
Redundancy | External |
SYS\ASMSNMP 密码 | grid |
IPMI | DO not use |
EM | 不注册到EMCC |
OSASM | asmdba |
OSDBA | asmdba |
OSOPER | asmdba |
Oracle Base | /u01/app/grid/base |
安装目录 | /u01/app/grid/product/21.3.0/db_1 |
Inventory | /u01/app/grid/oraInventory |
Warning
- 磁盘路径为:>
/dev/oracleasm/disks
- 注意
·Inventory
目录要正确,否则无法打补丁。
6 创建ASM 磁盘组
启动 asmca
创建 ASM
磁盘组
su - grid
#rac1#grid>
export DISPLAY=192.168.10.130:0.0
asmca
选项 | 参数 |
---|---|
磁盘组名称 | DATA(DATA1,DATA2,DATA3) |
磁盘组冗余 | External |
磁盘组名称 | FRA(FRA1,FRA2,FRA3) |
磁盘组名称 | MGT(MGT1,MGT2,MGT3) |
7 启动DB安装
su - oracle
#rac1#oracle>
cd $ORACLE_HOME
export DISPLAY=192.168.10.130:0.0
./runInstaller
7.1 DB 软件安装参数
参数 | 值 |
---|---|
install options | install database software only |
安装类型 | Oracle real application clustersdatabase |
OS Password | oracle |
不勾选 | Reuse private and public keys existing in the user home |
language | 添加simplified chinese |
数据库版本 | 企业版 |
oracle base | /u01/app/oracle |
软件安装目录 | /u01/app/oracle/product/21.3.0/db_1 |
OSDBA | dba |
OSOPER | dba |
OSBACKUPDBA | dba |
OSDGDBA | dba |
OSKMDBA | dba |
OSRACDBA | dba |
7.2 Oracle数据库安装参数
su - oracle
#oracle>
export DISPLAY=192.168.10.130:0.0
dbca
选项 | 参数 |
---|---|
数据库类型 | 选择GTP |
Global Database Name | citdb |
PDB | pdb1 |
EM | 不勾选 |
自动维护工具 | 开启 |
system 和sys 密码 | oracle |
数据文件存储 | ASM |
SFRA (快速恢复区) | 4182 (默认) |
sample schemas | 勾选 |
SGA and PGA | 选择TYpical 并指定 70%。 |
Process | 150 |
字符集 | AL16UTF16 |
Connection mode | 独占模式 |
Oracle-Manage | +DATA |
快速恢复区 | +FRA |
7.3 导入测试数据
导入 [[000-inbox/Oracle/inito.sql]] 脚本,生成 oa
模式。
7.4 密码过期处理
7.4.1 查看用户 Profile
#oracle>
sqlplus / as sysdba
SELECT username,PROFILE FROM dba_users WHERE username IN ('SYSTEM','OA');
7.4.2 更改 profile
策略
设置 profile
策略
#sys>
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
更多内容请参考 Oracle 密码过期策略
8 FAQ
8.1 互信问题
Warning
报错信息:passwordless ssh connectivity is not setup from the local node node1 to the following nodes node2
解决方案
1)Rename the original scp.
mv /usr/bin/scp /usr/bin/scp.orig
2)Create a new file .
vi /usr/bin/scp
3)Add the below line to the new created file .
/usr/bin/scp.orig -T $*
4)Change the file permission.
chmod 555 /usr/bin/scp
After installation:
mv /usr/bin/scp.orig /usr/bin/scp
8.2 删除磁盘组
count=1;
for i in {b..m};
do oracleasm deletedisk FRA$count;
let count+=1;
done
count=1;
for i in {b..m};
do oracleasm deletedisk DATA$count;
let count+=1;
done
count=1;
for i in {b..m};
do oracleasm deletedisk OCR$count;
let count+=1;
done
count=1;
for i in {b..m};
do oracleasm deletedisk MGT$count;
let count+=1;
done
8.3 删除磁盘分区
for i in {b..m};
do fdisk /dev/sd$i << eof
d
w
eof
done