规划

节点 system 主机名 pulic ip vip private ip scan ip
rac1 OL8 21C-RAC1 192.168.6.111 192.168.6.101 10.10.13.11 192.168.6.100
rac2 OL8 21C-RAC1 192.168.6.112 192.168.6.102 10.10.13.12

配置系统环境:

1.创建虚拟机

节点1
image.png
节点2
image.png

2.添加共享磁盘

1.磁盘规划

磁盘 容量 磁盘编号
data 50G 1.0
arch 30g 1.1
mght 30g 1.2
orc1 10g 1.3
orc2 10g 1.4
orc3 10g 1.5
orc4 10g 1.6
orc5 10g 1.7

2.添加磁盘

image.png
image.png
image.png
image.png
image.png
image.png
image.png

3.设置vmx参数

节点1 vmx文件,否则节点2主机挂载磁盘后,因为磁盘被节点1独占不能打开虚拟机
示例

  1. disk.locking="FALSE"
  2. disk.EnableUUID = "TRUE"

4.节点2添加磁盘

注意磁盘编号跟节点1保持一致
image.png

5.设置共享磁盘

  1. lsblk -f
  2. /lib/udev/scsi_id -g -d /dev/sdc 查看硬盘uuid
  3. 创建99-oracle-asmdevices.rules文件
  4. touch /etc/udev/rules.d/99-oracle-asmdevices.rules
  5. 未分区
  6. 1种方式:
  7. vi /etc/udev/rules.d/99-oracle-asmdevices.rules
  8. KERNEL=="sd*", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29f1e44953dc3bf6bde7ff61fd1", RUN+="/bin/sh -c 'mknod /dev/asmdisk1 b $major $minor; chown grid:asmadmin /dev/asmdisk1; chmod 0660 /dev/asmdisk1'"
  9. KERNEL=="sd*", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29316b5d859ce2fee1ab6c622f5", RUN+="/bin/sh -c 'mknod /dev/asmdisk2 b $major $minor; chown grid:asmadmin /dev/asmdisk2; chmod 0660 /dev/asmdisk2'"
  10. 2种方式:
  11. KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29f1e44953dc3bf6bde7ff61fd1", SYMLINK+="asmdisk1", OWNER="grid", GROUP="asmadmin", MODE="0660"
  12. KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29316b5d859ce2fee1ab6c622f5", SYMLINK+="asmdisk2", OWNER="grid", GROUP="asmadmin", MODE="0660"
  13. emc 多路径
  14. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf098002b63924885640ab7f028cb",SYMLINK+="oraocr1",OWNER="grid",GROUP="asmadmin",MODE="0660"
  15. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf09800c53619469a17fd57fa1e8a",SYMLINK+="oraocr2",OWNER="grid",GROUP="asmadmin",MODE="0660"
  16. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf098008c8042a8c7f47d8c9e7d06",SYMLINK+="oraocr3",OWNER="grid",GROUP="asmadmin",MODE="0660"
  17. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf09800038785466f37877d4ff1f3",SYMLINK+="oraocr4",OWNER="grid",GROUP="asmadmin",MODE="0660"
  18. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf098004a1e52ca193b167d7ab352",SYMLINK+="oraocr5",OWNER="grid",GROUP="asmadmin",MODE="0660"
  19. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf098009bdc2a2adedd77dd1fef9e",SYMLINK+="oraarch",OWNER="grid",GROUP="asmadmin",MODE="0660"
  20. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf09800b3ee2ffef4ce980c7ff1de",SYMLINK+="oradata",OWNER="grid",GROUP="asmadmin",MODE="0660"
  21. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf0980034683d967bbc832279d91f",SYMLINK+="oramgmt",OWNER="grid",GROUP="asmadmin",MODE="0660"
  22. 重启UDEV:
  23. systemctl restart systemd-udevd.service
  24. udevadm control --reload-rules
  25. /sbin/udevadm trigger --type=devices --action=add
  26. /sbin/udevadm trigger --type=devices --action=change
  27. 重新安装rac 格式化硬盘
  28. mkfs -t /dev/sdb
  29. mkfs -t /dev/sdc
  30. dd if=/dev/zero of=/dev/sdc bs=1024 count=512
  31. dd if=/dev/zero of=/dev/sdb bs=1024 count=512
  32. ls /dev 查看新添加的磁盘
  33. nvme磁盘 绑定权限
  34. KERNEL=="nvme1n1",SYMLINK+="oradata",OWNER="grid",GROUP="asmadmin",MODE="0660"
  35. KERNEL=="nvme1n2",SYMLINK+="oramgmt",OWNER="grid",GROUP="asmadmin",MODE="0660"
  36. KERNEL=="nvme1n3",SYMLINK+="oraarch",OWNER="grid",GROUP="asmadmin",MODE="0660"
  37. KERNEL=="nvme1n4",SYMLINK+="oraocr1",OWNER="grid",GROUP="asmadmin",MODE="0660"
  38. KERNEL=="nvme1n5",SYMLINK+="oraocr2",OWNER="grid",GROUP="asmadmin",MODE="0660"
  39. KERNEL=="nvme1n6",SYMLINK+="oraocr3",OWNER="grid",GROUP="asmadmin",MODE="0660"
  40. KERNEL=="nvme1n7",SYMLINK+="oraocr4",OWNER="grid",GROUP="asmadmin",MODE="0660"
  41. KERNEL=="nvme1n8",SYMLINK+="oraocr4",OWNER="grid",GROUP="asmadmin",MODE="0660"

3.添加网卡配置

注意因为复制的操作系统mac地址是一样的需要重新生成

  1. 2块网卡

1.配置IP地址主机名

  1. nmtui
  2. vi /etc/sysconfig/network-scripts/ifcfg-ens160
  3. TYPE=Ethernet
  4. PROXY_METHOD=none
  5. BROWSER_ONLY=no
  6. BOOTPROTO=none
  7. DEFROUTE=yes
  8. IPV4_FAILURE_FATAL=no
  9. IPV6INIT=yes
  10. IPV6_AUTOCONF=yes
  11. IPV6_DEFROUTE=yes
  12. IPV6_FAILURE_FATAL=no
  13. IPV6_ADDR_GEN_MODE=stable-privacy
  14. NAME=eth0
  15. DEVICE=eth0
  16. ONBOOT=yes
  17. IPADDR=192.168.6.111
  18. PREFIX=24
  19. GATEWAY=192.168.6.2
  20. DNS1=116.116.116.116
  21. vi /etc/sysconfig/network-scripts/ifcfg-Wired_connection_1
  22. TYPE=Ethernet
  23. PROXY_METHOD=none
  24. BROWSER_ONLY=no
  25. BOOTPROTO=none
  26. DEFROUTE=yes
  27. IPV4_FAILURE_FATAL=no
  28. IPV6INIT=yes
  29. IPV6_AUTOCONF=yes
  30. IPV6_DEFROUTE=yes
  31. IPV6_FAILURE_FATAL=no
  32. IPV6_ADDR_GEN_MODE=stable-privacy
  33. NAME=eth1
  34. DEVICE=eth1
  35. ONBOOT=yes
  36. AUTOCONNECT_PRIORITY=-999
  37. IPADDR=10.10.13.11
  38. PREFIX=8

2.修改配置文件名

  1. 修改文件名
  2. mv /etc/sysconfig/network-scripts/ifcfg-ens160 /etc/sysconfig/network-scripts/ifcfg-eth0
  3. mv /etc/sysconfig/network-scripts/ifcfg-Wired_connection_1 /etc/sysconfig/network-scripts/ifcfg-eth1

3.绑定mac地址

  1. /etc/sysconfig/network-scripts/ 文件夹下
  2. cp ifcfg-ens33 ifcfg-eth0
  3. 删除 uid 修改设备名和网卡名 设置规划的public ip 地址
  4. cp ifcfg-eth0 ifcfg-eth1 设置规划的private ip 地址
  5. vi /etc/sysconfig/grub 下的GRUB_CMDLINE_LINUX="" 中添加 net.ifnames=0 biosdevname=0
  6. grub2-mkconfig -o /boot/grub2/grub.cfg
  7. ip addr 查看mac地址
  8. 编辑/etc/udev/rules.d/70-persistent-ipoib.rules 文件,
  9. ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="00:0c:29:0f:93:49", NAME="eth0"
  10. ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="00:0c:29:0f:93:53", NAME="eth1"
  11. reboot

3.同步系统时间

  1. ntpdate ntp.aliyun.com
  2. ntpdate ntp.aliyun.com

4.关闭防火墙

  1. [root@rac1 ~]# systemctl disable firewalld.service
  2. Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
  3. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
  4. [root@rac1 ~]# systemctl stop firewalld.service

5.关闭selinux

  1. vi /etc/selinux/config
  2. SELINUX=disabled

6.配置/etc/hosts

  1. vi /etc/hosts
  2. #Public
  3. 192.168.6.111 21c-rac1
  4. 192.168.6.112 21c-rac2
  5. #Virtual
  6. 192.168.6.101 21c-rac1-vip
  7. 192.168.6.102 21c-rac2-vip
  8. #Private
  9. 10.10.13.11 21c-rac1-priv
  10. 10.10.13.12 21c-rac2-priv
  11. #Scan-ip
  12. 192.168.6.100 rac-scan-21c

7.配置资源限制limits.conf

vi /etc/security/limits.conf
oracle 预配置编辑 vi /etc/security/limits.d/oracle-database-preinstall-21c.conf

  1. oracle soft nproc 2047
  2. oracle hard nproc 16384
  3. oracle soft nofile 1024
  4. oracle hard nofile 65536
  5. oracle soft stack 3145728
  6. oracle hard stack 3145728
  7. oracle soft memlock 3145728
  8. oracle hard memlock 3145728
  9. grid soft nproc 16384
  10. grid hard nproc 16384
  11. grid soft nofile 1024
  12. grid hard nofile 65536
  13. grid soft stack 10240
  14. grid hard stack 32768

8.配置/dev/shm

推荐配置为生产环境ram的80%

  1. df -h
  2. vi /etc/fstab
  3. tmpfs /dev/shm tmpfs defaults,size=6g 0 0
  4. mount -o remount /dev/shm

9.配置内核参数

使用oracle 预配置则忽略此步骤

  1. touch /etc/sysctl.d/97-oracledatabase-sysctl.conf
  2. fs.aio-max-nr = 1048576
  3. fs.file-max = 6815744
  4. kernel.shmall = 1572864
  5. kernel.shmmax = 6442450944
  6. kernel.shmmni = 4096
  7. kernel.sem = 250 32000 100 128
  8. net.ipv4.ip_local_port_range = 9000 65500
  9. net.core.rmem_default = 262144
  10. net.core.rmem_max = 4194304
  11. net.core.wmem_default = 262144
  12. net.core.wmem_max = 1048576
  13. sysctl --system(立即生效)
  14. sysctl -a|grep shmmax
  15. sysctl -a|grep shmall

10.添加账户

  1. /usr/sbin/groupadd -g 54321 oinstall
  2. /usr/sbin/groupadd -g 54322 dba
  3. /usr/sbin/groupadd -g 54323 oper
  4. /usr/sbin/groupadd -g 54324 backupdba
  5. /usr/sbin/groupadd -g 54325 dgdba
  6. /usr/sbin/groupadd -g 54326 kmdba
  7. /usr/sbin/groupadd -g 54330 racdba
  8. /usr/sbin/groupadd -g 54327 asmdba
  9. /usr/sbin/groupadd -g 54328 asmoper
  10. /usr/sbin/groupadd -g 54329 asmadmin
  11. useradd -u 54322 -g oinstall -G dba,asmoper,asmadmin,asmdba grid
  12. useradd -u 54321 -g oinstall -G dba,oper,asmdba,asmadmin oracle
  13. passwd grid
  14. passwd oracle
  15. id oracle
  16. id grid
  17. 2个节点的用户号必须一样
  18. --------------------------------------------
  19. 预配置追加用户
  20. /usr/sbin/groupadd -g 54327 asmdba
  21. /usr/sbin/groupadd -g 54328 asmoper
  22. /usr/sbin/groupadd -g 54329 asmadmin
  23. useradd -u 54322 -g oinstall -G asmadmin,asmdba,racdba,asmoper grid
  24. /usr/sbin/usermod -g oinstall -G asmadmin,asmdba,racdba,asmoper grid
  25. /usr/sbin/usermod -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper oracle
  26. ---------------------------------------------------
  27. /usr/sbin/groupadd -g 54322 dba
  28. groupadd -g 54323 oper
  29. /usr/sbin/groupadd -g 54324 backupdba
  30. /usr/sbin/groupadd -g 54325 dgdba
  31. /usr/sbin/groupadd -g 54326 kmdba
  32. /usr/sbin/groupadd -g 54330 racdba

11.创建目录

  1. mkdir -p /u01/app/grid
  2. mkdir -p /u01/app/21c/grid
  3. mkdir -p /u01/app/oracle/product/21c/dbhome_1
  4. chown -R oracle:oinstall /u01
  5. chown -R grid:oinstall /u01/app/grid
  6. chown -R oracle:oinstall /u01/app/oracle
  7. chown -R grid:oinstall /u01/app/21c
  8. chmod -R 775 /u01

12.修改/etc/nsswitch.conf

  1. 修改行
  2. hosts: files dns myhostname
  3. hosts: files dns nis

13.关闭透明大页

https://www.yuque.com/yongle-okrsc/kb/abnl9t#ifioW
11.禁止ntp服务

  1. systemctl stop chronyd
  2. systemctl disable chronyd
  3. systemctl start chronyd
  4. systemctl enable chronyd

14.禁止avahi-daemon服务

avahi-daemon 服务会影响 oracle的多波通信,进而导致节点重启

  1. systemctl stop avahi-daemon.service
  2. systemctl disable avahi-daemon.service

15.配置network文件

  1. vi /etc/sysconfig/network
  2. NOZEROCONF=yes

16.解压文件

  1. unzip LINUX.X64_213000_grid_home.zip -d /u01/app/21c/grid/

安装grid

1.创建ssh秘钥文件

  1. passwd grid
  2. su - grid
  3. ssh-keygen

2.所有节点安装cvuqdisk

  1. rpm -ivh /u01/app/21c/grid/cv/rpm/cvuqdisk-1.0.10-1.rpm
  2. scp /u01/app/21c/grid/cv/rpm/cvuqdisk-1.0.10-1.rpm root@192.168.6.112:/setup

3.启动安装程序

  1. su - grid
  2. cd /u01/app/21c/grid
  3. ./gridSetup.sh

image.png
image.png
image.png

image.png
image.png
image.png
image.png
image.png
image.png
image.png

image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png

安装数据库

1.解压文件

  1. unzip LINUX.X64_213000_db_home.zip -d /u01/app/oracle/product/21c/dbhome_1/

2.更改oracle 账户密码

  1. passwd oracle

3.创建oracle账户ssh秘钥

  1. ssh-keygen

4.启动安装程序

  1. ./runInstaller

5.创建归档磁盘

  1. asmca

image.pngimage.png

image.png

image.png
image.png
image.png
image.png
image.png
image.png
注意我们使用CTSS 时间同步下面的报错可以忽略
image.png
image.png
image.png
image.png
5.添加环境变量

  1. export ORACLE_SID=+ASM1
  2. export ORACLE_BASE=/u01/app/grid
  3. export ORACLE_HOME=/u01/app/21c/grid
  4. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
  5. export PATH=$ORACLE_HOME/bin:$PATH
  6. export ORACLE_SID=+ASM2
  7. export ORACLE_BASE=/u01/app/grid
  8. export ORACLE_HOME=/u01/app/21c/grid
  9. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
  10. export PATH=$ORACLE_HOME/bin:$PATH
  11. Oracle Database
  12. .bash_profile
  13. export ORACLE_SID=rac21cdb1
  14. export ORACLE_BASE=/u01/app/oracle
  15. export ORACLE_HOME=/u01/app/oracle/product/21c/dbhome_1
  16. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
  17. export PATH=$ORACLE_HOME/bin:$PATH
  18. export ORACLE_SID=rac21cdb2
  19. export ORACLE_BASE=/u01/app/oracle
  20. export ORACLE_HOME=/u01/app/oracle/product/21c/dbhome_1
  21. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
  22. export PATH=$ORACLE_HOME/bin:$PATH

6.建库

  1. dbca

image.png
image.png

image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png