文章目录
- 环境规划
- 网络规划
- 文件系统规划
- rac用户规划
- grid与oracle用户规划
- ASM规划
- 虚拟机设置
- 搭建虚拟机
- 自定义网卡
- 安装操作系统
- 操作系统设置
- 关闭services
- 修改/etc/hosts
- 创建用户与组
- 创建文件目录
- 设置环境变量
- 设置内核参数
- 资源限制
- 添加 etc/pam.d/login
- 关闭大页
- 关机挂载本地ISO镜像
- 挂载asm物理磁盘
- 配置本地yum源
- 安装依赖包
- 配置自动SSH
- 配置第二节点
- 克隆虚拟机
- 修改hostname和IP
- 禁用zeroconf路由(两个节点)
- ASM磁盘(两个节点)
- 重启设置ASM磁盘
- 查看磁盘id绑定磁盘权限
- 磁盘权限绑定
环境规划
网络规划
192.168.56.41 rac01.example.com rac01
192.168.56.42 rac02.example.com rac02
192.168.56.43 rac01-priv.example.com rac01-priv
192.168.56.44 rac02-priv.example.com rac02-priv
10.1.54.41 rac01-vip.example.com rac01-vip
10.1.54.42 rac02-vip.example.com rac02-vip
192.168.56.45 rac-scan.example.com rac-scan
192.168.56.46 rac-scan.example.com rac-scan
文件系统规划
100G:
/ 30G
/boot + /tmp 10G
swap 10G
/u01 50G
rac用户规划
oinstall 54321
dba 54322
asmadmin 54323
asmdba 54324
asmoper 54325
grid与oracle用户规划
用户 | uid | 所属组 | 附属组 | home路径 | BASE | HOME |
---|---|---|---|---|---|---|
grid | 54321 | oinstall | asmadmin,asmdba,asmoper,dba | /home/grid | ORACLE_BASE=/u01/app/grid | ORACLE_HOME=/u01/app/19.0.3/grid |
oracle | 54322 | oinstall | dba,asmdba | /home/oracle | ORACLE_BASE=/u01/app/oracle | ORACLE_HOME=/u01/app/oracle/product/19.0.3/dbhome_1 |
ASM规划
+OCR 2G
+DATA 2G
+FRA 2G
虚拟机设置
搭建虚拟机
自定义网卡
安装操作系统
操作系统设置
关闭services
systemctl disable firewalld
systemctl stop firewalld
vi /etc/selinux/config
systemctl stop NetworkManager
systemctl disable NetworkManager
修改/etc/hosts
cat >> /etc/hosts << eof
192.168.56.41 rac01.example.com rac01
192.168.56.42 rac02.example.com rac02
192.168.56.43 rac01-priv.example.com rac01-priv
192.168.56.44 rac02-priv.example.com rac02-priv
10.1.54.41 rac01-vip.example.com rac01-vip
10.1.54.42 rac02-vip.example.com rac02-vip
192.168.56.45 rac-scan.example.com rac-scan
192.168.56.46 rac-scan.example.com rac-scan
eof
创建用户与组
groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 asmadmin
groupadd -g 54324 asmdba
groupadd -g 54325 asmoper
useradd -u 54321 -g oinstall -G asmadmin,asmdba,asmoper,dba -d /home/grid grid
useradd -u 54322 -g oinstall -G dba,asmdba -d /home/oracle oracle
echo "oracle:oracle" | chpasswd
echo "grid:grid" | chpasswd
创建文件目录
mkdir -p /u01/app/grid
mkdir -p /u01/app/19.0.3/grid
mkdir -p /u01/app/oracle/product/19.0.3/dbhome_1
chown -R grid:oinstall /u01/
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
设置环境变量
su - grid
cat >> ~/.bash_profile << eof
#add for grid
export ORACLE_SID=+ASM1
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/19.0.3/grid
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH
export TMP=/tmp
export TMPDIR=/tmp
eof
su - oracle
cat >> ~/.bash_profile << eof
#add for oracle
export ORACLE_SID=mcdb1
export ORACLE_HOSTNAME=rac01
export ORACLE_UNQNAME=mcdb
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.3/dbhome_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
export TMP=/tmp
export TMPDIR=/tmp
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS";
export PS1="[\${ORACLE_SID}@`hostname` \${PWD}]$ "
export ORACLE_TERM=xterm
#export NLS_LANG=SIMPLIFIED\ CHINESE_CHINA.ZHS16GBK
eof
设置内核参数
cat >> /etc/sysctl.conf <<EOF
#add for oracle
kernel.shmmax = 4294967295
kernel.shmall = 268435456
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
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
fs.aio-max-nr = 1048576
EOF
/sbin/sysctl -p
资源限制
cat >> /etc/security/limits.conf <<EOF
# add for oracle and grid
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
EOF
添加 etc/pam.d/login
cat >> /etc/pam.d/login <<EOF
session required pam_limits.so
EOF
关闭大页
echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >> /etc/rc.d/rc.local
echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.d/rc.local
grep Huge /proc/meminfo
关机挂载本地ISO镜像
挂载asm物理磁盘
配置本地yum源
mkdir /mnt/cdrom
mount /dev/sr0 /mnt/cdrom
cat >> /etc/yum.repos.d/local.repo << eof
[local]
name=local
baseurl=file:///mnt/cdrom
gpgcheck=1
enabled=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
eof
yum clean all
yum makecache
安装依赖包
yum install -y bc binutils compat-libcap1 compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc libstdc++ libstdc++-devel libxcb make smartmontools sysstat librdmacm-devel libXext libaio.i686 libstdc++-devel.i686 libstdc++.i686 libgcc.i686 glibc-devel.i686
yum install -y ipmiutil net-tools nfs-utils python python-configshell python-rtslib python-six targetcli compat-libstdc++-33.i686 gcc compat-libstdc++ readline libtermcap-devel unixODBC-devel unixODBC libXi.i686 libxcb.i686 libXau.i686 libX11.i686 libXtst.i686 libXext.i686 gcc-c++ glibc glibc.i686 libaio-devel.i686
yum install -y unzip vim
配置自动SSH
cat /etc/ssh/sshd_config |grep LoginGraceTime
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak`date +"%Y%m%d_%H%M%S"`
sed -i 's/#LoginGraceTime 2m/LoginGraceTime 0/' /etc/ssh/sshd_config
cat /etc/ssh/sshd_config |grep LoginGraceTime
配置第二节点
克隆虚拟机
修改hostname和IP
vim /etc/hostname
hostnamectl
cd /etc/sysconfig/network-scripts
# 删除uuid和修改ipaddr
vim ifcfg-ens33
vim ifcfg-ens34
systemctl restart network
禁用zeroconf路由(两个节点)
两个方法都可以,第二种可能方便一些
# 第一节点
vi /etc/sysconfig/network
# Created by anaconda
HOSTNAME=rac01
NOZEROCONF=yes
# 第二节点
cat >> /etc/sysconfig/network << eof
HOSTNAME=rac02
NOZEROCONF=yes
eof
ASM磁盘(两个节点)
重启设置ASM磁盘
用记事本打开虚拟机对应的.vmx文件加入以下内容:
#shared disks configure
disk.locking = "false"
scsi1.sharedBus = "virtual"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
查看磁盘id绑定磁盘权限
/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sdb
/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sdc
/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sdd
磁盘权限绑定
# RESULT=="36000c296d892cc1eb823bc3f7acdc0ef"的内容修改为自己的scsi_id
vi /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c296d892cc1eb823bc3f7acdc0ef", RUN+="/bin/sh -c 'mknod /dev/asm-data b $major $minor; chown grid:asmadmin /dev/asm-data; chmod 0660 /dev/asm-data'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c2933932d7f8333aef1e305246d3", RUN+="/bin/sh -c 'mknod /dev/asm-far b $major $minor; chown grid:asmadmin /dev/asm-far; chmod 0660 /dev/asm-far'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29aeedf160041f6d6f1f0d5c0f7", RUN+="/bin/sh -c 'mknod /dev/asm-ocr b $major $minor; chown grid:asmadmin /dev/asm-ocr; chmod 0660 /dev/asm-ocr'"