具体规划如下:
节点 | 操作系统 | 实例名 | Grid/Oralce版本 | 内存 | SWAP | Public IP | Private IP | Virtual IP | Scan IP |
---|---|---|---|---|---|---|---|---|---|
1 | Oracle Linux 7.4 | myrac1 | 19.14.0.0 | 16G | 16G | 192.168.15.101 | 1.1.1.1 | 192.168.15.103 | 192.168.15.100 |
2 | Oracle Linux 7.4 | myrac2 | 19.14.0.0 | 16G | 16G | 192.168.15.102 | 1.1.1.2 | 192.168.15.104 | 192.168.15.100 |
本文涉及的安装包,如果找不到资源,我也放网盘来供下载:
链接:https://pan.baidu.com/s/1nyW2Oj0Vs_wpHXLfGFkTXQ
提取码:4yhg
myrac1
和 myrac2
myrac-cluster
主机名 | 网卡名 | IP |
---|---|---|
myrac1 | ens33 | 192.168.15.101 |
myrac1 | ens36 | 1.1.1.1 |
myrac2 | ens33 | 192.168.15.103 |
myrac2 | ens36 | 1.1.1.2 |
#Public IP(公司内部访问,非外网)
192.168.15.101 myrac1
192.168.15.102 myrac2
#Private IP(用于节点间心跳网络)
1.1.1.1 myrac1-priv
1.1.1.2 myrac2-priv
#Virtual IP(提供客户端访问,漂移)
192.168.15.103 myrac1-vip
192.168.15.104 myrac2-vip
#SCAN IP(提供客户端访问,均衡)
192.168.15.100 myrac-scan
磁盘名称 | 磁盘用途 | 磁盘大小 |
---|---|---|
asm-ocr | OCR/Voting File | 10G |
asm-data | Data Files | 20G |
安装 Oracle Linux 7.4,主要注意几个点:
(1)内存与swap的大小关系,本测试中内存与SWAP大小一致,均为16G(需要添加SWAP,可参考 linux中增加swap分区文件的步骤方法)
(2)升级 kernel-uek,yum install -y kernel-uek
(1)修改 host
修改 /etc/hosts
,添加以下内容
#Public IP
192.168.15.101 myrac1
192.168.15.102 myrac2
#Private IP
1.1.1.1 myrac1-priv
1.1.1.2 myrac2-priv
#Virtual IP
192.168.15.103 myrac1-vip
192.168.15.104 myrac2-vip
#SCAN IP
192.168.15.100 myrac-scan
(2)网卡设置:
主机名 | 网卡名 | IP |
---|---|---|
myrac1 | ens33 | 192.168.15.101 |
myrac1 | ens36 | 1.1.1.1 |
myrac2 | ens33 | 192.168.15.103 |
myrac2 | ens36 | 1.1.1.2 |
rac1:
方法1:直接修改网卡配置文件,如下所示
[root@myrac1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=3edeedc9-11c8-42b4-863f-509b5cadaaa6
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.15.101
GATEWAY=192.168.15.2
NETMASK=255.255.255.0
DNS1=114.114.114.114
PREFIX=24
[root@myrac1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens36
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=1.1.1.1
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens36
UUID=9c8ef42a-711d-4295-8d27-61c1d56426ad
DEVICE=ens36
ONBOOT=yes
[root@myrac1 ~]# service network restart
Restarting network (via systemctl): [ 确定 ]
[root@myrac1 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.15.101 netmask 255.255.255.0 broadcast 192.168.15.255
inet6 fe80::31b5:2f37:bb9a:d359 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:ec:2e:78 txqueuelen 1000 (Ethernet)
RX packets 95 bytes 7445 (7.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 187 bytes 23670 (23.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 1.1.1.1 netmask 255.255.255.0 broadcast 1.1.1.255
inet6 fe80::1879:4050:9785:a430 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:ec:2e:82 txqueuelen 1000 (Ethernet)
RX packets 79 bytes 9860 (9.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 30 bytes 2202 (2.1 KiB)
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 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
方法2:命令修改
hostnamectl set-hostname myrac1
nmcli connection add con-name ens36 type ethernet ifname ens36
nmcli connection modify ens36 ipv4.addresses 1.1.1.2/24 ipv4.method manual autoconnect yes
rac2:与rac1设置类型,修改IP即可,略
(3)修改 hostname
修改 /etc/hostname
,或者执行以下语句设置 hostname
## rac1 下执行
hostnamectl set-hostname myrac1
##rac2 下执行
hostnamectl set-hostname myrac2
安装Oracle 提供的 yum install -y oracle-database-preinstall-19c
,自动安装本次必要的包,以及创建用户组,用户,系统参数设置等,会比较方便。
安装完后,检查是否有遗漏,这里我是中文环境,所以 grep | 未安装
,因为可以相应改成 grep | "not installed"
[root@myrac1 ~]# rpm -q bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ elfutils-libelf elfutils-libelf-devel glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libxcb libX11 libXau libXi libXtst libXrender libXrender-devel make net-tools nfs-utils smartmontools sysstat e2fsprogs e2fsprogs-libs fontconfig-devel expect unzip openssh-clients readline kmod kmod-libs policycoreutils-python | grep 未安装
未安装软件包 compat-libstdc++-33
未安装软件包 gcc
未安装软件包 gcc-c++
未安装软件包 elfutils-libelf-devel
未安装软件包 libXrender-devel
未安装软件包 fontconfig-devel
未安装软件包 expect
未安装软件包 kmod
未安装软件包 kmod-libs
未安装软件包 policycoreutils-python
[root@rac1 ~]# yum install -y compat-libstdc++-33 gcc gcc-c++ elfutils-libelf-devel libXrender-devel fontconfig-devel expect kmod kmod-libs policycoreutils-python
创建用户和用户组,如果安装了 oracle-database-preinstall-19c
,oracle以及部分组名会已存在,可忽略警告。
## 创建用户组并指定组ID(涉及多个节点,需要保证每个节点的组ID和用户ID一致)
groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
groupadd -g 54324 backupdba
groupadd -g 54325 dgdba
groupadd -g 54326 kmdba
groupadd -g 54327 asmdba
groupadd -g 54328 asmoper
groupadd -g 54329 asmadmin
groupadd -g 54330 racdba
## 创建用户,并指定用户ID,所属的用户组以及所属的附加组
useradd -u 54321 -g oinstall -G asmdba,dba,backupdba,dgdba,kmdba,racdba,oper oracle
useradd -u 54322 -g oinstall -G asmadmin,asmdba,asmoper,dba,racdba,oper grid
## 如果用户已存在,可以用以下语句更新用户组信息(oracle-database-preinstall-19c会自动创建用户oracle)
usermod -g oinstall -G asmdba,dba,backupdba,dgdba,kmdba,racdba,oper oracle
##修改用户密码为oracle
echo "oracle" | passwd oracle --stdin
echo "oracle" | passwd grid --stdin
##查看用户
id grid
id oracle
本地 Windows 设置共享存储设备可以参考这篇文章 一步步教你Windows配置ISCSI共享存储(StarWind)
(1)连接共享存储
##安装 iscsi
[root@myrac1 ~]# yum install -y iscsi-initiator-utils*
##输出targetname,192.168.31.210 为 iscsi 共享存储设备IP地址
[root@myrac1 ~]# iscsiadm -m discovery -t st -p 192.168.31.210
192.168.31.210:3260,-1 iqn.2008-08.com.starwindsoftware:192.168.31.210-rac
##连接共享存储
[root@myrac1 ~]# iscsiadm -m node -T iqn.2008-08.com.starwindsoftware:192.168.31.210-rac -p 192.168.31.210 -l
Logging in to [iface: default, target: iqn.2008-08.com.starwindsoftware:192.168.31.210-rac, portal: 192.168.31.210,3260] (multiple)
Login to [iface: default, target: iqn.2008-08.com.starwindsoftware:192.168.31.210-rac, portal: 192.168.31.210,3260] successful.
##此时查看磁盘信息,发现已经能显示刚刚添加的共享盘了
[root@myrac1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1T 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 1023G 0 part
├─ol-root 249:0 0 957G 0 lvm /
├─ol-swap 249:1 0 16G 0 lvm [SWAP]
└─ol-home 249:2 0 50G 0 lvm /home
sdb 8:16 0 10G 0 disk
sdc 8:32 0 10G 0 disk
sdd 8:48 0 10G 0 disk
sde 8:64 0 20G 0 disk
sdf 8:80 0 20G 0 disk
sdg 8:96 0 20G 0 disk
sr0 11:0 1 1024M 0 rom
(2)安装 multipath
绑定多路径
[root@myrac1 ~]# yum install -y device-mapper device-mapper-multipath-devel
# 启用 multipath
[root@myrac1 ~]# mpathconf --enable --with_multipathd y
#查看共享盘 scsi_id
[root@myrac1 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdb
291ce6d081d202469
[root@myrac1 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdc
22c4c20c46a08fbdb
[root@myrac1 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdd
249f0d172705acd42
[root@myrac1 ~]# /usr/lib/udev/scsi_id -g -u /dev/sde
28f789b7e25a42b5d
[root@myrac1 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdf
2be2b31c313ff46fe
[root@myrac1 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdg
2979a5ea9e0028764
##配置 multipath 文件,其中wwid即上面 /usr/lib/udev/scsi_id -g -u /dev/sd* 的结果
[root@rac1 ~]# cat </etc/multipath.conf
defaults {
user_friendly_names yes
}
blacklist {
devnode "^sda"
}
multipaths {
multipath {
wwid "291ce6d081d202469"
alias asm_ocr1
}
multipath {
wwid "22c4c20c46a08fbdb"
alias asm_ocr2
}
multipath {
wwid "249f0d172705acd42"
alias asm_ocr3
}
multipath {
wwid "28f789b7e25a42b5d"
alias asm_data1
}
multipath {
wwid "2be2b31c313ff46fe"
alias asm_data2
}
multipath {
wwid "2979a5ea9e0028764"
alias asm_data3
}
}
EOF
(3)激活multipath多路径:
[root@myrac1 ~]# multipath -F
[root@myrac1 ~]# multipath -v2
## 显示multipath结果
[root@myrac1 ~]# multipath -ll
asm_ocr2 (28e46a515456bc1a9) dm-4 ROCKET ,IMAGEFILE
size=10G features='0' hwhandler='0' wp=rw
`-+- policy='service-time 0' prio=1 status=enabled
`- 3:0:0:1 sdc 8:32 active ready running
asm_ocr1 (2da9eac16601b69f3) dm-3 ROCKET ,IMAGEFILE
size=10G features='0' hwhandler='0' wp=rw
`-+- policy='service-time 0' prio=1 status=enabled
`- 3:0:0:0 sdb 8:16 active ready running
asm_data3 (25fe5d1e4cd6bbddf) dm-8 ROCKET ,IMAGEFILE
size=20G features='0' hwhandler='0' wp=rw
`-+- policy='service-time 0' prio=1 status=enabled
`- 3:0:0:5 sdg 8:96 active ready running
asm_data2 (2bd52df95cf6f669a) dm-7 ROCKET ,IMAGEFILE
size=20G features='0' hwhandler='0' wp=rw
`-+- policy='service-time 0' prio=1 status=enabled
`- 3:0:0:4 sdf 8:80 active ready running
asm_data1 (2093ab4a1c1405d3c) dm-6 ROCKET ,IMAGEFILE
size=20G features='0' hwhandler='0' wp=rw
`-+- policy='service-time 0' prio=1 status=enabled
`- 3:0:0:3 sde 8:64 active ready running
asm_ocr3 (2527fb62efbbba57a) dm-5 ROCKET ,IMAGEFILE
size=10G features='0' hwhandler='0' wp=rw
`-+- policy='service-time 0' prio=1 status=enabled
`- 3:0:0:2 sdd 8:48 active ready running
[root@myrac1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1T 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 1023G 0 part
├─ol-root 249:0 0 957G 0 lvm /
├─ol-swap 249:1 0 16G 0 lvm [SWAP]
└─ol-home 249:2 0 50G 0 lvm /home
sdb 8:16 0 10G 0 disk
└─asm_ocr1 249:3 0 10G 0 mpath
sdc 8:32 0 10G 0 disk
└─asm_ocr2 249:4 0 10G 0 mpath
sdd 8:48 0 10G 0 disk
└─asm_ocr3 249:5 0 10G 0 mpath
sde 8:64 0 20G 0 disk
└─asm_data1 249:6 0 20G 0 mpath
sdf 8:80 0 20G 0 disk
└─asm_data2 249:7 0 20G 0 mpath
sdg 8:96 0 20G 0 disk
└─asm_data3 249:8 0 20G 0 mpath
sr0 11:0 1 1024M 0 rom
(4)配置 udev 绑盘
[root@myrac1 ~]# rm -rf /dev/mapper/udev_info
[root@myrac1 ~]# rm -rf /etc/udev/rules.d/99-oracle-asmdevices.rules
[root@myrac1 ~]# cd /dev/mapper
[root@myrac1 mapper]# for i in asm_*; do
printf "%s %s\n" "$i" "$(udevadm info --query=all --name=/dev/mapper/"$i" | grep -i dm_uuid)" >>/dev/mapper/udev_info
done
while read -r line; do
dm_uuid=$(echo "$line" | awk -F'=' '{print $2}')
disk_name=$(echo "$line" | awk '{print $1}')
echo "KERNEL==\"dm-*\",ENV{DM_UUID}==\"${dm_uuid}\",SYMLINK+=\"${disk_name}\",OWNER=\"grid\",GROUP=\"asmadmin\",MODE=\"0660\"" >>/etc/udev/rules.d/99-oracle-asmdevices.rules
done </dev/mapper/udev_info
## 查看udev_info 和 99-oracle-asmdevices.rules,内容如下
[root@myrac1 ~]# cat /dev/mapper/udev_info
asm_data1 E: DM_UUID=mpath-2093ab4a1c1405d3c
asm_data2 E: DM_UUID=mpath-2bd52df95cf6f669a
asm_data3 E: DM_UUID=mpath-25fe5d1e4cd6bbddf
asm_ocr1 E: DM_UUID=mpath-2da9eac16601b69f3
asm_ocr2 E: DM_UUID=mpath-28e46a515456bc1a9
asm_ocr3 E: DM_UUID=mpath-2527fb62efbbba57a
[root@myrac1 ~]# cat /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-2093ab4a1c1405d3c",SYMLINK+="asm_data1",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-2bd52df95cf6f669a",SYMLINK+="asm_data2",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-25fe5d1e4cd6bbddf",SYMLINK+="asm_data3",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-2da9eac16601b69f3",SYMLINK+="asm_ocr1",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-28e46a515456bc1a9",SYMLINK+="asm_ocr2",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-2527fb62efbbba57a",SYMLINK+="asm_ocr3",OWNER="grid",GROUP="asmadmin",MODE="0660"
## 重载
[root@myrac1 ~]# udevadm control --reload-rules
[root@myrac1 ~]# udevadm trigger --type=devices
## 查看后,磁盘属于grid用户
[root@myrac1 mapper]# ll /dev/asm_*
lrwxrwxrwx. 1 root root 4 7月 24 23:25 /dev/asm_data1 -> dm-6
lrwxrwxrwx. 1 root root 4 7月 24 23:25 /dev/asm_data2 -> dm-7
lrwxrwxrwx. 1 root root 4 7月 24 23:25 /dev/asm_data3 -> dm-8
lrwxrwxrwx. 1 root root 4 7月 24 23:25 /dev/asm_ocr1 -> dm-3
lrwxrwxrwx. 1 root root 4 7月 24 23:25 /dev/asm_ocr2 -> dm-4
lrwxrwxrwx. 1 root root 4 7月 24 23:25 /dev/asm_ocr3 -> dm-5
[root@myrac1 dev]# ll /dev/dm-[3-8]
brw-rw----. 1 grid asmadmin 249, 3 7月 26 11:29 dm-3
brw-rw----. 1 grid asmadmin 249, 4 7月 26 11:29 dm-4
brw-rw----. 1 grid asmadmin 249, 5 7月 26 11:29 dm-5
brw-rw----. 1 grid asmadmin 249, 6 7月 26 11:29 dm-6
brw-rw----. 1 grid asmadmin 249, 7 7月 26 11:29 dm-7
brw-rw----. 1 grid asmadmin 249, 8 7月 26 11:29 dm-8
##关闭防火墙
systemctl stop firewalld
##关闭开机启动
systemctl disable firewalld
##查看防火墙状态
systemctl status firewalld
##修改/etc/selinux/config文件,其中的SELINUX=enforcing 修改为SELINUX=disabled
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
##即时关闭selinux
setenforce 0
##获取selinux状态
getenforce
(1)禁用 chronyd
systemctl stop chronyd.service
systemctl disable chronyd.service
(2)设置时区
timedatectl set-timezone Asia/Shanghai
(3)配置 ntpdate 时间同步计划任务
yum install -y ntpdate
##192.168.15.60为本地搭建的NTP时间服务器IP,如果没有可以用 0.rhel.pool.ntp.org,每天12点同步系统时间
cat <<EOF>>/var/spool/cron/root
00 12 * * * /usr/sbin/ntpdate -u 192.168.15.60 && /usr/sbin/hwclock -w
EOF
##查看计划任务
crontab -l
##手动执行
/usr/sbin/ntpdate -u 192.168.15.60 && /usr/sbin/hwclock -w
关闭透明大页和NUMA(oracle-database-preinstall-19c 会自动设置,可跳过这一步)
##修改/etc/default/grub,会在quiet后面加上transparent_hugepage=never numa=off
sed -i 's/quiet/quiet transparent_hugepage=never numa=off/' /etc/default/grub
##关闭透明大页
grub2-mkconfig -o /boot/grub2/grub.cfg
##需要重启下,检查是否已关闭
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /proc/cmdline
如果安装了 oracle-database-preinstall-19c
,会自动设置,不过以防万一,也可以检查下 /etc/default/grub
中的 GRUB_CMDLINE_LINUX
中 numa=off
和 transparent_hugepage=never
是否存在
[root@myrac1 ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"
avahi-daemon会影响集群间的心跳网络,建议关闭(如果没有安装,也装上后关闭,避免后面不小心安装导致问题)
yum install -y avahi*
systemctl stop avahi-daemon.socket
systemctl stop avahi-daemon.service
pgrep -f avahi-daemon | awk '{print "kill -9 "$2}'
systemctl disable avahi-daemon.socket
systemctl disable avahi-daemon.service
修改文件 /etc/sysconfig/network
,如果安装了oracle-database-preinstall-19c
, 会自动设置
cat <<EOF>>/etc/sysconfig/network
NOZEROCONF=yes
EOF
修改文件 /etc/sysctl.conf
, oracle-database-preinstall-19c
会自动设置,可跳过,下面是 oracle-database-preinstall-19c
自动生产的,供参考
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
cat <<EOF>>/etc/security/limits.conf
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
oracle hard memlock 134217728
oracle soft memlock 134217728
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
grid soft nproc 2047
grid hard nproc 16384
EOF
配置pam.d/login,得添加下面内容,资源限制才能生效?
cat <>/etc/pam.d/login
session required pam_limits.so
session required /lib64/security/pam_limits.so
EOF
mkdir -p /u01/app/19.3.0/grid
mkdir -p /u01/app/grid
mkdir -p /u01/app/oracle/product/19.3.0/db
mkdir -p /u01/app/oraInventory
mkdir -p /backup
mkdir -p /home/oracle/scripts
chown -R oracle:oinstall /backup
chown -R oracle:oinstall /home/oracle/scripts
chown -R grid:oinstall /u01
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/19.3.0/grid
chown -R grid:oinstall /u01/app/oraInventory
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
su - grid
cat <<EOF>>/home/grid/.bash_profile
################OracleBegin#########################
umask 022
export TMP=/tmp
export TMPDIR=\$TMP
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/19.3.0/grid
export ORACLE_TERM=xterm
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=+ASM1
export PATH=/usr/sbin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:\$PATH
alias sas='sqlplus / as sysasm'
################OracleEnd#########################
EOF
oracle
su - oracle
cat <<EOF>>/home/oracle/.bash_profile
################OracleBegin#########################
umask 022
export TMP=/tmp
export TMPDIR=\$TMP
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/19.3.0/db
export ORACLE_HOSTNAME=myrac1
export ORACLE_TERM=xterm
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=myrac1
export PATH=/usr/sbin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:\$PATH
alias sas='sqlplus / as sysdba'
################OracleEnd#########################
EOF
ORACLE_SID
)su - grid
cat <<EOF>>/home/grid/.bash_profile
################OracleBegin#########################
umask 022
export TMP=/tmp
export TMPDIR=\$TMP
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/19.3.0/grid
export ORACLE_TERM=xterm
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=+ASM2
export PATH=/usr/sbin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:\$PATH
alias sas='sqlplus / as sysasm'
################OracleEnd#########################
EOF
oracle(修改ORACLE_HOSTNAME
和 ORACLE_SID
)
su - oracle
cat <<EOF>>/home/oracle/.bash_profile
################OracleBegin#########################
umask 022
export TMP=/tmp
export TMPDIR=\$TMP
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/19.3.0/db
export ORACLE_HOSTNAME=myrac2
export ORACLE_TERM=xterm
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=myrac2
export PATH=/usr/sbin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:\$PATH
alias sas='sqlplus / as sysdba'
################OracleEnd#########################
EOF
rac2 节点需要修改下 ORACLE_HOME
和 ORACLE_SID
本文安装所需的所有文件下载:
链接:https://pan.baidu.com/s/1nyW2Oj0Vs_wpHXLfGFkTXQ
提取码:4yhg
上传文件至 /soft
[root@myrac1 ~]# ll /soft
总用量 8489468
-rw-r--r--. 1 root root 3059705302 7月 28 14:54 LINUX.X64_193000_db_home.zip
-rw-r--r--. 1 root root 2889184573 7月 28 15:05 LINUX.X64_193000_grid_home.zip
-rw-r--r--. 1 root root 2622069335 7月 28 15:05 p33509923_190000_Linux-x86-64.zip
-rw-r--r--. 1 root root 122247289 7月 28 15:04 p6880880_190000_Linux-x86-64.zip
解压 grid 和 oracle 安装包
chown -R grid:oinstall /soft
su - grid -c "unzip -q /soft/LINUX.X64_193000_grid_home.zip -d /u01/app/19.3.0/grid/"
chown -R oracle:oinstall /soft
su - oracle -c "unzip -q /soft/LINUX.X64_193000_db_home.zip -d /u01/app/oracle/product/19.3.0/db/"
解压 Opatch 和 RU补丁
chown -R grid:oinstall /soft
su - grid -c "unzip -q -o /soft/p6880880_190000_Linux-x86-64.zip -d /u01/app/19.3.0/grid"
su - grid -c "unzip -q /soft/p33509923_190000_Linux-x86-64.zip -d /soft"
chown -R oracle:oinstall /soft
su - oracle -c "unzip -q -o /soft/p6880880_190000_Linux-x86-64.zip -d /u01/app/oracle/product/19.3.0/db"
安装 cvuqdisk
,后面先决条件会检查,提前安装
rpm -ivh /u01/app/19.3.0/grid/cv/rpm/cvuqdisk-1.0.10-1.rpm
##传输到节点二安装
scp /u01/app/19.3.0/grid/cv/rpm/cvuqdisk-1.0.10-1.rpm myrac2:/soft
rpm -ivh /soft/cvuqdisk-1.0.10-1.rpm
##root用户下修改 /soft 所属组,grid安装打补丁需要访问该目录
chown -R grid:oinstall /soft
用户 grid 下运行,我用的 MobaXterm
,自带 X server,可以显示界面,比较方便,另外如果显示中文异常,可根据以下 PS 内容进行设置。
##应用环境变量,一般登录会自动加载
source ~/.bash_profile
##进入安装目录
cd $ORACLE_HOME
##执行安装程序开始安装,通过-applyRU参数指向补丁解压位置,提前安装grid补丁
LANG=en_US ./gridSetup.sh -applyRU /soft/33509923
PS:
解决安装界面中文显示异常方法
LANG=en_US gridSetup.sh
./gridSetup.sh
开始安装
(1)选择 为新集群配置 Oracle Grid Infrastructure
,点击下一步
(2)选择 配置 Oracle 独立集群
,点击下一步
(3)选择 创建本地 SCAN
,集群名称设置为 myrac-cluster
,SCAN名称设置为 myrac-scan
,SCAN端口默认为 1521
,点击下一步
(4)点击添加,添加另一个节点
选择 添加单个节点
,公共主机名设置为 myrac2
,虚拟主机名设置为 myrac2-vip
,点击确定
点击 SSH 连接
,输入 grid 的密码
先点击设置,后点击测试,然后下一步
(5)这里私网网卡设置为 ASM 和专用
,点击下一步
(6)选择 将 Oracle Flex ASM 用于存储
,点击下一步
(7)选择 否
,不安装,点击下一步
(8)磁盘组名设置为 OCR
,冗余选择 普通
(磁盘数量3),更改搜索路径为 /dev/asm*
,
勾选 asm_ocr1,asm_ocr2,asm_ocr3
,取消勾选 配置 Oracle ASM Filter Driver
,点击下一步
(9)设置管理员密码,测试环境可以设置为 manager
,点击下一步
(10)默认,选择 不使用智能平台管理接口(IPMI)
,点击下一步
(11)不注册,如果需要可以安装好配置,点击下一步
(12)默认即可,点击下一步
(13)默认即可,点击下一步
(14)默认即可,点击下一步
(15)可以选择自动运行配置脚本,或者不勾选,后面安装提示需要执行时,再手工执行,点击下一步
(16)先决条件检查,稍等几分钟
以下几项,忽略,点击下一步
(17)显示安装总体的配置情况,点击安装
会出现以下错误提示,原因没研究,可忽略,具体可参考下此篇文字 INS-20802 Oracle Cluster Verification Utility failed解释说明
(19)安装完成,点击关闭
检查集群状态
crsctl stat res -t
[grid@myrac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
ONLINE ONLINE myrac1 STABLE
ONLINE ONLINE myrac2 STABLE
ora.chad
ONLINE ONLINE myrac1 STABLE
ONLINE ONLINE myrac2 STABLE
ora.net1.network
ONLINE ONLINE myrac1 STABLE
ONLINE ONLINE myrac2 STABLE
ora.ons
ONLINE ONLINE myrac1 STABLE
ONLINE ONLINE myrac2 STABLE
ora.proxy_advm
OFFLINE OFFLINE myrac1 STABLE
OFFLINE OFFLINE myrac2 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)
1 ONLINE ONLINE myrac1 STABLE
2 ONLINE ONLINE myrac2 STABLE
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE myrac1 STABLE
ora.OCR.dg(ora.asmgroup)
1 ONLINE ONLINE myrac1 STABLE
2 ONLINE ONLINE myrac2 STABLE
ora.asm(ora.asmgroup)
1 ONLINE ONLINE myrac1 Started,STABLE
2 ONLINE ONLINE myrac2 Started,STABLE
ora.asmnet1.asmnetwork(ora.asmgroup)
1 ONLINE ONLINE myrac1 STABLE
2 ONLINE ONLINE myrac2 STABLE
ora.cvu
1 ONLINE ONLINE myrac1 STABLE
ora.myrac1.vip
1 ONLINE ONLINE myrac1 STABLE
ora.myrac2.vip
1 ONLINE ONLINE myrac2 STABLE
ora.qosmserver
1 ONLINE ONLINE myrac1 STABLE
ora.scan1.vip
1 ONLINE ONLINE myrac1 STABLE
--------------------------------------------------------------------------------
检查 grid 补丁
opatch lspatches
sqlplus -version
[grid@myrac2 ~]$ opatch lspatches
33575402;DBWLM RELEASE UPDATE 19.0.0.0.0 (33575402)
33534448;ACFS RELEASE UPDATE 19.14.0.0.0 (33534448)
33529556;OCW RELEASE UPDATE 19.14.0.0.0 (33529556)
33515361;Database Release Update : 19.14.0.0.220118 (33515361)
33239955;TOMCAT RELEASE UPDATE 19.0.0.0.0 (33239955)
OPatch succeeded.
[grid@myrac2 ~]$ sqlplus -version
SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.14.0.0.0
asmca
(1)点击磁盘组,点击创建
(2)磁盘组名称设置为:DATA
,冗余设置为 正常
,选择 asm_data1,asm_data2,asm_data3
,点击确定
成功创建磁盘组 DATA,点击退出
检查 asm 磁盘
asmcmd lsdg
[grid@myrac1 ~]$ asmcmd lsdg
State Type Rebal Sector Logical_Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED NORMAL N 512 512 4096 4194304 61440 60900 20480 20210 0 N DATA/
MOUNTED NORMAL N 512 512 4096 4194304 30720 29732 10240 9746 0 Y OCR/
安装数据库
##修改/soft 所属用户 为 oracle,后面该目录打补丁会用到
chown -R oracle:oinstall /soft
在用户 oracle 下执行脚本,另外中文问题与安装grid类似,请查看上文解决
##通过 -applyRU 选项,可提前安装补丁
cd $ORACLE_HOME
./runInstaller -applyRU /soft/33509923/
[oracle@myrac1 ~]$ cd $ORACLE_HOME
[oracle@myrac1 db]$ ./runInstaller -applyRU /soft/33509923/
正在准备要打补丁的主目录...
正在应用补丁程序 /soft/33509923/...
开始安装
(1)选择 仅设置软件
,点击下一步
(2)选择 Oracle Real Application Clusters 数据库安装
,点击下一步
(3)点击SSH 连接
输入密码,先点设置,后点测试
点击下一步
(4)选择企业版
,点击下一步
(5)默认 /u01/app/oracle
,点击下一步
(6)默认即可,点击下一步
(7)勾选,输入root密码,若未勾选,那等后续安装时,根据提示手动执行即可,点击下一步
(8)先决条件检查
由于我们只配了一个 SCAN,所以关于 DNS 相关的都无视,点击下一步
(9)点击安装,大概10分钟左右
(10)安装成功,点击关闭
检查版本
opatch lspatches
sqlplus -version
[oracle@myrac1 db]$ opatch lspatches
33529556;OCW RELEASE UPDATE 19.14.0.0.0 (33529556)
33515361;Database Release Update : 19.14.0.0.220118 (33515361)
OPatch succeeded.
[oracle@myrac1 db]$ sqlplus -version
SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.14.0.0.0
dbca
开始创建
(1)选择 创建数据库
,点击下一步
(2)选择 高级配置
,点击下一步
(3)默认即可,点击下一步
(4)选择节点,点击下一步
(5)数据数据库名设置为 myrac
,SID 前缀设置为myrac
,勾选创建为容器数据库,不创建 PDB,点击下一步
(6)默认,点击下一步
(7)不开闪回,不开归档,可建完实例后有需要再开启,点击下一步
(8)不勾选,点击下一步
(9)设置内存,使用 ASMM 模式,数据库总内存占用物理内存 70%-90% 之间
进程调整为 1500
数据库字符集选择AL32UTF8
,国家字符集默认为 AL16UTF16
,其余默认即可,点击下一步
PS:这一步会检测可用内存,若提示不足,可参考文章最后问题解决
(10)均不启用,点击下一步
(11)设置管理员密码,点击下一步
(12)默认即可,点击下一步
(13)先决条件检查,与 DNS 有关检查忽略,点击下一步
(14)点击完成
(15)开始创建数据库
(16)数据库创建成功
登录数据库,查看数据库实例
[oracle@myrac1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Jul 28 23:00:10 2022
Version 19.14.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.14.0.0.0
SQL> SELECT INSTANCE_NAME, STATUS FROM gv$instance;
INSTANCE_NAME STATUS
---------------- ------------
myrac1 OPEN
myrac2 OPEN
su - grid
crsctl stat res -t
##关闭所有节点
srvctl stop database -d myrac
##打开所有节点
srvctl start database -d myrac
##查看数据库状态
srvctl status database -d myrac
##打开单个节点
srvctl start instance -d myrac -i myrac1 -o mount
##关闭单个节点
srvctl stop instance -d myrac -i myrac1
[oracle@myrac1 ~]$ srvctl status database -d myrac
实例 myrac1 正在节点 myrac1 上运行
实例 myrac2 正在节点 myrac2 上运行
[oracle@myrac1 ~]$ srvctl stop database -d myrac
[oracle@myrac1 ~]$ srvctl status database -d myrac
实例 myrac1 没有在 myrac1 节点上运行
实例 myrac2 没有在 myrac2 节点上运行
[oracle@myrac1 ~]$ srvctl start instance -d myrac -i myrac1 -o mount
[oracle@myrac1 ~]$ srvctl status database -d myrac
实例 myrac1 正在节点 myrac1 上运行
实例 myrac2 没有在 myrac2 节点上运行
sqlnet.ora
中添加以下语句 SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
,允许低版本客户端连接数据库,另外还需要下修改下用户密码,否则还是会连接失败,提示用户名密码错误cat <$ORACLE_HOME/network/admin/sqlnet.ora
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
EOF
[oracle@myrac1 ~]$ cat <<EOF>$ORACLE_HOME/network/admin/sqlnet.ora
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
EOF
[oracle@myrac1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Jul 28 23:37:13 2022
Version 19.14.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.14.0.0.0
SQL> alter user system identified by manager;
User altered.
(1)创建数据库,在执行以下步骤时,发现提示可用内存不够,检查了下,发现很多在 cache 中
以防万一,两个节点都检查下,并回收cache
echo 3 > /proc/sys/vm/drop_caches
释放命令参考的是 这篇文章。
(2)如果执行root.sh失败后,想重新安装,需要执行 .
,来清除上一次的影响,要还是异常,那还是把 /u01
下的文件全都删除,重新解压安装。
PS: 再检查下 /var/tmp/.oracle
下是否存在文件,有就清除;还有 /etc/oracle
也可以清空,安装时会根据该文件夹下的内容判断安装软件是新增还是更新,所以重新安装的话,就清空吧。参考 2542916.1
. /u01/app/19.3.0/grid/crs/install/rootcrs.sh -deconfig -force
(3)节点2执行 root.sh 时,最后提示错误 ,参考Metalink 2571719.1,可忽略
[root@hsrac2 tmp]# . /u01/app/19.3.0/grid/root.sh
rm: remove fifo ‘/u01/app/19.3.0/grid/install/root_hsrac2_2022-08-09_15-50-48-293217079.log.pipe’?
Performing root user operation.
The following environment variables are set as:
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/19.3.0/grid
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
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.
Relinking oracle with rac_on option
Using configuration parameter file: /u01/app/19.3.0/grid/crs/install/crsconfig_params
The log of current session can be found at:
/u01/app/grid/crsdata/hsrac2/crsconfig/rootcrs_hsrac2_2022-08-09_03-51-03PM.log
2022/08/09 15:51:07 CLSRSC-594: Executing installation step 1 of 19: 'SetupTFA'.
2022/08/09 15:51:07 CLSRSC-594: Executing installation step 2 of 19: 'ValidateEnv'.
2022/08/09 15:51:07 CLSRSC-594: Executing installation step 3 of 19: 'CheckFirstNode'.
2022/08/09 15:51:08 CLSRSC-594: Executing installation step 4 of 19: 'GenSiteGUIDs'.
2022/08/09 15:51:08 CLSRSC-594: Executing installation step 5 of 19: 'SetupOSD'.
Redirecting to /bin/systemctl restart rsyslog.service
2022/08/09 15:51:09 CLSRSC-594: Executing installation step 6 of 19: 'CheckCRSConfig'.
2022/08/09 15:51:09 CLSRSC-594: Executing installation step 7 of 19: 'SetupLocalGPNP'.
2022/08/09 15:51:11 CLSRSC-594: Executing installation step 8 of 19: 'CreateRootCert'.
2022/08/09 15:51:11 CLSRSC-594: Executing installation step 9 of 19: 'ConfigOLR'.
2022/08/09 15:51:21 CLSRSC-594: Executing installation step 10 of 19: 'ConfigCHMOS'.
2022/08/09 15:51:21 CLSRSC-594: Executing installation step 11 of 19: 'CreateOHASD'.
2022/08/09 15:51:23 CLSRSC-594: Executing installation step 12 of 19: 'ConfigOHASD'.
2022/08/09 15:51:23 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'
2022/08/09 15:51:46 CLSRSC-594: Executing installation step 13 of 19: 'InstallAFD'.
2022/08/09 15:52:06 CLSRSC-594: Executing installation step 14 of 19: 'InstallACFS'.
2022/08/09 15:52:18 CLSRSC-4002: Successfully installed Oracle Trace File Analyzer (TFA) Collector.
2022/08/09 15:52:20 CLSRSC-594: Executing installation step 15 of 19: 'InstallKA'.
2022/08/09 15:52:21 CLSRSC-594: Executing installation step 16 of 19: 'InitConfig'.
2022/08/09 15:52:30 CLSRSC-594: Executing installation step 17 of 19: 'StartCluster'.
2022/08/09 15:53:24 CLSRSC-343: Successfully started Oracle Clusterware stack
2022/08/09 15:53:24 CLSRSC-594: Executing installation step 18 of 19: 'ConfigNode'.
2022/08/09 15:53:36 CLSRSC-594: Executing installation step 19 of 19: 'PostConfig'.
2022/08/09 15:53:43 CLSRSC-325: Configure Oracle Grid Infrastructure for a Cluster ... succeeded
Error 4 opening dom ASM/Self in 0x78a4950
Domain name to open is ASM/Self
Error 4 opening dom ASM/Self in 0x78a4950
参考文章:
VMWARE无法识别新添加的硬盘
Oracle 19.3 Grid Infrastructure 软件安装详细教程
windows 下共享存储设置
Linux7 安装 Oracle 19C RAC 详细图文教程
实战篇:一步步教你Linux7安装Oracle RAC(11GR2版本)
花钱都买不到的绝版Oracle数据库最全版本安装包(精心整理)附下载链接,建议收藏
实战篇:一步步教你Linux7安装Oracle RAC(11GR2版本)
ntpd与ntpdate的区别(集群间时间同步)
ntp服务器搭建
官方文档
iscsiadm常用命令