规划
节点 | 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.创建虚拟机
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.添加磁盘
3.设置vmx参数
节点1 vmx文件,否则节点2主机挂载磁盘后,因为磁盘被节点1独占不能打开虚拟机
示例
disk.locking="FALSE"
disk.EnableUUID = "TRUE"
4.节点2添加磁盘
5.设置共享磁盘
lsblk -f
/lib/udev/scsi_id -g -d /dev/sdc 查看硬盘uuid
创建99-oracle-asmdevices.rules文件
touch /etc/udev/rules.d/99-oracle-asmdevices.rules
未分区
第1种方式:
vi /etc/udev/rules.d/99-oracle-asmdevices.rules
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'"
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'"
第2种方式:
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"
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"
emc 多路径
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf098002b63924885640ab7f028cb",SYMLINK+="oraocr1",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf09800c53619469a17fd57fa1e8a",SYMLINK+="oraocr2",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf098008c8042a8c7f47d8c9e7d06",SYMLINK+="oraocr3",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf09800038785466f37877d4ff1f3",SYMLINK+="oraocr4",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf098004a1e52ca193b167d7ab352",SYMLINK+="oraocr5",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf098009bdc2a2adedd77dd1fef9e",SYMLINK+="oraarch",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf09800b3ee2ffef4ce980c7ff1de",SYMLINK+="oradata",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-368ccf0980034683d967bbc832279d91f",SYMLINK+="oramgmt",OWNER="grid",GROUP="asmadmin",MODE="0660"
重启UDEV:
systemctl restart systemd-udevd.service
udevadm control --reload-rules
/sbin/udevadm trigger --type=devices --action=add
/sbin/udevadm trigger --type=devices --action=change
重新安装rac 格式化硬盘
mkfs -t /dev/sdb
mkfs -t /dev/sdc
dd if=/dev/zero of=/dev/sdc bs=1024 count=512
dd if=/dev/zero of=/dev/sdb bs=1024 count=512
ls /dev 查看新添加的磁盘
nvme磁盘 绑定权限
KERNEL=="nvme1n1",SYMLINK+="oradata",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="nvme1n2",SYMLINK+="oramgmt",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="nvme1n3",SYMLINK+="oraarch",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="nvme1n4",SYMLINK+="oraocr1",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="nvme1n5",SYMLINK+="oraocr2",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="nvme1n6",SYMLINK+="oraocr3",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="nvme1n7",SYMLINK+="oraocr4",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="nvme1n8",SYMLINK+="oraocr4",OWNER="grid",GROUP="asmadmin",MODE="0660"
3.添加网卡配置
注意因为复制的操作系统mac地址是一样的需要重新生成
2块网卡
1.配置IP地址主机名
nmtui
vi /etc/sysconfig/network-scripts/ifcfg-ens160
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
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=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.6.111
PREFIX=24
GATEWAY=192.168.6.2
DNS1=116.116.116.116
vi /etc/sysconfig/network-scripts/ifcfg-Wired_connection_1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
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=eth1
DEVICE=eth1
ONBOOT=yes
AUTOCONNECT_PRIORITY=-999
IPADDR=10.10.13.11
PREFIX=8
2.修改配置文件名
修改文件名
mv /etc/sysconfig/network-scripts/ifcfg-ens160 /etc/sysconfig/network-scripts/ifcfg-eth0
mv /etc/sysconfig/network-scripts/ifcfg-Wired_connection_1 /etc/sysconfig/network-scripts/ifcfg-eth1
3.绑定mac地址
在 /etc/sysconfig/network-scripts/ 文件夹下
cp ifcfg-ens33 ifcfg-eth0
删除 uid 修改设备名和网卡名 设置规划的public ip 地址
cp ifcfg-eth0 ifcfg-eth1 设置规划的private ip 地址
vi /etc/sysconfig/grub 下的GRUB_CMDLINE_LINUX="" 中添加 net.ifnames=0 biosdevname=0
grub2-mkconfig -o /boot/grub2/grub.cfg
ip addr 查看mac地址
编辑/etc/udev/rules.d/70-persistent-ipoib.rules 文件,
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="00:0c:29:0f:93:49", NAME="eth0"
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="00:0c:29:0f:93:53", NAME="eth1"
reboot
3.同步系统时间
ntpdate ntp.aliyun.com
ntpdate ntp.aliyun.com
4.关闭防火墙
[root@rac1 ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@rac1 ~]# systemctl stop firewalld.service
5.关闭selinux
vi /etc/selinux/config
SELINUX=disabled
6.配置/etc/hosts
vi /etc/hosts
#Public
192.168.6.111 21c-rac1
192.168.6.112 21c-rac2
#Virtual
192.168.6.101 21c-rac1-vip
192.168.6.102 21c-rac2-vip
#Private
10.10.13.11 21c-rac1-priv
10.10.13.12 21c-rac2-priv
#Scan-ip
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
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 3145728
oracle hard stack 3145728
oracle soft memlock 3145728
oracle hard memlock 3145728
grid soft nproc 16384
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
8.配置/dev/shm
推荐配置为生产环境ram的80%
df -h
vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=6g 0 0
mount -o remount /dev/shm
9.配置内核参数
使用oracle 预配置则忽略此步骤
touch /etc/sysctl.d/97-oracledatabase-sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 1572864
kernel.shmmax = 6442450944
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
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
sysctl --system(立即生效)
sysctl -a|grep shmmax
sysctl -a|grep shmall
10.添加账户
/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper
/usr/sbin/groupadd -g 54324 backupdba
/usr/sbin/groupadd -g 54325 dgdba
/usr/sbin/groupadd -g 54326 kmdba
/usr/sbin/groupadd -g 54330 racdba
/usr/sbin/groupadd -g 54327 asmdba
/usr/sbin/groupadd -g 54328 asmoper
/usr/sbin/groupadd -g 54329 asmadmin
useradd -u 54322 -g oinstall -G dba,asmoper,asmadmin,asmdba grid
useradd -u 54321 -g oinstall -G dba,oper,asmdba,asmadmin oracle
passwd grid
passwd oracle
id oracle
id grid
2个节点的用户号必须一样
--------------------------------------------
预配置追加用户
/usr/sbin/groupadd -g 54327 asmdba
/usr/sbin/groupadd -g 54328 asmoper
/usr/sbin/groupadd -g 54329 asmadmin
useradd -u 54322 -g oinstall -G asmadmin,asmdba,racdba,asmoper grid
/usr/sbin/usermod -g oinstall -G asmadmin,asmdba,racdba,asmoper grid
/usr/sbin/usermod -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper oracle
---------------------------------------------------
/usr/sbin/groupadd -g 54322 dba
groupadd -g 54323 oper
/usr/sbin/groupadd -g 54324 backupdba
/usr/sbin/groupadd -g 54325 dgdba
/usr/sbin/groupadd -g 54326 kmdba
/usr/sbin/groupadd -g 54330 racdba
11.创建目录
mkdir -p /u01/app/grid
mkdir -p /u01/app/21c/grid
mkdir -p /u01/app/oracle/product/21c/dbhome_1
chown -R oracle:oinstall /u01
chown -R grid:oinstall /u01/app/grid
chown -R oracle:oinstall /u01/app/oracle
chown -R grid:oinstall /u01/app/21c
chmod -R 775 /u01
12.修改/etc/nsswitch.conf
修改行
hosts: files dns myhostname
为
hosts: files dns nis
13.关闭透明大页
https://www.yuque.com/yongle-okrsc/kb/abnl9t#ifioW
11.禁止ntp服务
systemctl stop chronyd
systemctl disable chronyd
systemctl start chronyd
systemctl enable chronyd
14.禁止avahi-daemon服务
avahi-daemon 服务会影响 oracle的多波通信,进而导致节点重启
systemctl stop avahi-daemon.service
systemctl disable avahi-daemon.service
15.配置network文件
vi /etc/sysconfig/network
NOZEROCONF=yes
16.解压文件
unzip LINUX.X64_213000_grid_home.zip -d /u01/app/21c/grid/
安装grid
1.创建ssh秘钥文件
passwd grid
su - grid
ssh-keygen
2.所有节点安装cvuqdisk
rpm -ivh /u01/app/21c/grid/cv/rpm/cvuqdisk-1.0.10-1.rpm
scp /u01/app/21c/grid/cv/rpm/cvuqdisk-1.0.10-1.rpm root@192.168.6.112:/setup
3.启动安装程序
su - grid
cd /u01/app/21c/grid
./gridSetup.sh
安装数据库
1.解压文件
unzip LINUX.X64_213000_db_home.zip -d /u01/app/oracle/product/21c/dbhome_1/
2.更改oracle 账户密码
passwd oracle
3.创建oracle账户ssh秘钥
ssh-keygen
4.启动安装程序
./runInstaller
5.创建归档磁盘
asmca
注意我们使用CTSS 时间同步下面的报错可以忽略
5.添加环境变量
export ORACLE_SID=+ASM1
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/21c/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=+ASM2
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/21c/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
Oracle Database
.bash_profile
export ORACLE_SID=rac21cdb1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/21c/dbhome_1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=rac21cdb2
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/21c/dbhome_1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
6.建库
dbca