当前位置: 首页 > article >正文

Oracle Dataguard(主库为 RAC 双节点集群)配置详解(1):安装 Oracle11g RAC 双节点集群

Oracle Dataguard(主库为 RAC 双节点集群)配置详解(1):安装 Oracle11g RAC 双节点集群

目录

  • Oracle Dataguard(主库为 RAC 双节点集群)配置详解(1):安装 Oracle11g RAC 双节点集群
    • 一、Oracle 11g rac 安装规划
    • 二、关闭防火墙和 selinux(两个节点同时操作)
    • 三、修改主机的 shell 限制(两个节点同时操作)
    • 四、修改主机的内核参数(两个节点同时操作)
    • 五、修改 /etc/pam.d/login(两个节点同时操作)
    • 六、禁用 NTP 服务(两个节点同时操作)
    • 七、创建用户和组(两个节点同时操作)
    • 八、配置 oracle 和 grid 用户的环境变量(两个节点同时操作)
        • 1、修改 oracle 用户的配置文件
        • 2、修改 grid 用户的配置文件
    • 九、在 VMWARE 虚拟机配置共享磁盘并按要求进行分区
        • 1、在 VMware 虚拟机中配置共享磁盘
        • 2、对共享磁盘进行分区(在任意一个节点上执行)
    • 十、使用 ASM 管理共享磁盘
        • 1、安装 oracleasm(两个节点同时操作)
        • 2、创建 ASM 磁盘
    • 十一、配置网络与 DNS 服务器
        • 1、查看主机 IP 地址
        • 2、修改 /etc/hosts 文件(两个节点内容相同)
        • 3、安装 DNS 服务器
        • 4、配置 DNS 服务器
        • 5、配置客户端(两个节点同时操作)
        • 6、强制修改 resolv.conf 的文件 flag,设定为不可被更改(两个节点同时操作)
        • 7、测试 DNS 服务器
        • (2)测试效果
    • 十二、配置 grid 用户和 oracle 用户的信任关系
        • 1、配置 grid 用户的信任关系
        • 2、配置 oracle 用户的信任关系
    • 十三、安装 grid 软件前的准备工作
        • 1、创建目录并授权(两个节点同时操作)
        • 2、安装 Oracle 所需要的依赖包(两个节点同时操作)
        • 3、将 grid 安装包上传到节点 rac01 的 grid 家目录
        • 4、将 oracle 安装包上传到节点 rac01 的 oracle 家目录
        • 5、解压缩 grid 软件包
        • 6、安装 cvuqdisk-1.0.9-1.rpm 包(两个节点同时操作)
        • 7、执行以下命令(两个节点同时操作)
        • 8、校验集群安装的可行性
    • 十四、安装 grid 软件
        • 1、根据需要修改 grid 响应文件
        • 2、开始安装 grid 软件
        • 4、查看 grid rac 状态
    • 十五、解决退格键乱码问题
        • 1、安装 readline-6.2(两节点同时操作)
        • 2、安装 libtermcap-devel (两节点同时操作)
        • 3、安装 rlwrap-0.37(两节点同时操作)
    • 十五、安装 Oracle 软件
        • 1、创建磁盘组
        • 2、修改 oracle 响应文件(只在节点1 执行)
        • 3、开始安装 oracle 软件
        • 4、查看集群状态
    • 十六、创建数据库
        • 1、修改建库使用的响应文件
        • 2、使用 dbca 命令创建数据库
        • 3、查看 grid 集群状态

一、Oracle 11g rac 安装规划

在虚拟机环境中安装包含两个节点的 Oracle 11g rac 集群,节点名称分别为 rac01 和 rac02,每台虚拟机使用一块本地磁盘(容量 50GB)和一块共享磁盘(容量 30GB)。具体配置如下:

(1)虚拟机:VMware Workstation12;

(2)操作系统:CentOS7.3、64位系统;

(3)IP 地址:

主机名IP地址子网掩码网关DNS
节点1(rac01)
Public IP(ens33)192.168.1.1124192.168.1.1192.168.1.1
Private IP(ens38)10.1.1.1124
节点2(rac02)
Public IP(ens33)192.168.1.1224192.168.1.1192.168.1.1
Private IP(ens38)10.1.1.1224
Virtual IP(VIP)192.168.1.21
实例名:节点1(rac01)oracle1
节点2(rac02)oracle2

二、关闭防火墙和 selinux(两个节点同时操作)

# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld

# 关闭 selinux
# 修改文件 /etc/selinux/config,设置 SELINUX=disabled:
[root@localhost /]# vi /etc/selinux/config
# 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 two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

三、修改主机的 shell 限制(两个节点同时操作)

修改 /etc/security/limits.conf 文件,在文件的结尾添加以下内容:

[root@localhost /]# vi /etc/security/limits.conf

.....

grid soft nofile 65536
grid hard nofile 65536
grid soft nproc 16384
grid hard nproc 16384

oracle soft nofile 65536
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
                            
# End of file

四、修改主机的内核参数(两个节点同时操作)

修改/etc/sysctl.conf文件,在文件的结尾添加以下内容:

[root@localhost /]# vi /etc/sysctl.conf

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

执行以下命令使内核参数生效:

[root@localhost /]# /sbin/sysctl -p
kernel.shmmax = 4294967296
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
fs.aio-max-nr = 1048576
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

五、修改 /etc/pam.d/login(两个节点同时操作)

修改 /etc/pam.d/login 文件,在文件的结尾添加以下内容:

[root@localhost /]# vi /etc/pam.d/login

......

session required /lib64/security/pam_limits.so
session required pam_limits.so

六、禁用 NTP 服务(两个节点同时操作)

[root@localhost /]# systemctl stop ntpd
Failed to stop ntpd.service: Unit ntpd.service not loaded.

七、创建用户和组(两个节点同时操作)

# 创建组
groupadd -g 501 oinstall
groupadd -g 502 dba
groupadd -g 503 oper
groupadd -g 504 asmadmin
groupadd -g 505 asmdba
groupadd -g 506 asmoper

# 创建用户并设置密码
# grid用户所在的组为:dba,asmadmin,asmdba,asmoper
# oracle用户所在的组为:dba,oper,asmdba,asmadmin

useradd -u 502 -g oinstall -G dba,asmadmin,asmdba,asmoper grid
useradd -u 501 -g oinstall -G dba,oper,asmdba,asmadmin oracle
echo "oracle" | passwd --stdin oracle  # 为oracle用户设置密码
echo "grid" | passwd --stdin grid      # 为grid用户设置密码

八、配置 oracle 和 grid 用户的环境变量(两个节点同时操作)

1、修改 oracle 用户的配置文件
su - oracle
vi .bash_profile

# 节点1的内容
.....
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_OWNER=oracle
export ORACLE_SID=ora1   # 实例名为 ora1
export ORACLE_TERM=vt100
export THREADS_FLAG=native
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
export EDITOR=vi
export SQLPATH=/home/oracle
export LANG=en_US
alias sqlplus='rlwrap sqlplus'
alias lsnrctl='rlwrap lsnrctl'
alias rman='rlwrap rman'
alias dgmgrl='rlwrap dgmgrl'

# 节点2的内容
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_OWNER=oracle
export ORACLE_SID=ora2   # 实例名为 ora1
export ORACLE_TERM=vt100
export THREADS_FLAG=native
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
export EDITOR=vi
export SQLPATH=/home/oracle
export LANG=en_US
alias sqlplus='rlwrap sqlplus'
alias lsnrctl='rlwrap lsnrctl'
alias rman='rlwrap rman'
alias dgmgrl='rlwrap dgmgrl'

# 使环境变量生效
source .bash_profile 
2、修改 grid 用户的配置文件
su - grid
vi .bash_profile

# 节点1的内容
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export ORACLE_OWNER=oracle
export ORACLE_SID=+ASM1
export ORACLE_TERM=vt100
export THREADS_FLAG=native
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
export LANG=en_US
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias lsnrctl='rlwrap lsnrctl'
alias asmcmd='rlwrap asmcmd'

# 节点2的内容
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export ORACLE_OWNER=oracle
export ORACLE_SID=+ASM2
export ORACLE_TERM=vt100
export THREADS_FLAG=native
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
export LANG=en_US
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias lsnrctl='rlwrap lsnrctl'
alias asmcmd='rlwrap asmcmd'

# 使环境变量生效
source .bash_profile

九、在 VMWARE 虚拟机配置共享磁盘并按要求进行分区

1、在 VMware 虚拟机中配置共享磁盘

(1)打开 windows 命令行窗口、进入 VMware 安装路径

 C:\Program Files (x86)\VMware\VMware Workstation 的目录

2015-08-14  13:43            89,792 vmware-authd.exe
2015-08-14  14:02        12,465,344 vmware-hostd.exe
2015-08-14  14:03           659,648 vmware-kvm.exe
2015-08-14  14:03         5,309,120 vmware-remotemks.exe
2015-08-14  14:03            84,672 vmware-shell-ext-thunker.exe
2015-08-14  14:03            42,176 vmware-tray-helper.dll
2015-08-14  14:03           104,128 vmware-tray.exe
2015-08-14  14:03           194,752 vmware-unity-helper.exe
2015-08-14  14:01         1,352,896 vmware-vdiskmanager.exe
2015-08-14  14:03         1,960,128 vmware.exe
2015-08-14  13:43         5,796,544 vmwarebase.dll
2015-08-14  14:03         9,894,592 vmwarecui.dll
2015-08-14  14:03            50,368 vmwarestring.dll
2015-08-14  14:03         4,968,128 vmwarewui.dll
              14 个文件     42,972,288 字节
               0 个目录 13,696,651,264 可用字节

(2)执行 vmware-vdiskmanager.exe 命令创建虚拟磁盘

C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager.exe -c -s 30gb -a lsilogic -t 2 G:\vm_xuniji\Share_Disk\sdisk1.vmdk
Creating disk 'G:\vm_xuniji\Share_Disk\sdisk1.vmdk'
  Create: 100% done.
Virtual disk creation successful.

(3)修改虚拟机配置文件

关闭虚拟机,编辑虚拟机安装目录下的xxx.vmx文件。

进入虚拟机对应的文件夹,使用文本编辑器卡开虚拟机oracle-rac01中的oracle-rac01.vmx文件以及oracle-rac02中的oracle-rac02.vmx文件,在文件的结尾添加如下内容:

disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.dataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"

scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"
scsi1.sharedBus = "VIRTUAL"

scsi1:1.present = "TRUE"
scsi1:1.mode = "independent-persistent"
scsi1:1.fileName = "G:\vm_xuniji\Share_Disk\sdisk1.vmdk"  
scsi1:1.deviceType = "disk"
scsi1:1.redo = ""

(4)启动虚拟机,查看磁盘情况

# 节点1
[root@rac01 ~]# ll /dev/sd*
brw-rw---- 1 root disk 8,  0 17 16:34 /dev/sda
brw-rw---- 1 root disk 8,  1 17 16:34 /dev/sda1
brw-rw---- 1 root disk 8,  2 17 16:34 /dev/sda2
brw-rw---- 1 root disk 8, 16 17 16:34 /dev/sdb

# 节点2
[root@rac02 ~]# ll /dev/sd*
brw-rw---- 1 root disk 8,  0 17 16:34 /dev/sda
brw-rw---- 1 root disk 8,  1 17 16:34 /dev/sda1
brw-rw---- 1 root disk 8,  2 17 16:34 /dev/sda2
brw-rw---- 1 root disk 8, 16 17 16:34 /dev/sdb

# sdb即为共享磁盘
2、对共享磁盘进行分区(在任意一个节点上执行)

在节点rac01上对新添加的共享磁盘进行分区,一共分为7个分区,其中三个主分区,编号为:1-3,大小均为1GB,四个扩展分区,编号为:5-8,大小均为6GB

(1)查看磁盘分区情况

[root@rac01 ~]# fdisk -l

磁盘 /dev/sdb:32.2 GB, 32212254720 字节,62914560 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/sda:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a7ba2

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   104857599    51379200   8e  Linux LVM

磁盘 /dev/mapper/cl-root:50.5 GB, 50457477120 字节,98549760 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/cl-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

(2)使用fdisk命令对共享磁盘分区

[root@rac01 ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

Device does not contain a recognized partition table
使用磁盘标识符 0x2e9b48ef 创建新的 DOS 磁盘标签。

#  创建第 1 个主分区
命令(输入 m 获取帮助):n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-62914559,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-62914559,默认为 62914559):+1G
分区 1 已设置为 Linux 类型,大小设为 1 GiB

#  创建第 2 个主分区
命令(输入 m 获取帮助):n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): 
Using default response p
分区号 (2-4,默认 2):
起始 扇区 (2099200-62914559,默认为 2099200):
将使用默认值 2099200
Last 扇区, +扇区 or +size{K,M,G} (2099200-62914559,默认为 62914559):+1G
分区 2 已设置为 Linux 类型,大小设为 1 GiB

#  创建第 3 个主分区
命令(输入 m 获取帮助):n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): 
Using default response p
分区号 (3,4,默认 3):
起始 扇区 (4196352-62914559,默认为 4196352):
将使用默认值 4196352
Last 扇区, +扇区 or +size{K,M,G} (4196352-62914559,默认为 62914559):+1G
分区 3 已设置为 Linux 类型,大小设为 1 GiB

#  创建扩展分区
命令(输入 m 获取帮助):n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): e
已选择分区 4
起始 扇区 (6293504-62914559,默认为 6293504):
将使用默认值 6293504
Last 扇区, +扇区 or +size{K,M,G} (6293504-62914559,默认为 62914559):
将使用默认值 62914559
分区 4 已设置为 Extended 类型,大小设为 27 GiB

# 创建第 1 个逻辑分区
命令(输入 m 获取帮助):n
All primary partitions are in use
添加逻辑分区 5
起始 扇区 (6295552-62914559,默认为 6295552):
将使用默认值 6295552
Last 扇区, +扇区 or +size{K,M,G} (6295552-62914559,默认为 62914559):+6G
分区 5 已设置为 Linux 类型,大小设为 6 GiB

# 创建第 2 个逻辑分区
命令(输入 m 获取帮助):n
All primary partitions are in use
添加逻辑分区 6
起始 扇区 (18880512-62914559,默认为 18880512):
将使用默认值 18880512
Last 扇区, +扇区 or +size{K,M,G} (18880512-62914559,默认为 62914559):+6G
分区 6 已设置为 Linux 类型,大小设为 6 GiB

# 创建第 3 个逻辑分区
命令(输入 m 获取帮助):n
All primary partitions are in use
添加逻辑分区 7
起始 扇区 (31465472-62914559,默认为 31465472):
将使用默认值 31465472
Last 扇区, +扇区 or +size{K,M,G} (31465472-62914559,默认为 62914559):+6G
分区 7 已设置为 Linux 类型,大小设为 6 GiB

# 创建第 4 个逻辑分区
命令(输入 m 获取帮助):n
All primary partitions are in use
添加逻辑分区 8
起始 扇区 (44050432-62914559,默认为 44050432):
将使用默认值 44050432
Last 扇区, +扇区 or +size{K,M,G} (44050432-62914559,默认为 62914559):+6G
分区 8 已设置为 Linux 类型,大小设为 6 GiB

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。

(3)重新查看分区情况

# 查看分区情况
[root@rac01 ~]# fdisk -l

磁盘 /dev/sdb:32.2 GB, 32212254720 字节,62914560 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x2e9b48ef

   设备 Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux
/dev/sdb2         2099200     4196351     1048576   83  Linux
/dev/sdb3         4196352     6293503     1048576   83  Linux
/dev/sdb4         6293504    62914559    28310528    5  Extended
/dev/sdb5         6295552    18878463     6291456   83  Linux
/dev/sdb6        18880512    31463423     6291456   83  Linux
/dev/sdb7        31465472    44048383     6291456   83  Linux
/dev/sdb8        44050432    56633343     6291456   83  Linux

磁盘 /dev/sda:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a7ba2

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   104857599    51379200   8e  Linux LVM

磁盘 /dev/mapper/cl-root:50.5 GB, 50457477120 字节,98549760 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/cl-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

# 查看磁盘
[root@rac01 ~]# ll /dev/sd*
brw-rw---- 1 root disk 8,  0 17 16:34 /dev/sda
brw-rw---- 1 root disk 8,  1 17 16:34 /dev/sda1
brw-rw---- 1 root disk 8,  2 17 16:34 /dev/sda2
brw-rw---- 1 root disk 8, 16 17 16:44 /dev/sdb
brw-rw---- 1 root disk 8, 17 17 16:44 /dev/sdb1
brw-rw---- 1 root disk 8, 18 17 16:44 /dev/sdb2
brw-rw---- 1 root disk 8, 19 17 16:44 /dev/sdb3
brw-rw---- 1 root disk 8, 20 17 16:44 /dev/sdb4
brw-rw---- 1 root disk 8, 21 17 16:44 /dev/sdb5
brw-rw---- 1 root disk 8, 22 17 16:44 /dev/sdb6
brw-rw---- 1 root disk 8, 23 17 16:44 /dev/sdb7
brw-rw---- 1 root disk 8, 24 17 16:44 /dev/sdb8

(4)在另一个节点上执行partprobe命令识别分区

在节点rac02上执行以下命令:

# 执行`partprobe`命令识别分区
[root@rac02 ~]# partprobe
Warning: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。

# 查看分区信息
[root@rac02 ~]# fdisk -l

磁盘 /dev/sdb:32.2 GB, 32212254720 字节,62914560 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x2e9b48ef

   设备 Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux
/dev/sdb2         2099200     4196351     1048576   83  Linux
/dev/sdb3         4196352     6293503     1048576   83  Linux
/dev/sdb4         6293504    62914559    28310528    5  Extended
/dev/sdb5         6295552    18878463     6291456   83  Linux
/dev/sdb6        18880512    31463423     6291456   83  Linux
/dev/sdb7        31465472    44048383     6291456   83  Linux
/dev/sdb8        44050432    56633343     6291456   83  Linux

磁盘 /dev/sda:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a67d4

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   104857599    51379200   8e  Linux LVM

磁盘 /dev/mapper/cl-root:50.5 GB, 50457477120 字节,98549760 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/cl-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

# 查看磁盘
[root@rac02 ~]# ll /dev/sd*
brw-rw---- 1 root disk 8,  0 17 16:49 /dev/sda
brw-rw---- 1 root disk 8,  1 17 16:49 /dev/sda1
brw-rw---- 1 root disk 8,  2 17 16:49 /dev/sda2
brw-rw---- 1 root disk 8, 16 17 16:49 /dev/sdb
brw-rw---- 1 root disk 8, 17 17 16:49 /dev/sdb1
brw-rw---- 1 root disk 8, 18 17 16:49 /dev/sdb2
brw-rw---- 1 root disk 8, 19 17 16:49 /dev/sdb3
brw-rw---- 1 root disk 8, 20 17 16:49 /dev/sdb4
brw-rw---- 1 root disk 8, 21 17 16:49 /dev/sdb5
brw-rw---- 1 root disk 8, 22 17 16:49 /dev/sdb6
brw-rw---- 1 root disk 8, 23 17 16:49 /dev/sdb7
brw-rw---- 1 root disk 8, 24 17 16:49 /dev/sdb8

十、使用 ASM 管理共享磁盘

1、安装 oracleasm(两个节点同时操作)

(1)上传所需的rpm包(注意oracleasm版本号和操作系统必须匹配)

[root@rac02 asm]# pwd
/home/soft/asm
[root@rac02 asm]# ll
总用量 136
-rw-r--r-- 1 root root 34436 81 2018 kmod-oracleasm-2.0.8-17.el7.x86_64.rpm
-rw-r--r-- 1 root root 19360 81 2018 oracleasmlib-2.0.12-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 80968 81 2018 oracleasm-support-2.1.8-3.el7.x86_64.rpm

(2)依次安装rpm

# 1、安装 kom-oracleasm 包
[root@rac02 asm]# rpm -ivh kmod-oracleasm-2.0.8-17.el7.x86_64.rpm
警告:kmod-oracleasm-2.0.8-17.el7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 192a7d7d: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:kmod-oracleasm-2.0.8-17.el7      ################################# [100%]

# 2、安装 oracleasmlib 包
[root@rac01 asm]# rpm -ivh oracleasmlib-2.0.12-1.el7.x86_64.rpm 
警告:oracleasmlib-2.0.12-1.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:oracleasmlib-2.0.12-1.el7        ################################# [100%]

# 3、安装 oracleasm-support 包
[root@rac02 asm]# rpm -ivh oracleasm-support-2.1.8-3.el7.x86_64.rpm
警告:oracleasm-support-2.1.8-3.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:oracleasm-support-2.1.8-3.el7    ################################# [100%]
注意:正在将请求转发到“systemctl enable oracleasm.service”。
Created symlink from /etc/systemd/system/multi-user.target.wants/oracleasm.service to /usr/lib/systemd/system/oracleasm.service.

(3)初始化ASM

# ========================================================================================
#   注意:oracleasm 命令有两个,一个在 /etc/init.d/ 目录下,另一个在 /usr/sbin/ 目录下
#        使用 /etc/init.d/oracleasm 进行初始化
# ========================================================================================
[root@rac02 asm]# /etc/init.d/oracleasm configure -i
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting <ENTER> without typing an
answer will keep that current value.  Ctrl-C will abort.

Default user to own the driver interface []: grid           # 选择用户:grid
Default group to own the driver interface []: asmadmin      # 选择用户所在的组:asmadmin
Scan for Oracle ASM disks on boot (y/n) [y]: y              # 选择:y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:                     [  OK  ]
Scanning the system for Oracle ASMLib disks:               [  OK  ]

(4)查看 ASM 的状态

[root@rac01 asm]# /etc/init.d/oracleasm  status
Checking if ASM is loaded: yes
Checking if /dev/oracleasm is mounted: yes
2、创建 ASM 磁盘

(1)在任意一个节点创建ASM磁盘

在节点rac01进行如下操作:

# 创建 ASM 磁盘
/etc/init.d/oracleasm createdisk ocr1 /dev/sdb1
/etc/init.d/oracleasm createdisk ocr2 /dev/sdb2
/etc/init.d/oracleasm createdisk ocr3 /dev/sdb3
/etc/init.d/oracleasm createdisk data1 /dev/sdb5
/etc/init.d/oracleasm createdisk data2 /dev/sdb6
/etc/init.d/oracleasm createdisk bak1 /dev/sdb7
/etc/init.d/oracleasm createdisk bak2 /dev/sdb8

# 执行以上命令创建 ASM 磁盘
[root@rac01 asm]# /etc/init.d/oracleasm createdisk ocr1 /dev/sdb1
acleasm createdisk bak1 /dev/sdb7
/etc/init.d/oracleasm createdisk bak2 /dev/sdb8Marking disk[  OK  ]as an ASM disk: 
[root@rac01 asm]# /etc/init.d/oracleasm createdisk ocr2 /dev/sdb2
Marking disk "ocr2" as an ASM disk:                        [  OK  ]
[root@rac01 asm]# /etc/init.d/oracleasm createdisk ocr3 /dev/sdb3
Marking disk "ocr3" as an ASM disk:                        [  OK  ]
[root@rac01 asm]# /etc/init.d/oracleasm createdisk data1 /dev/sdb5
Marking disk "data1" as an ASM disk:                       [  OK  ]
[root@rac01 asm]# /etc/init.d/oracleasm createdisk data2 /dev/sdb6
Marking disk "data2" as an ASM disk:                       [  OK  ]
[root@rac01 asm]# /etc/init.d/oracleasm createdisk bak1 /dev/sdb7
Marking disk "bak1" as an ASM disk:                        [  OK  ]
[root@rac01 asm]# /etc/init.d/oracleasm createdisk bak2 /dev/sdb8
Marking disk "bak2" as an ASM disk:                        [  OK  ]

# 查看 ASM 磁盘列表
[root@rac01 asm]# /etc/init.d/oracleasm  listdisks
BAK1
BAK2
DATA1
DATA2
OCR1
OCR2
OCR3

(2)在另一个节点扫描ASM磁盘

在节点rac02执行如下操作:

# 扫描 ASM 磁盘信息
[root@rac02 asm]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]

# 查看 ASM 磁盘列表
[root@rac02 asm]# /etc/init.d/oracleasm  listdisks
BAK1
BAK2
DATA1
DATA2
OCR1
OCR2
OCR3

十一、配置网络与 DNS 服务器

1、查看主机 IP 地址
# 节点 rac01 的 IP 地址信息
[root@rac01 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.11  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 2409:8a44:3d36:4750:20c:29ff:fe8d:b077  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::20c:29ff:fe8d:b077  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:8d:b0:77  txqueuelen 1000  (Ethernet)
        RX packets 3651  bytes 377629 (368.7 KiB)
        RX errors 0  dropped 2615  overruns 0  frame 0
        TX packets 663  bytes 130674 (127.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens38: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.1.1.11  netmask 255.255.255.0  broadcast 10.1.1.255
        inet6 fe80::20c:29ff:fe8d:b08b  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:8d:b0:8b  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 1005 (1005.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 768 (768.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 68  bytes 5524 (5.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 68  bytes 5524 (5.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        
        
# 节点 rac02 的 IP 地址信息
[root@rac02 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.12  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::20c:29ff:fe89:50e  prefixlen 64  scopeid 0x20<link>
        inet6 2409:8a44:3d36:4750:20c:29ff:fe89:50e  prefixlen 64  scopeid 0x0<global>
        ether 00:0c:29:89:05:0e  txqueuelen 1000  (Ethernet)
        RX packets 3576  bytes 370374 (361.6 KiB)
        RX errors 0  dropped 2690  overruns 0  frame 0
        TX packets 566  bytes 98326 (96.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens38: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.1.1.12  netmask 255.255.255.0  broadcast 10.1.1.255
        inet6 fe80::20c:29ff:fe89:522  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:89:05:22  txqueuelen 1000  (Ethernet)
        RX packets 9  bytes 1368 (1.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 768 (768.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 68  bytes 5524 (5.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 68  bytes 5524 (5.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
2、修改 /etc/hosts 文件(两个节点内容相同)
#Public Network (ens33)——公用IP

192.168.1.11 rac01
192.168.1.12 rac02

#Private Interconnect (ens38)——私有

10.1.1.11 rac01-priv
10.1.1.12 rac02-priv

#Virtual IP——虚拟 IP,与 Public Network 必须在同一网段  

192.168.1.101 rac01-vip
192.168.1.102 rac02-vip

#scan IP

192.168.1.21 rac-scan
3、安装 DNS 服务器

节点rac01作为DNS服务器,以下操作在节点rac01上进行。

(1)安装rpm

# 查看 rpm 包
[root@rac01 dns]# pwd
/home/soft/dns
[root@rac01 dns]# ll
总用量 5292
-rw-r--r-- 1 root root 4194724 119 2020 bind-9.8.2-0.68.rc1.el6_10.8.x86_64.rpm
-rw-r--r-- 1 root root   80368 119 2020 bind-chroot-9.8.2-0.68.rc1.el6_10.8.x86_64.rpm
-rw-r--r-- 1 root root  914528 119 2020 bind-libs-9.8.2-0.68.rc1.el6_10.8.x86_64.rpm
-rw-r--r-- 1 root root  194432 119 2020 bind-utils-9.8.2-0.68.rc1.el6_10.8.x86_64.rpm
-rw-r--r-- 1 root root   23628 512 2016 portreserve-0.0.4-11.el6.x86_64.rpm

# 安装 rpm 包
[root@rac01 dns]# rpm -ivh --force --nodeps *.rpm
警告:bind-9.8.2-0.68.rc1.el6_10.8.x86_64.rpm: 头V3 RSA/SHA1 Signature, 密钥 ID c105b9de: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:bind-libs-32:9.8.2-0.68.rc1.el6_1################################# [ 20%]
   2:portreserve-0.0.4-11.el6         ################################# [ 40%]
   3:bind-32:9.8.2-0.68.rc1.el6_10.8  ################################# [ 60%]
   4:bind-chroot-32:9.8.2-0.68.rc1.el6################################# [ 80%]
   5:bind-utils-32:9.8.2-0.68.rc1.el6_################################# [100%]

(2)启动DNS服务

# 依次执行如下命令
systemctl start named
systemctl enable named
/sbin/chkconfig named on
ps -ef|grep named

[root@rac01 dns]# systemctl start named

[root@rac01 dns]# systemctl enable named
named.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig named on

[root@rac01 dns]# /sbin/chkconfig named on

[root@rac01 dns]# ps -ef|grep named
named     12078      1  0 17:35 ?        00:00:00 /usr/sbin/named -u named -t /var/named/chroot
root      12127   2483  0 17:35 pts/0    00:00:00 grep --color=auto named
4、配置 DNS 服务器

(1)配置主文件(named.conf

[root@rac01 dns]# cd /var/named/chroot/etc
[root@rac01 etc]# ll
总用量 688
-rw-r--r--  1 root root     388 103 2016 localtime
drwxr-x---  2 root named      6 117 2020 named
-rw-r-----  1 root named    984 1120 2015 named.conf
-rw-r--r--  1 root named   3923 117 2020 named.iscdlv.key
-rw-r-----  1 root named    931 621 2007 named.rfc1912.zones
-rw-r--r--  1 root named   1587 530 2017 named.root.key
drwxr-x---  3 root named     25 17 17:33 pki
-rw-r--r--. 1 root root    6545 67 2013 protocols
-rw-r-----  1 root named     77 17 17:35 rndc.key
-rw-r--r--. 1 root root  670293 67 2013 services

# 主配置文件内容如下:
[root@rac01 etc]# vi /var/named/chroot/etc/named.conf

// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
        listen-on port 53 { any; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { any; };
        allow-query-cache     { any; };
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
view localhost_resolver {
        match-clients      { any; };
        match-destinations { any; };
        recursion yes;
        include "/etc/named.rfc1912.zones";
};

(2)配置区域文件named.rfc1912.zones

[root@rac01 etc]# cd /var/named/chroot/etc
[root@rac01 etc]# ll
总用量 688
-rw-r--r--  1 root root     388 103 2016 localtime
drwxr-x---  2 root named      6 117 2020 named
-rw-r-----  1 root named    930 17 17:42 named.conf
-rw-r--r--  1 root named   3923 117 2020 named.iscdlv.key
-rw-r-----  1 root named    931 621 2007 named.rfc1912.zones
-rw-r--r--  1 root named   1587 530 2017 named.root.key
drwxr-x---  3 root named     25 17 17:33 pki
-rw-r--r--. 1 root root    6545 67 2013 protocols
-rw-r-----  1 root named     77 17 17:35 rndc.key
-rw-r--r--. 1 root root  670293 67 2013 services

# 区域文件 named.rfc1912.zones 内容如下:
[root@rac1 etc]# vi named.rfc1912.zones
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R W Franks
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

zone "." IN {
        type hint;
        file "/dev/null";
};

zone "oracle.com" IN {
        type master;
        file "oracle.com.zone";
        allow-update { none; };
};

zone "1.168.192.in-addr.arpa" IN {
        type master;
        file "1.168.192.local";
        allow-update { none; };
};


# 注:oracle.com.zone 为正向解析文件,1.168.192.local 为反向解析文件。

(3)配置正向解析文件:oracle.com.zone

[root@rac01 etc]# cd /var/named/chroot/var/named

# 复制文件 named.localhost 生成正向解析文件 oracle.com.zone
[root@rac01 named]# cp -a named.localhost oracle.com.zone

[root@rac01 named]# ll
总用量 20
drwxr-x--- 7 root  named   63 17 17:33 chroot
drwxrwx--- 2 named named   23 17 17:35 data
drwxrwx--- 2 named named   60 17 17:35 dynamic
-rw-r----- 1 root  named 3289 411 2017 named.ca
-rw-r----- 1 root  named  152 1215 2009 named.empty
-rw-r----- 1 root  named  152 621 2007 named.localhost
-rw-r----- 1 root  named  168 1215 2009 named.loopback
-rw-r----- 1 root  named  565 17 17:50 oracle.com.zone
drwxrwx--- 2 named named    6 117 2020 slaves


# 正向解析文件 oracle.com.zone 内容如下:
[root@rac1 named]# vi oracle.com.zone

$TTL 86400
@       IN SOA  dns.oracle.com.     root.oracle.com. (
                                        42      ; serial
                                        3H      ; refresh
                                        15M     ; retry
                                        1W      ; expire
                                        1D )    ; minimum
@          IN        NS      dns.oracle.com.
dns        IN        A       192.168.1.11
rac01      IN        A       192.168.1.11
rac02      IN        A       192.168.1.12
scan       IN        A       192.168.1.21

(4)配置反向解析文件:1.168.192.local

[root@rac01 named]# cd /var/named/chroot/var/named

# 复制文件 named.loopback 生成反向解析文件 1.168.192.local
[root@rac01 named]# cp -a named.loopback 1.168.192.local

[root@rac01 named]# ll
总用量 24
-rw-r----- 1 root  named  168 1215 2009 1.168.192.local
drwxr-x--- 7 root  named   63 17 17:33 chroot
drwxrwx--- 2 named named   23 17 17:35 data
drwxrwx--- 2 named named   60 17 17:35 dynamic
-rw-r----- 1 root  named 3289 411 2017 named.ca
-rw-r----- 1 root  named  152 1215 2009 named.empty
-rw-r----- 1 root  named  152 621 2007 named.localhost
-rw-r----- 1 root  named  168 1215 2009 named.loopback
-rw-r----- 1 root  named  565 17 17:50 oracle.com.zone
drwxrwx--- 2 named named    6 117 2020 slaves

# 反向解析文件 1.168.192.local 内容如下:
$TTL 86400
@       IN SOA  dns.oracle.com.     root.oracle.com. (
                                        19997022700 ; serial
                                        28800       ; refresh
                                        14400       ; retry
                                        3600000     ; expire
                                        86400 )     ; minimum
@          IN        NS     dns.oracle.com.
11        IN        PTR     dns.oracle.com.
11        IN        PTR     rac01.oracle.com.
12        IN        PTR     rac02.oracle.com.
21        IN        PTR     scan.oracle.com.

(5)重新启动DNS服务

[root@rac01 named]# systemctl restart named
5、配置客户端(两个节点同时操作)
[root@rac01 named]# vi /etc/resolv.conf
# Generated by NetworkManager
search oracle.com
nameserver 192.168.1.11
6、强制修改 resolv.conf 的文件 flag,设定为不可被更改(两个节点同时操作)

系统重启后/etc/resolv.conf文件会自动还原,强制修改resolv.conf的文件flag,设定为不可被更改。代码如下:

[root@rac01 ~]# chattr +i /etc/resolv.conf
7、测试 DNS 服务器

(1)在节点rac02安装以下rpm

[root@rac02 dns]# pwd
/home/soft/dns
[root@rac02 dns]# ll
总用量 1088
-rw-r--r-- 1 root root 914528 119 2020 bind-libs-9.8.2-0.68.rc1.el6_10.8.x86_64.rpm
-rw-r--r-- 1 root root 194432 119 2020 bind-utils-9.8.2-0.68.rc1.el6_10.8.x86_64.rpm


[root@rac02 dns]# rpm -ivh --nodeps --force *.rpm
警告:bind-libs-9.8.2-0.68.rc1.el6_10.8.x86_64.rpm: 头V3 RSA/SHA1 Signature, 密钥 ID c105b9de: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:bind-libs-32:9.8.2-0.68.rc1.el6_1################################# [ 50%]
   2:bind-utils-32:9.8.2-0.68.rc1.el6_################################# [100%]
(2)测试效果

节点1:

# 在节点 rac01 执行如下命令:
nslookup scan.oracle.com
nslookup 192.168.1.21
nslookup rac02.oracle.com
nslookup 192.168.1.12


# 运行结果如下
[root@rac01 named]# nslookup scan.oracle.com
Server:		192.168.1.11
Address:	192.168.1.11#53

Name:	scan.oracle.com
Address: 192.168.1.21

[root@rac01 named]# nslookup 192.168.1.21
Server:		192.168.1.11
Address:	192.168.1.11#53

21.1.168.192.in-addr.arpa	name = scan.oracle.com.

[root@rac01 named]# nslookup rac02.oracle.com
Server:		192.168.1.11
Address:	192.168.1.11#53

Name:	rac02.oracle.com
Address: 192.168.1.12

[root@rac01 named]# nslookup 192.168.1.12
Server:		192.168.1.11
Address:	192.168.1.11#53

12.1.168.192.in-addr.arpa	name = rac02.oracle.com.

节点2:

# 在节点 rac01 执行如下命令:
nslookup scan.oracle.com
nslookup 192.168.1.21
nslookup rac02.oracle.com
nslookup 192.168.1.12


# 运行结果如下
[root@rac02 dns]# nslookup scan.oracle.com
Server:		192.168.1.11
Address:	192.168.1.11#53

Name:	scan.oracle.com
Address: 192.168.1.21

[root@rac02 dns]# nslookup 192.168.1.21
Server:		192.168.1.11
Address:	192.168.1.11#53

21.1.168.192.in-addr.arpa	name = scan.oracle.com.

[root@rac02 dns]# nslookup rac02.oracle.com
Server:		192.168.1.11
Address:	192.168.1.11#53

Name:	rac02.oracle.com
Address: 192.168.1.12

[root@rac02 dns]# nslookup 192.168.1.12
Server:		192.168.1.11
Address:	192.168.1.11#53

12.1.168.192.in-addr.arpa	name = rac02.oracle.com.

十二、配置 grid 用户和 oracle 用户的信任关系

1、配置 grid 用户的信任关系

(1)在每个节点上生成公钥和私钥并添加到authorized_keys文件中

说明:1-3步在节点rac01rac02同时操作

步骤1:生成公钥(两个节点同时操作:一路回车)

su - grid

[grid@rac01 ~]$ ssh-keygen -t rsa

步骤2:生成私钥(两个节点同时操作:一路回车)

[grid@rac01 ~]$ ssh-keygen -t dsa

步骤3:切换目录(两个节点同时操作)

[grid@rac02 ~]$ cd .ssh

步骤4:在节点rac01上执行以下操作

# 把节点 rac01 上的公钥和私钥全部复制到 authorized_keys 文件中
[grid@rac01 .ssh]$ cat *.pub > authorized_keys

# 查看文件
[grid@rac01 .ssh]$ ll
total 20
-rw-r--r-- 1 grid oinstall  992 Jan  7 18:53 authorized_keys
-rw------- 1 grid oinstall  668 Jan  7 18:50 id_dsa
-rw-r--r-- 1 grid oinstall  600 Jan  7 18:50 id_dsa.pub
-rw------- 1 grid oinstall 1675 Jan  7 18:50 id_rsa
-rw-r--r-- 1 grid oinstall  392 Jan  7 18:50 id_rsa.pub

# 把 authorized_keys 文件复制到节点 rac02
[grid@rac01 .ssh]$ scp authorized_keys grid@rac02:/home/grid/.ssh/authorized_keys
The authenticity of host 'rac02 (192.168.1.12)' can't be established.
ECDSA key fingerprint is 67:84:19:82:a3:58:0f:4e:38:bc:e7:13:32:2d:dd:b8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac02,192.168.1.12' (ECDSA) to the list of known hosts.
grid@rac02's password: 
authorized_keys                   100%  992     1.0KB/s   00:00

步骤5:在节点rac02上执行以下操作

# 查看文件
[grid@rac02 .ssh]$ ll
total 12
-rw-r--r-- 1 grid oinstall 992 Jan  7 18:55 authorized_keys
-rw------- 1 grid oinstall 668 Jan  7 18:50 id_dsa
-rw-r--r-- 1 grid oinstall 600 Jan  7 18:50 id_dsa.pub

# 把节点 rac02 上的公钥和密钥全部添加到 authorized_keys 文件中
[grid@rac02 .ssh]$ cat *.pub >> authorized_keys

# 把节点 rac02 上的 authorized_keys 文件复制到节点 rac01
[grid@rac02 .ssh]$ scp authorized_keys grid@rac01:/home/grid/.ssh/
The authenticity of host 'rac01 (192.168.1.11)' can't be established.
ECDSA key fingerprint is bf:47:c8:c0:44:4d:de:b2:dd:ef:89:8b:4f:13:da:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac01,192.168.1.11' (ECDSA) to the list of known hosts.
grid@rac01's password:            100% 1592     1.6KB/s   00:00 

(2)分别在两个节点上测试grid用户的信任关系

节点1rac01):

ssh rac01 date
ssh rac02 date
ssh rac01-priv date
ssh rac02-priv date

# 执行结果如下
[grid@rac01 .ssh]$ ssh rac01 date
The authenticity of host 'rac01 (192.168.1.11)' can't be established.
ECDSA key fingerprint is bf:47:c8:c0:44:4d:de:b2:dd:ef:89:8b:4f:13:da:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac01,192.168.1.11' (ECDSA) to the list of known hosts.
Tue Jan  7 19:00:20 CST 2025

[grid@rac01 .ssh]$ ssh rac02 date
Tue Jan  7 19:00:24 CST 2025

[grid@rac01 .ssh]$ ssh rac01-priv date
The authenticity of host 'rac01-priv (10.1.1.11)' can't be established.
ECDSA key fingerprint is bf:47:c8:c0:44:4d:de:b2:dd:ef:89:8b:4f:13:da:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac01-priv,10.1.1.11' (ECDSA) to the list of known hosts.
Tue Jan  7 19:00:33 CST 2025

[grid@rac01 .ssh]$ ssh rac02-priv date
The authenticity of host 'rac02-priv (10.1.1.12)' can't be established.
ECDSA key fingerprint is 67:84:19:82:a3:58:0f:4e:38:bc:e7:13:32:2d:dd:b8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac02-priv,10.1.1.12' (ECDSA) to the list of known hosts.
Tue Jan  7 19:00:42 CST 2025

# 第二次执行
[grid@rac01 .ssh]$ ssh rac01 date
Tue Jan  7 19:01:36 CST 2025
[grid@rac01 .ssh]$ ssh rac02 date
Tue Jan  7 19:01:36 CST 2025
[grid@rac01 .ssh]$ ssh rac01-priv date
Tue Jan  7 19:01:36 CST 2025
[grid@rac01 .ssh]$ ssh rac02-priv date
Tue Jan  7 19:01:38 CST 2025

节点2rac02):

ssh rac01 date
ssh rac02 date
ssh rac01-priv date
ssh rac02-priv date

# 执行结果如下
[grid@rac02 .ssh]$ ssh rac01 date
Tue Jan  7 19:02:32 CST 2025

[grid@rac02 .ssh]$ ssh rac02 date
The authenticity of host 'rac02 (192.168.1.12)' can't be established.
ECDSA key fingerprint is 67:84:19:82:a3:58:0f:4e:38:bc:e7:13:32:2d:dd:b8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac02,192.168.1.12' (ECDSA) to the list of known hosts.
Tue Jan  7 19:02:39 CST 2025

[grid@rac02 .ssh]$ ssh rac01-priv date
The authenticity of host 'rac01-priv (10.1.1.11)' can't be established.
ECDSA key fingerprint is bf:47:c8:c0:44:4d:de:b2:dd:ef:89:8b:4f:13:da:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac01-priv,10.1.1.11' (ECDSA) to the list of known hosts.
Tue Jan  7 19:02:47 CST 2025

[grid@rac02 .ssh]$ ssh rac02-priv date
The authenticity of host 'rac02-priv (10.1.1.12)' can't be established.
ECDSA key fingerprint is 67:84:19:82:a3:58:0f:4e:38:bc:e7:13:32:2d:dd:b8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac02-priv,10.1.1.12' (ECDSA) to the list of known hosts.
Tue Jan  7 19:02:53 CST 2025

# 第二次执行
[grid@rac02 .ssh]$ ssh rac01 date
Tue Jan  7 19:03:12 CST 2025
[grid@rac02 .ssh]$ ssh rac02 date
Tue Jan  7 19:03:12 CST 2025
[grid@rac02 .ssh]$ ssh rac01-priv date
Tue Jan  7 19:03:12 CST 2025
[grid@rac02 .ssh]$ ssh rac02-priv date
Tue Jan  7 19:03:13 CST 2025
2、配置 oracle 用户的信任关系

(1)在每个节点上生成公钥和私钥并添加到authorized_keys文件中

说明:1-3步在节点rac01rac02同时操作

步骤1:生成公钥(两个节点同时操作:一路回车)

su - oracle
[oracle@rac02 ~]$ ssh-keygen -t rsa

步骤2:生成私钥(两个节点同时操作:一路回车)

[oracle@rac01 ~]$ ssh-keygen -t dsa

步骤3:切换目录(两个节点同时操作)

[oracle@rac02 ~]$ cd .ssh

步骤4:在节点rac01上执行以下操作

# 把节点 rac01 上的公钥和私钥全部复制到 authorized_keys 文件中
[oracle@rac01 .ssh]$ cat *.pub > authorized_keys

# 查看文件
[oracle@rac01 .ssh]$ ll
total 20
-rw-r--r-- 1 oracle oinstall  996 Jan  7 19:07 authorized_keys
-rw------- 1 oracle oinstall  672 Jan  7 19:05 id_dsa
-rw-r--r-- 1 oracle oinstall  602 Jan  7 19:05 id_dsa.pub
-rw------- 1 oracle oinstall 1675 Jan  7 19:05 id_rsa
-rw-r--r-- 1 oracle oinstall  394 Jan  7 19:05 id_rsa.pub

# 把 authorized_keys 文件复制到节点 rac02
[oracle@rac01 .ssh]$ scp authorized_keys oracle@rac02:/home/oracle/.ssh/authorized_keys
The authenticity of host 'rac02 (192.168.1.12)' can't be established.
ECDSA key fingerprint is 67:84:19:82:a3:58:0f:4e:38:bc:e7:13:32:2d:dd:b8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac02,192.168.1.12' (ECDSA) to the list of known hosts.
oracle@rac02's password: 
authorized_keys                  100%  996     1.0KB/s   00:00   

步骤5:在节点rac02上执行以下操作

# 查看文件
[oracle@rac02 .ssh]$ ll
total 20
-rw-r--r-- 1 oracle oinstall  996 Jan  7 19:08 authorized_keys
-rw------- 1 oracle oinstall  668 Jan  7 19:05 id_dsa
-rw-r--r-- 1 oracle oinstall  602 Jan  7 19:05 id_dsa.pub
-rw------- 1 oracle oinstall 1679 Jan  7 19:05 id_rsa
-rw-r--r-- 1 oracle oinstall  394 Jan  7 19:05 id_rsa.pub

# 把节点 rac02 上的公钥和密钥全部添加到 authorized_keys 文件中
[oracle@rac02 .ssh]$ cat *.pub >> authorized_keys

# 把节点 rac02 上的 authorized_keys 文件复制到节点 rac01
[oracle@rac02 .ssh]$ scp authorized_keys oracle@rac01:/home/oracle/.ssh/
The authenticity of host 'rac01 (192.168.1.11)' can't be established.
ECDSA key fingerprint is bf:47:c8:c0:44:4d:de:b2:dd:ef:89:8b:4f:13:da:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac01,192.168.1.11' (ECDSA) to the list of known hosts.
oracle@rac01's password: 
authorized_keys               100% 1992     2.0KB/s   00:00   

(2)分别在两个节点上测试oracle用户的信任关系

节点1rac01):

ssh rac01 date
ssh rac02 date
ssh rac01-priv date
ssh rac02-priv date

# 执行结果如下
[oracle@rac01 .ssh]$ ssh rac01 date
The authenticity of host 'rac01 (192.168.1.11)' can't be established.
ECDSA key fingerprint is bf:47:c8:c0:44:4d:de:b2:dd:ef:89:8b:4f:13:da:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac01,192.168.1.11' (ECDSA) to the list of known hosts.
Tue Jan  7 19:12:10 CST 2025

[oracle@rac01 .ssh]$ ssh rac02 date
Tue Jan  7 19:12:14 CST 2025

[oracle@rac01 .ssh]$ ssh rac01-priv date
The authenticity of host 'rac01-priv (10.1.1.11)' can't be established.
ECDSA key fingerprint is bf:47:c8:c0:44:4d:de:b2:dd:ef:89:8b:4f:13:da:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac01-priv,10.1.1.11' (ECDSA) to the list of known hosts.
Tue Jan  7 19:12:23 CST 2025

[oracle@rac01 .ssh]$ ssh rac02-priv date
The authenticity of host 'rac02-priv (10.1.1.12)' can't be established.
ECDSA key fingerprint is 67:84:19:82:a3:58:0f:4e:38:bc:e7:13:32:2d:dd:b8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac02-priv,10.1.1.12' (ECDSA) to the list of known hosts.
Tue Jan  7 19:12:29 CST 2025

# 第二次执行
[oracle@rac01 .ssh]$ ssh rac01 date
Tue Jan  7 19:13:01 CST 2025
[oracle@rac01 .ssh]$ ssh rac02 date
Tue Jan  7 19:13:02 CST 2025
[oracle@rac01 .ssh]$ ssh rac01-priv date
Tue Jan  7 19:13:01 CST 2025
[oracle@rac01 .ssh]$ ssh rac02-priv date
Tue Jan  7 19:13:02 CST 2025

节点2rac02):

ssh rac01 date
ssh rac02 date
ssh rac01-priv date
ssh rac02-priv date

# 执行结果如下
[oracle@rac02 .ssh]$ ssh rac01 date
Tue Jan  7 19:13:35 CST 2025

[oracle@rac02 .ssh]$ ssh rac02 date
The authenticity of host 'rac02 (192.168.1.12)' can't be established.
ECDSA key fingerprint is 67:84:19:82:a3:58:0f:4e:38:bc:e7:13:32:2d:dd:b8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac02,192.168.1.12' (ECDSA) to the list of known hosts.
Tue Jan  7 19:13:40 CST 2025

[oracle@rac02 .ssh]$ ssh rac01-priv date
The authenticity of host 'rac01-priv (10.1.1.11)' can't be established.
ECDSA key fingerprint is bf:47:c8:c0:44:4d:de:b2:dd:ef:89:8b:4f:13:da:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac01-priv,10.1.1.11' (ECDSA) to the list of known hosts.
Tue Jan  7 19:13:56 CST 2025

[oracle@rac02 .ssh]$ ssh rac02-priv date
The authenticity of host 'rac02-priv (10.1.1.12)' can't be established.
ECDSA key fingerprint is 67:84:19:82:a3:58:0f:4e:38:bc:e7:13:32:2d:dd:b8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac02-priv,10.1.1.12' (ECDSA) to the list of known hosts.
Tue Jan  7 19:14:03 CST 2025

# 第二次执行
[oracle@rac02 .ssh]$ ssh rac01 date
Tue Jan  7 19:14:31 CST 2025
[oracle@rac02 .ssh]$ ssh rac02 date
Tue Jan  7 19:14:31 CST 2025
[oracle@rac02 .ssh]$ ssh rac01-priv date
Tue Jan  7 19:14:31 CST 2025
[oracle@rac02 .ssh]$ ssh rac02-priv date
Tue Jan  7 19:14:32 CST 2025

十三、安装 grid 软件前的准备工作

1、创建目录并授权(两个节点同时操作)
# grid 用户的 oracle_base 目录:/u01/app/grid
# grid 用户的 oracle_home 目录:/u01/app/11.2.0/grid
# oracle 用户的 oracle_base 目录:/u01/app/oracle
# oracle 用户的 oracle_home 目录:/u01/app/oracle/product/11.2.0/db_1

su - root
# 创建以上目录
[root@rac01 ~]# mkdir -p /u01/app/grid /u01/app/11.2.0/grid /u01/app/oracle /u01/app/oracle/product/11.2.0/db_1

# 更改目录的所有者
chown -R grid:oinstall /u01
chown -R oracle:oinstall /u01/app/oracle

[root@rac02 ~]# chown -R grid:oinstall /u01
[root@rac02 ~]# chown -R oracle:oinstall /u01/app/oracle

# 更改目录的访问权限
[root@rac01 ~]# chmod -R 775 /u01/

# 查看目录
[root@rac02 ~]# ll /u01/app
总用量 0
drwxrwxr-x 3 grid   oinstall 18 17 19:17 11.2.0
drwxrwxr-x 2 grid   oinstall  6 17 19:17 grid
drwxrwxr-x 3 oracle oinstall 21 17 19:17 oracle
2、安装 Oracle 所需要的依赖包(两个节点同时操作)

(1)把所需的rpm包上传到服务器

[root@rac02 pack]# pwd
/home/soft/pack
[root@rac02 pack]# ll
总用量 119612
-rw-r--r-- 1 root root   195388 314 2015 compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
-rw-r--r-- 1 root root  6236316 823 2019 cpp-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root    33596 44 2020 elfutils-default-yama-scope-0.176-4.el7.noarch.rpm
-rw-r--r-- 1 root root   199264 44 2020 elfutils-libelf-0.176-4.el7.x86_64.rpm
-rw-r--r-- 1 root root    40632 44 2020 elfutils-libelf-devel-0.176-4.el7.x86_64.rpm
-rw-r--r-- 1 root root    77868 44 2020 elfutils-libelf-devel-static-0.176-4.el7.x86_64.rpm
-rw-r--r-- 1 root root   297776 44 2020 elfutils-libs-0.176-4.el7.x86_64.rpm
-rw-r--r-- 1 root root 16966352 823 2019 gcc-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root  7529552 823 2019 gcc-c++-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root  6983372 823 2019 gcc-gfortran-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root 13559304 823 2019 gcc-gnat-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root  6199712 823 2019 gcc-go-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root  6026156 823 2019 gcc-objc-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root  6447348 823 2019 gcc-objc++-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root   847636 823 2019 gcc-plugin-devel-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root  3815032 44 2020 glibc-2.17-307.el7.1.x86_64.rpm
-rw-r--r-- 1 root root 12057552 44 2020 glibc-common-2.17-307.el7.1.x86_64.rpm
-rw-r--r-- 1 root root  1126396 44 2020 glibc-devel-2.17-307.el7.1.x86_64.rpm
-rw-r--r-- 1 root root   705348 44 2020 glibc-headers-2.17-307.el7.1.x86_64.rpm
-rw-r--r-- 1 root root   287768 811 2017 gmp-6.0.0-15.el7.x86_64.rpm
-rw-r--r-- 1 root root   185500 811 2017 gmp-devel-6.0.0-15.el7.x86_64.rpm
-rw-r--r-- 1 root root  9389840 826 2020 kernel-headers-3.10.0-1127.19.1.el7.x86_64.rpm
-rw-r--r-- 1 root root    24744 625 2019 libaio-0.3.109-13.el7.x86_64.rpm
-rw-r--r-- 1 root root    13176 1125 2015 libaio-devel-0.3.109-13.el7.x86_64.rpm
-rw-r--r-- 1 root root   104736 823 2019 libgcc-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root   307596 823 2019 libgfortran-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root   989820 823 2019 libgnat-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root  2821040 823 2019 libgnat-devel-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root  2287136 823 2019 libgo-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root   235848 823 2019 libgo-devel-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root   161828 823 2019 libgomp-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root    51732 74 2014 libmpc-1.0.1-3.el7.x86_64.rpm
-rw-r--r-- 1 root root    32904 74 2014 libmpc-devel-1.0.1-3.el7.x86_64.rpm
-rw-r--r-- 1 root root    81836 823 2019 libobjc-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root   194380 823 2019 libquadmath-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root    54228 823 2019 libquadmath-devel-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root   312504 823 2019 libstdc++-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root  1580840 823 2019 libstdc++-devel-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root 11580600 823 2019 libstdc++-docs-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root   422504 823 2019 libstdc++-static-4.8.5-39.el7.x86_64.rpm
-rw-r--r-- 1 root root    50076 413 2017 libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm
-rw-r--r-- 1 root root    42784 823 2019 lm_sensors-libs-3.4.0-8.20160601gitf9185e5.el7.x86_64.rpm
-rw-r--r-- 1 root root   208316 74 2014 mpfr-3.1.1-4.el7.x86_64.rpm
-rw-r--r-- 1 root root    69904 74 2014 mpfr-devel-3.1.1-4.el7.x86_64.rpm
-rw-r--r-- 1 root root   210440 16 2019 pdksh-5.2.14-37.el7.centos.1.x86_64.rpm
-rw-r--r-- 1 root root   376916 16 2019 pdksh-debuginfo-5.2.14-37.el7.centos.1.x86_64.rpm
-rw-r--r-- 1 root root   323020 44 2020 sysstat-10.1.5-19.el7.x86_64.rpm
-rw-r--r-- 1 root root   423152 823 2019 unixODBC-2.3.1-14.el7.x86_64.rpm
-rw-r--r-- 1 root root    56144 823 2019 unixODBC-devel-2.3.1-14.el7.x86_64.rpm
-rw-r--r-- 1 root root    91960 1112 2018 zlib-1.2.7-18.el7.x86_64.rpm
-rw-r--r-- 1 root root    51128 1112 2018 zlib-devel-1.2.7-18.el7.x86_64.rpm

(2)安装rpm

[root@rac01 pack]# rpm -ivh --nodeps --force *.rpm
警告:compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:libgcc-4.8.5-39.el7              ################################# [  2%]
   2:glibc-common-2.17-307.el7.1      ################################# [  4%]
   3:glibc-2.17-307.el7.1             警告:/etc/nsswitch.conf 已建立为 /etc/nsswitch.conf.rpmnew 
################################# [  6%]
   4:zlib-1.2.7-18.el7                ################################# [  8%]
   5:libquadmath-4.8.5-39.el7         ################################# [ 10%]
   6:libstdc++-4.8.5-39.el7           ################################# [ 12%]
   7:gmp-1:6.0.0-15.el7               ################################# [ 14%]
   8:mpfr-3.1.1-4.el7                 ################################# [ 16%]
   9:libmpc-1.0.1-3.el7               ################################# [ 18%]
  10:gmp-devel-1:6.0.0-15.el7         ################################# [ 20%]
  11:mpfr-devel-3.1.1-4.el7           ################################# [ 22%]
  12:libstdc++-devel-4.8.5-39.el7     ################################# [ 24%]
  13:elfutils-libelf-0.176-4.el7      ################################# [ 25%]
  14:libgo-4.8.5-39.el7               ################################# [ 27%]
  15:libgo-devel-4.8.5-39.el7         ################################# [ 29%]
  16:libmpc-devel-1.0.1-3.el7         ################################# [ 31%]
  17:cpp-4.8.5-39.el7                 ################################# [ 33%]
  18:libgfortran-4.8.5-39.el7         ################################# [ 35%]
  19:zlib-devel-1.2.7-18.el7          ################################# [ 37%]
  20:elfutils-libelf-devel-0.176-4.el7################################# [ 39%]
  21:libaio-0.3.109-13.el7            ################################# [ 41%]
  22:libgnat-4.8.5-39.el7             ################################# [ 43%]
  23:libgomp-4.8.5-39.el7             ################################# [ 45%]
  24:libobjc-4.8.5-39.el7             ################################# [ 47%]
  25:libtool-ltdl-2.4.2-22.el7_3      ################################# [ 49%]
  26:unixODBC-2.3.1-14.el7            ################################# [ 51%]
  27:lm_sensors-libs-3.4.0-8.20160601g################################# [ 53%]
  28:libgnat-devel-4.8.5-39.el7       ################################# [ 55%]
  29:kernel-headers-3.10.0-1127.19.1.e################################# [ 57%]
  30:glibc-headers-2.17-307.el7.1     ################################# [ 59%]
  31:glibc-devel-2.17-307.el7.1       ################################# [ 61%]
  32:gcc-4.8.5-39.el7                 ################################# [ 63%]
  33:gcc-c++-4.8.5-39.el7             ################################# [ 65%]
  34:gcc-objc-4.8.5-39.el7            ################################# [ 67%]
  35:libquadmath-devel-4.8.5-39.el7   ################################# [ 69%]
  36:elfutils-default-yama-scope-0.176################################# [ 71%]
  37:elfutils-libs-0.176-4.el7        ################################# [ 73%]
  38:gcc-gfortran-4.8.5-39.el7        ################################# [ 75%]
  39:gcc-objc++-4.8.5-39.el7          ################################# [ 76%]
  40:gcc-gnat-4.8.5-39.el7            ################################# [ 78%]
  41:gcc-go-4.8.5-39.el7              ################################# [ 80%]
  42:gcc-plugin-devel-4.8.5-39.el7    ################################# [ 82%]
  43:sysstat-10.1.5-19.el7            ################################# [ 84%]
  44:unixODBC-devel-2.3.1-14.el7      ################################# [ 86%]
  45:libaio-devel-0.3.109-13.el7      ################################# [ 88%]
  46:elfutils-libelf-devel-static-0.17################################# [ 90%]
  47:libstdc++-static-4.8.5-39.el7    ################################# [ 92%]
  48:compat-libstdc++-33-3.2.3-72.el7 ################################# [ 94%]
  49:pdksh-5.2.14-37.el7.centos.1     ################################# [ 96%]
  50:pdksh-debuginfo-5.2.14-37.el7.cen################################# [ 98%]
  51:libstdc++-docs-4.8.5-39.el7      ################################# [100%]
3、将 grid 安装包上传到节点 rac01 的 grid 家目录
[root@rac01 ~]# su - grid

[grid@rac01 ~]$ pwd
/home/grid

[grid@rac01 ~]$ ll
total 1177004
-rw-r--r-- 1 grid oinstall 1205251894 Jan  7  2020 p13390677_112040_Linux-x86-64_3of7.zip
4、将 oracle 安装包上传到节点 rac01 的 oracle 家目录
[grid@rac01 ~]$ su - oracle

[oracle@rac01 ~]$ pwd
/home/oracle

[oracle@rac01 ~]$ ll
total 2487200
-rw-r--r-- 1 oracle oinstall 1395582860 Jan  7  2020 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r-- 1 oracle oinstall 1151304589 Jan  7  2020 p13390677_112040_Linux-x86-64_2of7.zip
5、解压缩 grid 软件包
[oracle@rac01 ~]$ su - grid

[grid@rac01 ~]$ unzip p13390677_112040_Linux-x86-64_3of7.zip
....

[grid@rac01 ~]$ pwd
/home/grid
[grid@rac01 ~]$ ll
total 1177004
drwxr-xr-x 7 grid oinstall        156 Aug 27  2013 grid
-rw-r--r-- 1 grid oinstall 1205251894 Jan  7  2020 p13390677_112040_Linux-x86-64_3of7.zip
6、安装 cvuqdisk-1.0.9-1.rpm 包(两个节点同时操作)

(1)在节点1rac01)执行如下操作:

# 使用 grid 用户执行如下操作
[grid@rac01 ~]$ cd /home/grid/grid/rpm

[grid@rac01 rpm]$ ll
total 12
-rw-r--r-- 1 grid oinstall 8288 Aug 26  2013 cvuqdisk-1.0.9-1.rpm

# 把 cvuqdisk-1.0.9-1.rpm 包复制到节点2
[grid@rac01 rpm]$ scp cvuqdisk-1.0.9-1.rpm grid@rac02:/home/grid/
cvuqdisk-1.0.9-1.rpm              100% 8288     8.1KB/s   00:00 

# 切换到 root 用户执行如下操作
[grid@rac01 rpm]$ su - root

# 安装 smartmontools
[root@rac01 smartmontools]# pwd
/home/soft/smartmontools

[root@rac01 smartmontools]# ll
总用量 796
-rw-r--r-- 1 root root 250776 425 2018 mailx-12.5-19.el7.x86_64.rpm
-rw-r--r-- 1 root root 559568 44 2020 smartmontools-7.0-2.el7.x86_64.rpm


[root@rac01 smartmontools]# rpm -ivh --nodeps --force *.rpm
警告:mailx-12.5-19.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mailx-12.5-19.el7                ################################# [ 50%]
   2:smartmontools-1:7.0-2.el7        ################################# [100%]

# 安装 cvuqdisk-1.0.9-1.rpm 包
[root@rac01 smartmontools]# cd /home/grid/grid/rpm

[root@rac01 rpm]# ll
总用量 12
-rw-r--r-- 1 grid oinstall 8288 826 2013 cvuqdisk-1.0.9-1.rpm

[root@rac01 rpm]# rpm -ivh cvuqdisk-1.0.9-1.rpm
准备中...                          ################################# [100%]
Using default group oinstall to install package
正在升级/安装...
   1:cvuqdisk-1.0.9-1                 ################################# [100%]

(2)在节点2rac02)执行如下操作:

# 切换到 root 用户执行如下操作
[grid@rac02 rpm]$ su - root

# 安装 smartmontools
[root@rac02 smartmontools]# pwd
/home/soft/smartmontools

[root@rac02 smartmontools]# ll
总用量 796
-rw-r--r-- 1 root root 250776 425 2018 mailx-12.5-19.el7.x86_64.rpm
-rw-r--r-- 1 root root 559568 44 2020 smartmontools-7.0-2.el7.x86_64.rpm

[root@rac02 smartmontools]# rpm -ivh --nodeps --force *.rpm
警告:mailx-12.5-19.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mailx-12.5-19.el7                ################################# [ 50%]
   2:smartmontools-1:7.0-2.el7        ################################# [100%]

# 安装 cvuqdisk-1.0.9-1.rpm 包
[root@rac02 smartmontools]# cd /home/grid

[root@rac02 grid]# ll
总用量 12
-rw-r--r-- 1 grid oinstall 8288 17 19:46 cvuqdisk-1.0.9-1.rpm

[root@rac02 grid]# rpm -ivh cvuqdisk-1.0.9-1.rpm
准备中...                          ################################# [100%]
Using default group oinstall to install package
正在升级/安装...
   1:cvuqdisk-1.0.9-1                 ################################# [100%]
7、执行以下命令(两个节点同时操作)
cd /lib64
ls -lrt libcap*
ln -s libcap.so.2.22 libcap.so.1
ls -lrt libcap*

# 执行结果如下:
[root@rac01 rpm]# cd /lib64

[root@rac01 lib64]# ls -lrt libcap*
-rwxr-xr-x. 1 root root 20024 610 2014 libcap.so.2.22
-rwxr-xr-x. 1 root root 23968 1120 2015 libcap-ng.so.0.0.0
lrwxrwxrwx. 1 root root    14 17 2025 libcap.so.2 -> libcap.so.2.22
lrwxrwxrwx. 1 root root    18 17 2025 libcap-ng.so.0 -> libcap-ng.so.0.0.0

[root@rac01 lib64]# ln -s libcap.so.2.22 libcap.so.1

[root@rac01 lib64]# ls -lrt libcap*
-rwxr-xr-x. 1 root root 20024 610 2014 libcap.so.2.22
-rwxr-xr-x. 1 root root 23968 1120 2015 libcap-ng.so.0.0.0
lrwxrwxrwx  1 root root    14 17 19:58 libcap.so.1 -> libcap.so.2.22
lrwxrwxrwx. 1 root root    14 17 2025 libcap.so.2 -> libcap.so.2.22
lrwxrwxrwx. 1 root root    18 17 2025 libcap-ng.so.0 -> libcap-ng.so.0.0.0
8、校验集群安装的可行性

在节点rac01上执行以下命令:

# 切换到 grid 用户
[root@rac01 lib64]# su - grid

[grid@rac01 ~]$ cd /home/grid/grid

[grid@rac01 grid]$ ll
total 52
drwxr-xr-x  4 grid oinstall   281 Aug 26  2013 install
-rw-r--r--  1 grid oinstall 30016 Aug 27  2013 readme.html
drwxr-xr-x  2 grid oinstall    30 Aug 26  2013 response
drwxr-xr-x  2 grid oinstall    34 Aug 26  2013 rpm
-rwxr-xr-x  1 grid oinstall  4878 Aug 26  2013 runcluvfy.sh
-rwxr-xr-x  1 grid oinstall  3268 Aug 26  2013 runInstaller
drwxr-xr-x  2 grid oinstall    29 Aug 26  2013 sshsetup
drwxr-xr-x 14 grid oinstall  4096 Aug 26  2013 stage
-rw-r--r--  1 grid oinstall   500 Aug 27  2013 welcome.html

# 校验集群安装的可行性
[grid@rac01 grid]$ ./runcluvfy.sh stage -pre crsinst -n rac01,rac02 -fixup -verbose

....
Pre-check for cluster services setup was unsuccessful on all the nodes. 

检测通过!

十四、安装 grid 软件

1、根据需要修改 grid 响应文件

(1)在节点1执行如下操作:

# 切换到 grid 用户
[root@rac01 ~]# su - grid

[grid@rac01 ~]$ cd /home/grid/grid/response

[grid@rac01 response]$ ll
total 28
-rw-r--r-- 1 grid oinstall 24632 Aug 26  2013 grid_install.rsp

[grid@rac01 response]$ cp grid_install.rsp grid_install.rsp.bak

(2)修改grid响应文件内容如下

[grid@rac01 response]$ vi grid_install.rsp

# 在grid_install.rsp文件中修改如下内容
oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v11_2_0

# 当前安装节点的计算机名称:rac01
ORACLE_HOSTNAME=rac01

# 版本信息路径:/u01/app/oraInventory
INVENTORY_LOCATION=/u01/app/oraInventory

#语言:en,zh_CN
SELECTED_LANGUAGES=en,zh_CN

#指定安装类型:使用默认(CRS_CONFIG——cluster 集群)
oracle.install.option=CRS_CONFIG

# grid 的 BASE目录:/u01/app/grid
ORACLE_BASE=/u01/app/grid

# grid 的 HOME 目录:/u01/app/11.2.0/grid
ORACLE_HOME=/u01/app/11.2.0/grid

# 设置组信息
oracle.install.asm.OSDBA=asmdba
oracle.install.asm.OSOPER=asmoper
oracle.install.asm.OSASM=asmadmin

# scan名称:rac-scan
oracle.install.crs.config.gpnp.scanName=rac-scan

# 集群监听端口号:1521
oracle.install.crs.config.gpnp.scanPort=1521

# cluster名称:rac-cluster
oracle.install.crs.config.clusterName=rac-cluster

# 不使用GNS:以下四个选项不用设置
oracle.install.crs.config.gpnp.configureGNS=false
oracle.install.crs.config.gpnp.gnsSubDomain=
oracle.install.crs.config.gpnp.gnsVIPAddress=
oracle.install.crs.config.autoConfigureClusterNodeVIP=

# 节点信息,跟hosts对应:rac01:rac01-vip,rac02:rac02-vip
oracle.install.crs.config.clusterNodes=rac01:rac01-vip,rac02:rac02-vip

# 网卡信息和网段:ens33:192.168.1.0:1,ens38:10.1.1.0:2
oracle.install.crs.config.networkInterfaceList=ens33:192.168.1.0:1,ens38:10.1.1.0:2

# 存储形式:ASM_STORAGE
oracle.install.crs.config.storageOption=ASM_STORAGE

# 不使用 FILE_SYSTEM_STORAGE,以下选项不用设置
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

# 不使用IPMI,以下选项不用设置
oracle.install.crs.config.useIPMI=false
oracle.install.crs.config.ipmi.bmcUsername=
oracle.install.crs.config.ipmi.bmcPassword=

#  配置 ASM 操作密码:oracle
oracle.install.asm.SYSASMPassword=oracle

# 配置 ASM 表决盘名称:OCR
oracle.install.asm.diskGroup.name=OCR

# 配置 ASM 表决盘冗余选项:NORMAL(默认值)
oracle.install.asm.diskGroup.redundancy=NORMAL

# 配置 ASM AUSize:1(默认值)
oracle.install.asm.diskGroup.AUSize=1

#  设置表决盘所使用的裸盘:
#  /dev/oracleasm/disks/OCR1,/dev/oracleasm/disks/OCR2,/dev/oracleasm/disks/OCR3
oracle.install.asm.diskGroup.disks=/dev/oracleasm/disks/OCR1,/dev/oracleasm/disks/OCR2,/dev/oracleasm/disks/OCR3

# 配置 ASM 磁盘位置:/dev/oracleasm/disks
oracle.install.asm.diskGroup.diskDiscoveryString=/dev/oracleasm/disks/*

# 配置 ASMSNMP 密码:oracle
oracle.install.asm.monitorPassword=oracle

# 设置系统自动更新选项:SKIP_UPDATES(跳过更新——不更新)
oracle.installer.autoupdates.option=SKIP_UPDATES

oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=

# 配置代理服务器选项:不使用代理服务器
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
2、开始安装 grid 软件

(1)运行安装脚本runInstaller

# 切换到 grid 用户
[grid@rac01 response]$ cd /home/grid/grid

[grid@rac01 grid]$ ll
total 52
drwxr-xr-x  4 grid oinstall   281 Aug 26  2013 install
-rw-r--r--  1 grid oinstall 30016 Aug 27  2013 readme.html
drwxr-xr-x  2 grid oinstall    58 Jan  7 20:20 response
drwxr-xr-x  2 grid oinstall    34 Aug 26  2013 rpm
-rwxr-xr-x  1 grid oinstall  4878 Aug 26  2013 runcluvfy.sh
-rwxr-xr-x  1 grid oinstall  3268 Aug 26  2013 runInstaller
drwxr-xr-x  2 grid oinstall    29 Aug 26  2013 sshsetup
drwxr-xr-x 14 grid oinstall  4096 Aug 26  2013 stage
-rw-r--r--  1 grid oinstall   500 Aug 27  2013 welcome.html

# 运行安装脚本`runInstaller
[grid@rac01 grid]$ ./runInstaller  -force -noconfig -IgnoreSysPreReqs -showProgress -ignorePrereq -silent -responseFile /home/grid/grid/response/grid_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 41317 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2047 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2025-01-07_08-28-21PM. Please wait ...[grid@rac01 grid]$ [WARNING] [INS-30011] The SYS password entered d
oes not conform to the Oracle recommended standards.   CAUSE: Oracle recommends that the 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 ASMSNMP password entered does not conform to the Oracle recommended standards.
   CAUSE: Oracle recommends that the 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.
You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2025-01-07_08-28-21PM.log

Prepare in progress.
..................................................   9% Done.

Prepare successful.

Copy files in progress.
..................................................   15% Done.
..................................................   20% Done.
..................................................   25% Done.
..................................................   30% Done.
..................................................   35% Done.
..................................................   40% Done.
..................................................   45% Done.
........................................
Copy files successful.

Link binaries in progress.

Link binaries successful.
..................................................   62% Done.

Setup files in progress.

Setup files successful.
..................................................   76% Done.

Perform remote operations in progress.
..................................................   89% Done.

Perform remote operations successful.
The installation of Oracle Grid Infrastructure 11g was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2025-01-07_08-28-21PM.log' for more details.
..................................................   94% Done.

Execute Root Scripts in progress.

As a root user, execute the following script(s):
	1. /u01/app/oraInventory/orainstRoot.sh
	2. /u01/app/11.2.0/grid/root.sh

Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes: 
[rac01, rac02]
Execute /u01/app/11.2.0/grid/root.sh on the following nodes: 
[rac01, rac02]

..................................................   100% Done.

Execute Root Scripts successful.
As install user, execute the following script to complete the configuration.
	1. /u01/app/11.2.0/grid/cfgtoollogs/configToolAllCommands RESPONSE_FILE=<response_file>

 	Note:
	1. This script must be run on the same host from where installer was run. 
	2. This script needs a small password properties file for configuration assistants that require passwords (refer to install guide documentation).


Successfully Setup Software.

(2)分别在节点rac01rac02上按顺序以root用户身份执行以下两个脚本

执行脚本:/u01/app/oraInventory/orainstRoot.sh

脚本的作用:修改目录的权限。

# 分别为节点1与节点2新开一个窗口,切换到root用户
# 节点1
[root@rac01 ~]# /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.


# 节点2
[root@rac02 ~]# /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.

执行脚本:/u01/app/11.2.0/grid/root.sh

脚本的作用:启动相关资源。

节点1

[root@rac01 ~]# /u01/app/11.2.0/grid/root.sh
Check /u01/app/11.2.0/grid/install/root_rac01_2025-01-07_20-41-04.log for the output of root script

上述脚本执行过程较长,执行过程中可以查看日志:/u01/app/11.2.0/grid/install/root_rac01_2025-01-07_20-41-04.log

[root@rac01 ~]# tail -f /u01/app/11.2.0/grid/install/root_rac01_2025-01-07_20-41-04.log

Creating /etc/oratab file...
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 script.
Now product-specific root actions will be performed.
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
Creating trace directory
User ignored Prerequisites during installation
Installing Trace File Analyzer
OLR initialization - successful
  root wallet
  root wallet cert
  root cert export
  peer wallet
  profile reader wallet
  pa wallet
  peer wallet keys
  pa wallet keys
  peer cert request
  pa cert request
  peer cert
  pa cert
  peer root cert TP
  profile reader root cert TP
  pa root cert TP
  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 Clusterware entries to inittab
ohasd failed to start
Failed to start the Clusterware. Last 20 lines of the alert log follow: 
2025-01-07 20:42:58.138: 
[client(11087)]CRS-2101:The OLR was formatted using version 3.

# 此处发生错误

CRS-2672: Attempting to start 'ora.mdnsd' on 'rac01'
CRS-2676: Start of 'ora.mdnsd' on 'rac01' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on 'rac01'
CRS-2676: Start of 'ora.gpnpd' on 'rac01' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'rac01'
CRS-2672: Attempting to start 'ora.gipcd' on 'rac01'
CRS-2676: Start of 'ora.cssdmonitor' on 'rac01' succeeded
CRS-2676: Start of 'ora.gipcd' on 'rac01' succeeded
CRS-2672: Attempting to start 'ora.cssd' on 'rac01'
CRS-2672: Attempting to start 'ora.diskmon' on 'rac01'
CRS-2676: Start of 'ora.diskmon' on 'rac01' succeeded
CRS-2676: Start of 'ora.cssd' on 'rac01' succeeded

已成功创建并启动 ASM。

已成功创建磁盘组OCR。

clscfg: -install mode specified
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4256: Updating the profile
Successful addition of voting disk 1963c3a4ad044f1cbf7c207ec954f642.
Successful addition of voting disk 8fb960ab3f964faebff98360b51177f1.
Successful addition of voting disk acb95f5dc1004f0dbf0129f353dbaeee.
Successfully replaced voting disk group with +OCR.
CRS-4256: Updating the profile
CRS-4266: Voting file(s) successfully replaced
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   1963c3a4ad044f1cbf7c207ec954f642 (/dev/oracleasm/disks/OCR1) [OCR]
 2. ONLINE   8fb960ab3f964faebff98360b51177f1 (/dev/oracleasm/disks/OCR2) [OCR]
 3. ONLINE   acb95f5dc1004f0dbf0129f353dbaeee (/dev/oracleasm/disks/OCR3) [OCR]
Located 3 voting disk(s).
CRS-2672: Attempting to start 'ora.asm' on 'rac01'
CRS-2676: Start of 'ora.asm' on 'rac01' succeeded
CRS-2672: Attempting to start 'ora.OCR.dg' on 'rac01'
CRS-2676: Start of 'ora.OCR.dg' on 'rac01' succeeded

# 脚本执行成功
Configure Oracle Grid Infrastructure for a Cluster ... succeeded

错误的排除:

# 新开一个窗口,以 root 用户执行以下命令:
cd /var/tmp/.oracle/
ll
rm npohasd -f
touch npohasd
chmod 755 npohasd
ll

[root@rac01 ~]# cd /var/tmp/.oracle/
[root@rac01 .oracle]# ll
总用量 0
prw-r--r-- 1 root root 0 17 20:43 npohasd

[root@rac01 .oracle]# rm npohasd -f

[root@rac01 .oracle]# touch npohasd

[root@rac01 .oracle]# chmod 755 npohasd

[root@rac01 .oracle]# ll
总用量 4
srwxr-xr-x 1 grid oinstall 0 17 20:49 mdnsd
-rw-r--r-- 1 grid oinstall 6 17 20:49 mdnsd.pid
-rwxr-xr-x 1 root root     0 17 20:47 npohasd
srwxrwxrwx 1 grid oinstall 0 17 20:49 ora_gipc_gipcd_rac01
-rw-r--r-- 1 grid oinstall 0 17 20:49 ora_gipc_gipcd_rac01_lock
srwxrwxrwx 1 grid oinstall 0 17 20:49 ora_gipc_GPNPD_rac01
-rw-r--r-- 1 grid oinstall 0 17 20:48 ora_gipc_GPNPD_rac01_lock
srwxrwxrwx 1 root root     0 17 20:51 ora_gipc_srac01gridrac-clusterCRFM_CLIIPC
-rw-r--r-- 1 root root     0 17 20:51 ora_gipc_srac01gridrac-clusterCRFM_CLIIPC_lock
srwxrwxrwx 1 root root     0 17 20:51 ora_gipc_srac01gridrac-clusterCRFM_SIPC
-rw-r--r-- 1 root root     0 17 20:51 ora_gipc_srac01gridrac-clusterCRFM_SIPC_lock
srwxrwxrwx 1 grid oinstall 0 17 20:49 sOCSSD_LL_rac01_
-rw-r--r-- 1 grid oinstall 0 17 20:48 sOCSSD_LL_rac01__lock
srwxrwxrwx 1 grid oinstall 0 17 20:51 sOCSSD_LL_rac01_rac-cluster
-rw-r--r-- 1 grid oinstall 0 17 20:48 sOCSSD_LL_rac01_rac-cluster_lock
srwxrwxrwx 1 root root     0 17 20:47 sOHASD_IPC_SOCKET_11
-rw-r--r-- 1 root root     0 17 20:47 sOHASD_IPC_SOCKET_11_lock
srwxrwxrwx 1 root root     0 17 20:47 sOHASD_UI_SOCKET
srwxrwxrwx 1 grid oinstall 0 17 20:51 sOracle_CSS_LclLstnr_rac-cluster_1
-rw-r--r-- 1 grid oinstall 0 17 20:48 sOracle_CSS_LclLstnr_rac-cluster_1_lock
srwxrwxrwx 1 root root     0 17 20:49 sprocr_local_conn_0_PROC
-rw-r--r-- 1 root root     0 17 20:49 sprocr_local_conn_0_PROC_lock
srwxrwxrwx 1 root root     0 17 20:47 sprocr_local_conn_0_PROL
-rw-r--r-- 1 root root     0 17 20:47 sprocr_local_conn_0_PROL_lock
srwxrwxrwx 1 root root     0 17 20:49 srac01DBG_CRSD
srwxrwxrwx 1 grid oinstall 0 17 20:49 srac01DBG_CSSD
srwxrwxrwx 1 root root     0 17 20:51 srac01DBG_CTSSD
srwxrwxrwx 1 grid oinstall 0 17 20:49 srac01DBG_GIPCD
srwxrwxrwx 1 grid oinstall 0 17 20:49 srac01DBG_GPNPD
srwxrwxrwx 1 root root     0 17 20:51 srac01DBG_LOGD
srwxrwxrwx 1 grid oinstall 0 17 20:49 srac01DBG_MDNSD
srwxrwxrwx 1 root root     0 17 20:51 srac01DBG_MOND
srwxrwxrwx 1 root root     0 17 20:47 srac01DBG_OHASD

节点2

[root@rac02 lib64]# /u01/app/11.2.0/grid/root.sh
Check /u01/app/11.2.0/grid/install/root_rac02_2025-01-07_20-54-50.log for the output of root script

上述脚本执行过程较长,执行过程中可以查看日志:/u01/app/11.2.0/grid/install/root_rac02_2025-01-07_20-54-50.log

[root@rac02 ~]# tail -f /u01/app/11.2.0/grid/install/root_rac02_2025-01-07_20-54-50.log

Creating /etc/oratab file...
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 script.
Now product-specific root actions will be performed.
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
Creating trace directory
User ignored Prerequisites during installation
Installing Trace File Analyzer
OLR initialization - successful
Adding Clusterware entries to inittab
ohasd failed to start
Failed to start the Clusterware. Last 20 lines of the alert log follow: 
2025-01-07 20:56:46.189: 
[client(9165)]CRS-2101:The OLR was formatted using version 3.

# 此处发生与节点1同样的错误,解决方法见节点1。

CRS-4402: The CSS daemon was started in exclusive mode but found an active CSS daemon on node rac01, number 1, and is terminating
An active cluster was found during exclusive startup, restarting to join the cluster

# 脚本执行成功
Configure Oracle Grid Infrastructure for a Cluster ... succeeded

(3)在节点rac01上执行下面的脚本

su - grid
cd /u01/app/11.2.0/grid/cfgtoollogs
ll
touch cfgrsp.properties
/u01/app/11.2.0/grid/cfgtoollogs/configToolAllCommands RESPONSE_FILE=/u01/app/11.2.0/grid/cfgtoollogs/cfgrsp.properties

[root@rac01 ~]# su - grid

[grid@rac01 ~]$ cd /u01/app/11.2.0/grid/cfgtoollogs

[grid@rac01 cfgtoollogs]$ ll
total 12
drwx------ 2 grid oinstall 4096 Jan  7 20:35 cfgfw
-rw------- 1 grid oinstall   74 Jan  7 20:35 CfmLogger_2025-01-07_08-35-10-PM.log
-rwx------ 1 grid oinstall  176 Jan  7 20:35 configToolAllCommands
-rwx------ 1 grid oinstall    0 Jan  7 20:35 configToolAllCommands.bak
drwxrwxr-x 2 grid oinstall  211 Jan  7 20:53 crsconfig
-rw------- 1 grid oinstall    0 Jan  7 20:35 oracle.assistants.asm_2025-01-07_08-35-10-PM.log
-rw------- 1 grid oinstall    0 Jan  7 20:35 oracle.assistants.netca.client_2025-01-07_08-35-10-PM.log
-rw------- 1 grid oinstall    0 Jan  7 20:35 oracle.crs_2025-01-07_08-35-10-PM.log
drwxr-xr-x 2 grid oinstall  332 Jan  7 20:35 oui
-rw------- 1 grid oinstall    0 Jan  7 20:35 OuiConfigVariables_2025-01-07_08-35-10-PM.log

[grid@rac01 cfgtoollogs]$ touch cfgrsp.properties

[grid@rac01 cfgtoollogs]$ /u01/app/11.2.0/grid/cfgtoollogs/configToolAllCommands RESPONSE_FILE=/u01/app/11.2.0/grid/cfgtoollogs/cfgrsp.properties
Setting the invPtrLoc to /u01/app/11.2.0/grid/oraInst.loc

perform - mode is starting for action: configure

perform - mode finished for action: configure

You can see the log file: /u01/app/11.2.0/grid/cfgtoollogs/oui/configActions2025-01-07_09-06-14-PM.log
4、查看 grid rac 状态
# 节点1:
[grid@rac01 cfgtoollogs]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac01       
ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac01       
ora.OCR.dg     ora....up.type ONLINE    ONLINE    rac01       
ora.asm        ora.asm.type   ONLINE    ONLINE    rac01       
ora.cvu        ora.cvu.type   ONLINE    ONLINE    rac01       
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    rac01       
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    rac01       
ora.ons        ora.ons.type   ONLINE    ONLINE    rac01       
ora....SM1.asm application    ONLINE    ONLINE    rac01       
ora....01.lsnr application    ONLINE    ONLINE    rac01       
ora.rac01.gsd  application    OFFLINE   OFFLINE               
ora.rac01.ons  application    ONLINE    ONLINE    rac01       
ora.rac01.vip  ora....t1.type ONLINE    ONLINE    rac01       
ora....SM2.asm application    ONLINE    ONLINE    rac02       
ora....02.lsnr application    ONLINE    ONLINE    rac02       
ora.rac02.gsd  application    OFFLINE   OFFLINE               
ora.rac02.ons  application    ONLINE    ONLINE    rac02       
ora.rac02.vip  ora....t1.type ONLINE    ONLINE    rac02       
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac01       

# 节点2:
[grid@rac02 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac01       
ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac01       
ora.OCR.dg     ora....up.type ONLINE    ONLINE    rac01       
ora.asm        ora.asm.type   ONLINE    ONLINE    rac01       
ora.cvu        ora.cvu.type   ONLINE    ONLINE    rac01       
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    rac01       
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    rac01       
ora.ons        ora.ons.type   ONLINE    ONLINE    rac01       
ora....SM1.asm application    ONLINE    ONLINE    rac01       
ora....01.lsnr application    ONLINE    ONLINE    rac01       
ora.rac01.gsd  application    OFFLINE   OFFLINE               
ora.rac01.ons  application    ONLINE    ONLINE    rac01       
ora.rac01.vip  ora....t1.type ONLINE    ONLINE    rac01       
ora....SM2.asm application    ONLINE    ONLINE    rac02       
ora....02.lsnr application    ONLINE    ONLINE    rac02       
ora.rac02.gsd  application    OFFLINE   OFFLINE               
ora.rac02.ons  application    ONLINE    ONLINE    rac02       
ora.rac02.vip  ora....t1.type ONLINE    ONLINE    rac02       
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac01       

十五、解决退格键乱码问题

安装readline-6.2rlwrap-0.37插件可以解决使用SQLplus时退格键和上下箭头键无法使用的问题。

1、安装 readline-6.2(两节点同时操作)

(1)上传软件,解压缩

# 切换到 root 用户
[grid@rac01 ~]$ su - root

[root@rac01 soft]# pwd
/home/soft

[root@rac01 soft]# ll
总用量 2232
drwxr-xr-x  2 root root     144 17 17:00 asm
drwxr-xr-x. 2 root root       6 17 15:36 cdr
drwxr-xr-x  2 root root     255 17 17:33 dns
drwxr-xr-x  2 root root    4096 17 19:23 pack
-rw-r--r--  1 root root 2277926 63 2021 readline-6.2.tar.gz
drwxr-xr-x  2 root root      84 17 19:50 smartmontools

# 解压缩软件
[root@rac01 soft]# tar zxvf readline-6.2.tar.gz

(2)编译、安装软件

[root@rac01 readline-6.2]# cd readline-6.2

# 编译、安装软件
[root@rac01 readline-6.2]# ./configure && make && make install
2、安装 libtermcap-devel (两节点同时操作)

(1)把安装包上传到服务器

[root@rac02 libtermcap-devel]# pwd
/home/soft/libtermcap-devel

[root@rac02 libtermcap-devel]# ll
总用量 1408
-rw-r--r-- 1 root root 310928 97 2017 ncurses-5.9-14.20130511.el7_4.x86_64.rpm
-rw-r--r-- 1 root root  69900 97 2017 ncurses-base-5.9-14.20130511.el7_4.noarch.rpm
-rw-r--r-- 1 root root 729508 97 2017 ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm
-rw-r--r-- 1 root root 323192 97 2017 ncurses-libs-5.9-14.20130511.el7_4.x86_64.rpm

(2)安装rpm

[root@rac02 libtermcap-devel]# rpm -ivh --force --nodeps *.rpm
警告:ncurses-5.9-14.20130511.el7_4.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:ncurses-base-5.9-14.20130511.el7_################################# [ 25%]
   2:ncurses-libs-5.9-14.20130511.el7_################################# [ 50%]
   3:ncurses-5.9-14.20130511.el7_4    ################################# [ 75%]
   4:ncurses-devel-5.9-14.20130511.el7################################# [100%]
3、安装 rlwrap-0.37(两节点同时操作)

(1)把软件rlwrap-0.37上传到服务器、解压缩

[root@rac02 soft]# pwd
/home/soft

[root@rac02 soft]# ll
总用量 2484
drwxr-xr-x  2 root root      144 17 17:00 asm
drwxr-xr-x. 2 root root        6 17 15:38 cdr
drwxr-xr-x  2 root root      111 17 18:05 dns
drwxr-xr-x  2 root root      240 17 21:27 libtermcap-devel
drwxr-xr-x  2 root root     4096 17 19:23 pack
drwxrwxr-x  6  286 wheel    4096 17 21:21 readline-6.2
-rw-r--r--  1 root root  2277926 63 2021 readline-6.2.tar.gz
-rw-r--r--  1 root root   251438 515 2019 rlwrap-0.37.tar.gz
drwxr-xr-x  2 root root       84 17 19:53 smartmontools

# 解压缩软件
[root@rac01 soft]# tar zxvf rlwrap-0.37.tar.gz

(2)编译、安装软件

[root@rac02 soft]# cd rlwrap-0.37

# 编译、安装软件
[root@rac02 rlwrap-0.37]# ./configure && make && make install

十五、安装 Oracle 软件

1、创建磁盘组

(1)在节点rac01创建两个磁盘组DATABAK

-- 创建磁盘组 data
create diskgroup data external redundancy disk '/dev/oracleasm/disks/DATA1';
--为磁盘组 data 添加磁盘
alter diskgroup data add disk '/dev/oracleasm/disks/DATA2';
-- 创建磁盘组 bak
create diskgroup bak external redundancy disk '/dev/oracleasm/disks/BAK1';
--为磁盘组 bak 添加磁盘
alter diskgroup bak add disk '/dev/oracleasm/disks/BAK2';

-- 切换到 grid 用户
[root@rac01 ~]# su - grid

[grid@rac01 ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.4.0 Production on Tue Jan 7 21:31:07 2025

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> create diskgroup data external redundancy disk '/dev/oracleasm/disks/DATA1';

Diskgroup created.

SQL> alter diskgroup data add disk '/dev/oracleasm/disks/DATA2';

Diskgroup altered.

SQL>  create diskgroup bak external redundancy disk '/dev/oracleasm/disks/BAK1';

Diskgroup created.

SQL> alter diskgroup bak add disk '/dev/oracleasm/disks/BAK2';

Diskgroup altered.

(2)查看磁盘组信息

SQL> select INST_ID,name,free_mb,state from gv$asm_diskgroup;

   INST_ID NAME 			     FREE_MB STATE
---------- ------------------------------ ---------- -----------
	 1 OCR					2146 MOUNTED
	 1 DATA 			       12236 MOUNTED
	 1 BAK				       12236 MOUNTED
	 2 OCR					2146 MOUNTED
	 2 BAK					   0 DISMOUNTED
	 2 DATA 				   0 DISMOUNTED

6 rows selected.

(3)在节点rac02上修改磁盘组的状态为mount

在添加了磁盘组后在另一个节点是处于unmount状态,所以需要在另一个节点将磁盘组设置为dismount状态。在个节点rac02上执行如下操作:

-- 把磁盘组 data 修改为 mount 状态
alter diskgroup data mount;

-- 把磁盘组 bak 修改为 mount 状态
alter diskgroup bak mount;
-- 切换为 grid 用户
[root@rac02 rlwrap-0.37]# su - grid

[grid@rac02 ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.4.0 Production on Tue Jan 7 21:36:53 2025

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> alter diskgroup data mount;

Diskgroup altered.

SQL> alter diskgroup bak mount;

Diskgroup altered.

(4)查看磁盘组信息

SQL> select INST_ID,name,free_mb,state from gv$asm_diskgroup;

   INST_ID NAME 			     FREE_MB STATE
---------- ------------------------------ ---------- -----------
	 1 OCR					2146 MOUNTED
	 1 DATA 			       12193 MOUNTED
	 1 BAK				       12193 MOUNTED
	 2 OCR					2146 MOUNTED
	 2 BAK				       12193 MOUNTED
	 2 DATA 			       12193 MOUNTED

6 rows selected.
2、修改 oracle 响应文件(只在节点1 执行)

(1)解压缩安装包

# 切换为 oracle 用户
[grid@rac01 ~]$ su - oracle

[oracle@rac01 ~]$ pwd
/home/oracle

# 查看 oracle 安装包
[oracle@rac01 ~]$ ll
total 2487200
-rw-r--r-- 1 oracle oinstall 1395582860 Jan  7  2020 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r-- 1 oracle oinstall 1151304589 Jan  7  2020 p13390677_112040_Linux-x86-64_2of7.zip

# 解压缩安装文件
[oracle@rac01 ~]$ unzip p13390677_112040_Linux-x86-64_1of7.zip 
[oracle@rac01 ~]$ unzip p13390677_112040_Linux-x86-64_2of7.zip 

[oracle@rac01 ~]$ ll
total 2487200
drwxr-xr-x 7 oracle oinstall        136 Aug 27  2013 database
-rw-r--r-- 1 oracle oinstall 1395582860 Jan  7  2020 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r-- 1 oracle oinstall 1151304589 Jan  7  2020 p13390677_112040_Linux-x86-64_2of7.zip

(2)修改oracle响应文件

# 查看响应文件
[oracle@rac01 ~]$ cd ./database/response

[oracle@rac01 response]$ ll
total 80
-rwxr-xr-x 1 oracle oinstall 44533 Aug 27  2013 dbca.rsp
-rw-r--r-- 1 oracle oinstall 25116 Aug 27  2013 db_install.rsp
-rwxr-xr-x 1 oracle oinstall  5871 Aug 27  2013 netca.rsp

# 备份响应文件
[oracle@rac01 response]$ cp db_install.rsp db_install.rsp.bak

# 修改响应文件
[oracle@rac01 response]$ vi db_install.rsp

(3)响应文件db_install.rsp需要修改的内容如下:

# 标注响应文件版本(不要修改)
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0

# 选择安装类型:INSTALL_DB_SWONLY(只安装数据库软件 )
oracle.install.option=INSTALL_DB_SWONLY

# 指定主机名:rac01
ORACLE_HOSTNAME=rac01

#指定oracle inventory目录的所有者:oinstall
UNIX_GROUP_NAME=oinstall

#指定产品清单oracle inventory目录的路径:/u01/app/oraInventory
INVENTORY_LOCATION=/u01/app/oraInventory

#指定数据库语言:en,zh_CN
SELECTED_LANGUAGES=en,zh_CN

# 设置ORALCE_HOME的路径:/u01/app/oracle/product/11.2.0/db_1
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

#  设置ORALCE_BASE的路径:/u01/app/oracle
ORACLE_BASE=/u01/app/oracle

#选择Oracle安装数据库软件的版本:EE(企业版)
oracle.install.db.InstallEdition=EE

# 是否自定义Oracle的组件:false(安装默认组件)
oracle.install.db.EEOptionsSelection=false

# 要安装的组件列表(不要修改)
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0

#指定拥有OSDBA权限的用户组:dba
oracle.install.db.DBA_GROUP=dba

#指定拥有OSOPER权限的用户组:oinstall
oracle.install.db.OPER_GROUP=oinstall

#指定要安装oracle软件的节点:rac01,rac02
oracle.install.db.CLUSTER_NODES=rac01,rac02

# 是否安装单节点rac:false
oracle.install.db.isRACOneInstall=

# 安装单节点rac的服务名称
oracle.install.db.racOneServiceName=

#选择数据库的用途:GENERAL_PURPOSE(一般用途/事务处理)
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE

# 指定数据库的GlobalName(全局名称):不创建数据库,不用设置
oracle.install.db.config.starterdb.globalDBName=

# 指定数据库的SID:不创建数据库,不用设置
oracle.install.db.config.starterdb.SID=

#选择字符集:AL32UTF8
oracle.install.db.config.starterdb.characterSet=AL32UTF8

#11g的新特性:自动内存管理:true
oracle.install.db.config.starterdb.memoryOption=true

#指定Oracle自动管理内存的大小:800MB
oracle.install.db.config.starterdb.memoryLimit=800

#是否载入模板示例:false
oracle.install.db.config.starterdb.installExampleSchemas=false

#是否启用安全设置:true
oracle.install.db.config.starterdb.enableSecuritySettings=true

#设置数据库用户密码
#设定所有数据库用户使用同一个密码,其它数据库用户就不用单独设置了。
oracle.install.db.config.starterdb.password.ALL=oracle

#设定SYS用户的密码:不用设定,统一使用 oracle 作为密码
oracle.install.db.config.starterdb.password.SYS=

#设定SYSTEM用户的密码:不用设定,统一使用 oracle 作为密码
oracle.install.db.config.starterdb.password.SYSTEM=

#设定SYSMAN用户的密码:不用设定,统一使用 oracle 作为密码
oracle.install.db.config.starterdb.password.SYSMAN=

#设定DBSNMP用户的密码:不用设定,统一使用 oracle 作为密码
oracle.install.db.config.starterdb.password.DBSNMP=

# 使用数据库本地管理工具:DB_CONTROL
oracle.install.db.config.starterdb.control=DB_CONTROL

#当上一个选项设置为GRID_CONTROL时,才需要设定grid control的远程路径URL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=

# 设置自动备份:false
oracle.install.db.config.starterdb.automatedBackup.enable=false

# 不是自动备份:不用设置
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=

#指定存储类型:ASM_STORAGE
oracle.install.db.config.starterdb.storageType=ASM_STORAGE

# 不使用文件系统:不用设置
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=

#指定ASM的磁盘组:DATA
oracle.install.db.config.asm.diskGroup=DATA

#指定ASM实例密码:oracle
oracle.install.db.config.asm.ASMSNMPPassword=oracle

# 不使用metalink账户:不用设置
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=

# 是否设置安全更新
# False表示不需要设置安全更新,在11.2的静默安装中必须指定为true,否则会提示错误
DECLINE_SECURITY_UPDATES=true

# 不使用代理服务器,不用设置
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=

# 自动更新:SKIP_UPDATES
oracle.installer.autoupdates.option=SKIP_UPDATES

# 不使用自动:不用设置
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
3、开始安装 oracle 软件

(1)查看文件inventory.xml中是否有CRS="true"

[oracle@rac01 response]$ cd /u01/app/oraInventory/ContentsXML

[oracle@rac01 ContentsXML]$ ll
total 12
-rw-rw---- 1 grid oinstall 329 Jan  7 21:06 comps.xml
-rw-rw---- 1 grid oinstall 571 Jan  7 21:06 inventory.xml
-rw-rw---- 1 grid oinstall 292 Jan  7 21:06 libs.xml
[oracle@rac01 ContentsXML]$ 
[oracle@rac01 ContentsXML]$ 
[oracle@rac01 ContentsXML]$ vi inventory.xml

<?xml version="1.0" standalone="yes" ?>
<!-- Copyright (c) 1999, 2013, Oracle and/or its affiliates.
All rights reserved. -->
<!-- Do not modify the contents of this file by hand. -->
<INVENTORY>
<VERSION_INFO>
   <SAVED_WITH>11.2.0.4.0</SAVED_WITH>
   <MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>
</VERSION_INFO>
<HOME_LIST>
# =========================================================================================
<!--<HOME NAME="Ora11g_gridinfrahome1" LOC="/u01/app/11.2.0/grid" TYPE="O" IDX="1">-->
<HOME NAME="Ora11g_gridinfrahome1" LOC="/u01/app/11.2.0/grid" TYPE="O" IDX="1" CRS="true">
# =========================================================================================
   <NODE_LIST>
      <NODE NAME="rac01"/>
      <NODE NAME="rac02"/>
   </NODE_LIST>
</HOME>
</HOME_LIST>
<COMPOSITEHOME_LIST>
</COMPOSITEHOME_LIST>
</INVENTORY>

(2)执行runInstaller命令开始安装oracle

[grid@rac01 ~]$ su - oracle

[oracle@rac01 ~]$ cd ~/database

[oracle@rac01 database]$ ll
total 44
drwxr-xr-x  4 oracle oinstall   248 Aug 27  2013 install
-rw-r--r--  1 oracle oinstall 30016 Aug 27  2013 readme.html
drwxr-xr-x  2 oracle oinstall    87 Jan  7 21:58 response
drwxr-xr-x  2 oracle oinstall    34 Aug 27  2013 rpm
-rwxr-xr-x  1 oracle oinstall  3267 Aug 27  2013 runInstaller
drwxr-xr-x  2 oracle oinstall    29 Aug 27  2013 sshsetup
drwxr-xr-x 14 oracle oinstall  4096 Aug 27  2013 stage
-rw-r--r--  1 oracle oinstall   500 Aug 27  2013 welcome.html

# 执行 runInstaller 命令开始安装 oracle
[oracle@rac01 database]$ ./runInstaller -showProgress -ignorePrereq -silent -responseFile /home/oracle/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 34799 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2041 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2025-01-07_10-08-05PM. Please wait ...[oracle@rac01 database]$ You can find the log of this install sessi
on at: /u01/app/oraInventory/logs/installActions2025-01-07_10-08-05PM.log

Prepare in progress.
..................................................   9% Done.

Prepare successful.

Copy files in progress.
..................................................   14% Done.
..................................................   19% Done.
..................................................   25% Done.
..................................................   30% Done.
..................................................   36% Done.
..................................................   41% Done.
..................................................   46% Done.
..................................................   51% Done.
..................................................   56% Done.

Copy files successful.
..........
Link binaries in progress.

Link binaries successful.
..................................................   77% Done.

Setup files in progress.
..................................................   94% Done.

Setup files successful.
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2025-01-07_10-08-05PM.log' for more details.

Execute Root Scripts in progress.

As a root user, execute the following script(s):
	1. /u01/app/oracle/product/11.2.0/db_1/root.sh

Execute /u01/app/oracle/product/11.2.0/db_1/root.sh on the following nodes: 
[rac01, rac02]

..................................................   100% Done.

Execute Root Scripts successful.
Successfully Setup Software.

(3)切换到root用户,在节点rac01rac02 执行以下脚本

[grid@rac01 grid]$ su - root

[root@rac01 ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh
Check /u01/app/oracle/product/11.2.0/db_1/install/root_rac01_2025-01-07_22-25-42.log for the output of root script
4、查看集群状态
[root@rac01 ~]# su - grid

[grid@rac01 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.BAK.dg     ora....up.type ONLINE    ONLINE    rac01       
ora.DATA.dg    ora....up.type ONLINE    ONLINE    rac01       
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac01       
ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac01       
ora.OCR.dg     ora....up.type ONLINE    ONLINE    rac01       
ora.asm        ora.asm.type   ONLINE    ONLINE    rac01       
ora.cvu        ora.cvu.type   ONLINE    ONLINE    rac01       
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    rac01       
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    rac01       
ora.ons        ora.ons.type   ONLINE    ONLINE    rac01       
ora....SM1.asm application    ONLINE    ONLINE    rac01       
ora....01.lsnr application    ONLINE    ONLINE    rac01       
ora.rac01.gsd  application    OFFLINE   OFFLINE               
ora.rac01.ons  application    ONLINE    ONLINE    rac01       
ora.rac01.vip  ora....t1.type ONLINE    ONLINE    rac01       
ora....SM2.asm application    ONLINE    ONLINE    rac02       
ora....02.lsnr application    ONLINE    ONLINE    rac02       
ora.rac02.gsd  application    OFFLINE   OFFLINE               
ora.rac02.ons  application    ONLINE    ONLINE    rac02       
ora.rac02.vip  ora....t1.type ONLINE    ONLINE    rac02       
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac01       

十六、创建数据库

1、修改建库使用的响应文件

(1)查看oracle用户的环境变量

[grid@rac01 ~]$ su - oracle
Password: 
Last login: Tue Jan  7 22:06:35 CST 2025 on pts/1
[oracle@rac01 ~]$ vi .bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH


export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_OWNER=oracle
export ORACLE_SID=ora1   # 实例名
export ORACLE_TERM=vt100
export THREADS_FLAG=native
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
export EDITOR=vi
export SQLPATH=/home/oracle
export LANG=en_US
alias sqlplus='rlwrap sqlplus'
alias lsnrctl='rlwrap lsnrctl'
alias rman='rlwrap rman'
alias dgmgrl='rlwrap dgmgrl'

(2)修改响应文件

[oracle@rac01 ~]$ cd /home/oracle/database/response

# 备份响应文件
[oracle@rac01 response]$ cp dbca.rsp dbca.rsp.bak

# 查看响应文件
[oracle@rac01 response]$ ll
total 152
-rwxr-xr-x 1 oracle oinstall 44533 Aug 27  2013 dbca.rsp
-rwxr-xr-x 1 oracle oinstall 44533 Jan  7 22:31 dbca.rsp.bak
-rw-r--r-- 1 oracle oinstall 25309 Jan  7 21:58 db_install.rsp
-rw-r--r-- 1 oracle oinstall 25116 Jan  7 21:47 db_install.rsp.bak
-rwxr-xr-x 1 oracle oinstall  5871 Aug 27  2013 netca.rsp

# 修改响应文件
[oracle@rac01 response]$ vi dbca.rsp

(3)响应文件dbca.rsp的内容如下

# 响应文件的版本号,不要修改
RESPONSEFILE_VERSION = "11.2.0"

# 操作类型:createDatabase(创建数据库)
OPERATION_TYPE = "createDatabase"

# 全局数据库名
GDBNAME = "hisdb"

# 是否创建单节点 rac:false
RACONENODE  = "false"

# 指定数据库的 SID:ora,和 oracle 用户环境变量中的 ORACLE_SID 必须一致
SID = "ora"

# 逗号分隔的群集节点列表:rac01,rac02
NODELIST = "rac01,rac02"

# 数据库模板的名称:General_Purpose.dbc(默认值)
TEMPLATENAME = "General_Purpose.dbc"

##设置 sys 账户的密码
SYSPASSWORD = "oracle"

##设置 system 账户的密码
SYSTEMPASSWORD = "oracle"

# 数据库文件的位置:+DATA
DATAFILEDESTINATION = "+DATA"

# 恢复区的位置:+BAK
RECOVERYAREADESTINATION= "+BAK"

# 指定要创建的数据库的存储类型:ASM(自动存储管理)
STORAGETYPE = "ASM"

# 指定存储的磁盘组名称:DATA
DISKGROUPNAME = "DATA"

# 指定恢复区磁盘组名称:BAK
RECOVERYGROUPNAME = "BAK"

# 数据库字符集:AL32UTF8
CHARACTERSET = "AL32UTF8"

# 数据库国家字符集:AL32UTF8
NATIONALCHARACTERSET= "AL32UTF8"

## 监听名称
LISTENERS = "LISTENER LISTENER_SCAN1"

# oracle所占物理内存百分比:50%
MEMORYPERCENTAGE = "50"

# 数据库类型:MULTIPURPOSE(多用途)
DATABASETYPE = "MULTIPURPOSE"

# 是否启用自动内存管理:TRUE
AUTOMATICMEMORYMANAGEMENT = "TRUE"

# 分配给oracle数据库的总内存:800MB
TOTALMEMORY = "800"
2、使用 dbca 命令创建数据库
[oracle@rac01 response]$ cd /u01/app/oracle/product/11.2.0/db_1/bin

[oracle@rac01 bin]$ ll dbca
-rwxr-xr-x 1 oracle oinstall 6314 Jan  7 22:16 dbca

# 使用 dbca 命令创建数据库
[oracle@rac01 bin]$ dbca -silent -responseFile /home/oracle/database/response/dbca.rsp
Copying database files
1% complete
2% complete
4% complete
35% complete
Creating and starting Oracle instance
38% complete
43% complete
47% complete
48% complete
52% complete
53% complete
54% complete
57% complete
58% complete
Registering database with Oracle Restart
64% complete
Completing Database Creation
68% complete
71% complete
75% complete
86% complete
87% complete
97% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/hisdb/hisdb.log" for further details.

3、查看 grid 集群状态
[grid@rac01 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.BAK.dg     ora....up.type ONLINE    ONLINE    rac01       
ora.DATA.dg    ora....up.type ONLINE    ONLINE    rac01       
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac01       
ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac01       
ora.OCR.dg     ora....up.type ONLINE    ONLINE    rac01       
ora.asm        ora.asm.type   ONLINE    ONLINE    rac01       
ora.cvu        ora.cvu.type   ONLINE    ONLINE    rac01       
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora.hisdb.db   ora....se.type ONLINE    OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    rac01       
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    rac01       
ora.ons        ora.ons.type   ONLINE    ONLINE    rac01       
ora....SM1.asm application    ONLINE    ONLINE    rac01       
ora....01.lsnr application    ONLINE    ONLINE    rac01       
ora.rac01.gsd  application    OFFLINE   OFFLINE               
ora.rac01.ons  application    ONLINE    ONLINE    rac01       
ora.rac01.vip  ora....t1.type ONLINE    ONLINE    rac01       
ora....SM2.asm application    ONLINE    ONLINE    rac02       
ora....02.lsnr application    ONLINE    ONLINE    rac02       
ora.rac02.gsd  application    OFFLINE   OFFLINE               
ora.rac02.ons  application    ONLINE    ONLINE    rac02       
ora.rac02.vip  ora....t1.type ONLINE    ONLINE    rac02       
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac01      

http://www.kler.cn/a/471202.html

相关文章:

  • vue-codemirror定位光标位置并在光标处插入信息
  • 嵌入式中QT实现文本与线程控制方法
  • Hbuilder ios 离线打包sdk版本4.36,HbuilderX 4.36生成打包资源 问题记录
  • Android Telephony | 协议测试针对 test SIM attach network 的问题解决(3GPP TS 36523-1-i60)
  • 【学习笔记】数据结构(十)
  • 51单片机(二)中断系统与外部中断实验
  • 在DVWA靶机从渗透到控制(weevely和中国蚁剑)
  • Taro地图组件和小程序定位
  • 十五、Vue 响应接口
  • [大模型开源]SecGPT 网络安全大模型
  • java调用外部API,通过http请求,HttpGet和HttpPost方式实现
  • Elixir语言的正则表达式
  • HDFS异构存储和存储策略
  • 51单片机——步进电机模块
  • 使用 SAML 2.0协议需要注意的安全问题
  • .net core 线程锁,互斥锁,自旋锁,混合锁
  • shell-条件判断
  • iOS - 线程与AutoreleasePoolPage
  • 全覆盖路径规划算法之BCD源码实现(The Boustrophedon Cellular Decomposition)
  • linux下多个硬盘划分到同一挂载点
  • 电子应用设计方案87:智能AI收纳箱系统设计
  • SSR 【1】【nuxt安装】
  • pytorch torch.full_like函数介绍
  • 主板疑难杂症之解析(Analysis of Difficult and Miscellaneous Problems of Motherboard)
  • LogMiner
  • 【shell编程】报错信息:bash: bad file descriptor(包含6种解决方法)