centos7 Oracle 11g rac 静默安装(NFS配置共享存储)

1.环境信息准备

注意: 在配置网络时,Oracle RAC的每个节点必须具有至少两个以上的网卡,一张网卡对外提供网络服务,另一张网卡用于各个节点间的通信和心跳检测等。在配置RAC集群的网卡时,如果节点1的公共接口是eth0,则所有节点的公共接口必须是eth0。(配置私有网口时也必须一致)另外,每个节点的主机名必须符合RFC 952标准,不允许使用下划线。对于Oracle 11G RAC双节点说,Oracle要求我们至少有7个ip地址,Public IP、Virtual IP和Scan IP在同一个网段下,Private IP在另一个网段中。

|------------|---------------|---------------|
| 主机名 | rac1 | rac2 |
| Public IP | 10.186.63.52 | 10.186.63.53 |
| Private IP | 10.186.202.2 | 10.186.202.3 |
| Virtual ip | 10.186.63.203 | 10.186.63.204 |
| Scan ip | 10.186.63.205 ||
| NFS ip | 10.186.63.26 ||

2.共享存储规划

磁盘名 磁盘数量 磁盘大小 冗余模式
OCR 3 10G/个 Normal
DATA 1 50G External
FRA 1 20G External

3.安装步骤

3.1主机配置

sql 复制代码
#修改主机名
#10.186.63.52
hostnamectl set-hostname rac1 
#10.186.63.53
hostnamectl set-hostname rac2

#修改/etc/hosts文件 rac1和rac2一样文件末加入如下内容

vi /etc/hosts

#Public ip
10.186.63.52 rac1
10.186.63.53 rac2

# Private ip
10.186.202.2 rac1priv
10.186.202.3 rac2priv

# Virtual ip
10.186.63.203 rac1vip
10.186.63.204 rac2vip

# Scan ip
10.186.63.205 racscan

#NFS
10.186.63.26 nfs
sql 复制代码
#刷新
exec bash 

#查看是否生效,注意hostname不生效可能导致安装失败
cat /etc/hostname 

3.2创建用户组和用户

sql 复制代码
groupadd oinstall -g 500
groupadd dba -g 501
groupadd oper -g 502
groupadd asmadmin -g 2003
groupadd asmdba -g 2004
groupadd asmoper -g 2005
useradd -u 500 -g oinstall -G dba,oper,asmdba,asmadmin,asmoper -d /home/oracle oracle
useradd -u 2001 -g oinstall -G asmadmin,asmdba,asmoper,dba -d /home/grid grid
echo oracle | passwd --stdin oracle &&\
echo grid | passwd --stdin grid

3.3 禁用firewalld和selinux

sql 复制代码
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

3.4禁用 avahi-daemon服务

sql 复制代码
systemctl stop avahi-daemon
systemctl disable avahi-daemon
echo 'NOZEROCONF=yes' >> /etc/sysconfig/network

3.5关闭透明大页和NUMA

sql 复制代码
#查看透明页情况
cat /sys/kernel/mm/transparent_hugepage/enabled
#结果显示
[always] madvise never      表示开启了透明页

   #关闭透明大页
cat <<EOF>> /etc/rc.d/rc.local
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
EOF

授权
chmod +x /etc/rc.d/rc.local


#关闭numactl(关闭交换页面)
sed -i 's/quiet/quiet transparent_hugepage=never numa=off/' /etc/default/grub

#生成启动规则
grub2-mkconfig -o /boot/grub2/grub.cfg

#重启服务器
reboot

3.6修改nsswitch.conf

nsswitch.conf保存的是域名检索顺序,在一些系统配置中,NIS(Network Information system)可能会引起SCAN域名解析异常

sql 复制代码
sed -i "s/^hosts:      files dns myhostname/hosts:      files dns myhostname nis/g" /etc/nsswitch.conf

3.7调整磁盘调度模式

为了获得Oracle ASM的最佳性能,Oracle建议使用Deadline I/O调度

sql 复制代码
#查看当前系统的I/O调度方法
cat /sys/block/sda/queue/scheduler
noop [deadline] cfq     #表示是使用deadline I/O调度

#如果磁盘调度为noop或者是cfq,则需要修改为deadline,通过如下命令处理
#永久的更改I/O调度方法:修改内核引导参数,加入elevator=调度程序名
grubby --update-kernel=ALL --args="elevator=deadline"

#需要重启生效
reboot

#再次查看当前系统的I/O调度方法 
cat /sys/block/sda/queue/scheduler
结果显示:
noop [deadline] cfq     #此时已经是deadline了

3.8禁用NTP服务

Oracle会在安装时检测是否有NTP服务,如果有,则会认为你的服务器是使用NTP来同步节点时间的,会将自身的CTSS服务配置成观察状态;如果检测到没有NTP服务,则会使用CTSS服务来同步时间。CTSS服务会将安装Grid软件的那台来作为主节点,然后让集群的其他节点时间与主节点的时间进行同步。

禁用NTP服务,使用Oracle的CTSS服务来同步节点的时间,如果时间和时间差异比较大,则将其修改为主节点的时区,并将时间调整到与主节点相近的时间,后续CTSS服务会修正时间

sql 复制代码
#停止NTP服务并关闭开机自启
systemctl stop ntpd && systemctl disable ntpd && rm -fr /etc/ntp.conf

3.9 配置内核参数

sql 复制代码
cat <<EOF>> /etc/sysctl.conf
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
#kernel.shmall = 1310720
#kernel.shmmax = 8589934591
kernel.shmmax = 5368709120
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
vm.nr_hugepages = 2700
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 16777216
net.core.wmem_default = 262144
net.core.wmem_max = 16777216
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_fin_timeout = 10
EOF

重加载内核参数使之立即生效

sql 复制代码
sysctl -p

配置注解:

bash 复制代码
配置讲解:
(1)fs.file-max:最大打开文件数
(2)kernel.shmall:共享内存的总量,8G内存设置:(8*1024*1024)KB/4KB=2097152
(3)kernel.shmmax:最大共享内存的段大小,一般设置为服务器的80%内存总大小:物理内存大小*1024*1024*1024-1,必须要大于等于SGA,
    比如8G=oracle 内存8G*0.8=6.4 (SGA=6.4*0.8=5.12+PGA=6.4*0.2)---->=SGA=5*1024*1024*1024
   oracle 内存设置: oracle 内存=物理内存*40%-80%,生产服务器内存比较大可以设置为60%,小可以设置为80%
   物理内存的80%,   物理内存的40%
  oracle = SGA (80%)+ PGA(20%)
   SGA=物理内存的80%的80%=8*0.8*0.8=5
   PGA=物理内存的80%的20%=8*0.8*0.2=1.2
   shmmax=5*1024*1024*1024
   shmall=shmmax/PAGESIZE
   nr_hugepages=SGA/2+100~500=2600
    shmall参数:控制共享内存页数: = shmmax/PAGESIZE
   getconf PAGESIZE 获取每而大小
   shmmni参数:共享内存段最大数量
   vm.nr_hugepages:大页,系统内存大于8G,生产一定要设置,设置了大页会让oracle运行得更快
   SGA/2M+200
(4)net.ipv4.ip_local_port_range:可使用的ipv4端口范围
如果服务器只运行单个实例(数据库),可以参考下下面的建议值
内存为12G
     kernel.shmall = 3145728
     kernel.shmmax = 12884901887
内存为16G
     kernel.shmall = 4194304
     kernel.shmmax = 17179869183
内存为32G
     kernel.shmall = 8388608
     kernel.shmmax = 34359738367
内存为64G
     kernel.shmall = 16777216
     kernel.shmmax = 68719476735

3.10限制用户资源使用

sql 复制代码
cat <<EOF>> /etc/security/limits.conf
oracle  soft  nproc  2047
oracle  hard  nproc  16384
oracle  soft  nofile 1024
oracle  hard  nofile 65536
oracle  soft  stack  10240
oracle  hard  stack   32768
oracle  soft  memlock 7340032
oracle  hard  memlock 7340032

grid    soft  nproc  2047
grid    hard  nproc  16384
grid    soft  nofile 1024
grid    hard  nofile 65536
grid    soft  stack  10240
grid    hard  stack   32768
grid    soft  memlock 7340032
grid    hard  memlock 7340032
EOF

memlock(内存锁)要比内存要小:比如服务器内存是8G,内存锁可使用:7*1024*1024

bash 复制代码
ulimit -a

login文件增加如下参数

sql 复制代码
cat <<EOF>> /etc/pam.d/login
#Oracle Setting
session       required        pam_limits.so
session       required        /lib64/security/pam_limits.so
EOF

修改nproc参数

sql 复制代码
echo "* - nproc 16384" > /etc/security/limits.d/20-nproc.conf

编辑profile文件,添加如下内容

sql 复制代码
cat <<EOF>> /etc/profile
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi
EOF

生效:

sql 复制代码
source /etc/profile

3.11配置用户环境变量

sql 复制代码
#root用户执行就行:
#rac1节点:
vim /home/oracle/.bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl11g1
export LANG=en_US.UTF-8


vim /home/grid/.bash_profile
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=+ASM1
export LANG=en_US.UTF-8

#rac2节点:

vim /home/oracle/.bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl11g2
export LANG=en_US.UTF-8


vim /home/grid/.bash_profile
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=+ASM2
export LANG=en_US.UTF-8

生效:

sql 复制代码
source /home/oracle/.bash_profile
source /home/grid/.bash_profile

3.12创建软件目录

sql 复制代码
mkdir -p /u01/software
mkdir -p /u01/app/oracle
chown oracle:oinstall /u01/app/oracle
mkdir -p /u01/app/grid
chown grid:oinstall /u01/app/grid
chgrp oinstall /u01/app
chmod 775 /u01/app

3.13配置ssh

grid用户配置互信:su - grid

rac1:

sql 复制代码
# 生成协议2版本的RSA密钥对
[grid@rac1 ~]$ ssh-keygen -t rsa
# 将密钥内容复制到authorized_keys文件中
[grid@rac1 ~]$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys

rac2:

sql 复制代码
# 生成协议2版本的RSA密钥对
[grid@rac2 ~]$ ssh-keygen -t rsa

rac1:

sql 复制代码
[grid@rac1 ~]$ scp .ssh/authorized_keys rac-2:/home/grid/.ssh

rac2:

sql 复制代码
# 将节点2的密钥写入到authorized_keys文件中
[grid@rac2 ~]$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys
# 拷贝authorized_keys文件至节点1
[grid@rac2 ~]$ scp .ssh/authorized_keys rac1:/home/grid/.ssh

oracle用户配置互信:su - oracle

rac1:

sql 复制代码
# 生成协议2版本的RSA密钥对
[oracle@rac1 ~]$ ssh-keygen -t rsa
# 将密钥内容复制到authorized_keys文件中
[oracle@rac1 ~]$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys

rac2:

sql 复制代码
# 生成协议2版本的RSA密钥对
[oracle@rac2 ~]$ ssh-keygen -t rsa

rac1:

sql 复制代码
[oracle@rac1 ~]$ scp .ssh/authorized_keys rac-2:/home/oracle/.ssh

rac2:

sql 复制代码
# 将节点2的密钥写入到authorized_keys文件中
[grid@rac2 ~]$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys
# 拷贝authorized_keys文件至节点1
[grid@rac2 ~]$ scp .ssh/authorized_keys rac1:/home/oracle/.ssh

测试grid和oracle用户互信

rac1:

ssh rac1 date; ssh rac2 date; ssh rac1priv date; ssh rac2priv date;

sql 复制代码
[root@rac1 ~]# su - grid
Last login: Sat Oct 12 07:07:27 UTC 2024 on pts/2
[grid@rac1 ~]$ ssh rac1 date; ssh rac2 date; ssh rac1priv date; ssh rac2priv date;
Sat Oct 12 09:37:27 UTC 2024
Sat Oct 12 09:37:27 UTC 2024
Sat Oct 12 09:37:27 UTC 2024
Sat Oct 12 09:37:27 UTC 2024
[grid@rac1 ~]$ su - oracle
[oracle@rac1 ~]$ ssh rac1 date; ssh rac2 date; ssh rac1priv date; ssh rac2priv date;
Sat Oct 12 09:38:19 UTC 2024
Sat Oct 12 09:38:19 UTC 2024
Sat Oct 12 09:38:19 UTC 2024
Sat Oct 12 09:38:19 UTC 2024
[oracle@rac1 ~]$

rac2:

ssh rac1 date; ssh rac2 date; ssh rac1priv date; ssh rac2priv date;

sql 复制代码
[root@rac2 ~]# su - grid
Last login: Sat Oct 12 07:07:27 UTC 2024 on pts/2
[grid@rac2 ~]$ ssh rac1 date; ssh rac2 date; ssh rac1priv date; ssh rac2priv date;
Sat Oct 12 09:37:27 UTC 2024
Sat Oct 12 09:37:27 UTC 2024
Sat Oct 12 09:37:27 UTC 2024
Sat Oct 12 09:37:27 UTC 2024
[grid@rac2 ~]$ su - oracle
[oracle@rac2 ~]$ ssh rac1 date; ssh rac2 date; ssh rac1priv date; ssh rac2priv date;
Sat Oct 12 09:38:19 UTC 2024
Sat Oct 12 09:38:19 UTC 2024
Sat Oct 12 09:38:19 UTC 2024
Sat Oct 12 09:38:19 UTC 2024
[oracle@rac2 ~]$

4.配置NFS共享存储(10.186.63.26 nfs)

4.1创建lvm(10.186.63.26 nfs服务端操作)

bash 复制代码
vgcreate vg01 /dev/vdb
vgcreate vg02 /dev/vdc
lvcreate -n lv01 -l 100%free vg01
lvcreate -n lv02 -l 100%free vg02

注意:lvcreate -n lv02 -l 100%free vg02&vg01创建的时候选择分配所有空间,不然后面安装grid执行root.sh时节点2可能会重新创建表决盘而无法加入集群。

4.2挂载共享目录

bash 复制代码
mkdir -p /ora_data
mkdir -p /ora_arch

mkfs.xfs /dev/vg01/lv01
mkfs.xfs /dev/vg02/lv02 

mount /dev/vg01/lv01 /ora_data
mount /dev/vg02/lv02 /ora_arch

vi /etc/fstab
/dev/vg01/lv01 /ora_data  xfs defaults 0 0 
/dev/vg02/lv02 /ora_arch  xfs defaults 0 0 

mount -a 

/ora_data存放oracle数据,ora_arch存放归档日志

#挂载后如图:

4.3配置NFS共享目录,让目标节点可以识别到

bash 复制代码
yum install -y nfs-utils rpcbind


vi /etc/exports
#rac1\rac2-ASM
/ora_data 10.186.63.52/32(rw,sync,no_wdelay,insecure,no_root_squash)
/ora_data 10.186.63.53/32(rw,sync,no_wdelay,insecure,no_root_squash)

#ra1\rac2-arch
/ora_arch 10.186.63.52/32(rw,sync,no_wdelay,insecure,no_root_squash)
/ora_arch 10.186.63.53/32(rw,sync,no_wdelay,insecure,no_root_squash)



systemctl start nfs-server.service && systemctl enable nfs-server.service
systemctl status nfs-server

exportfs -v

10.186.63.52&53为oracle rac两个节点ip

#配置好后截图如下:

4.4创建ASM磁盘组

mkdir /ora_data/oracleasm/

mkdir /ora_arch/oracleasm/

bash 复制代码
dd if=/dev/zero of=/ora_data/oracleasm/ocr1 bs=8192k count=1280
dd if=/dev/zero of=/ora_data/oracleasm/ocr2 bs=8192k count=1280
dd if=/dev/zero of=/ora_data/oracleasm/ocr3 bs=8192k count=1280
dd if=/dev/zero of=/ora_data/oracleasm/fra  bs=8192k count=2560
dd if=/dev/zero of=/ora_data/oracleasm/data bs=8192k count=6400

4.5 nfs客户端配置(rac1和rac2)

sql 复制代码
yum install nfs-utils -y

systemctl start nfs-server.service && systemctl enable nfs-server.service

systemctl status nfs-server.service

showmount -e 10.186.63.26

mkdir /ora_data /ora_arch

#设置开机自动挂载

vi /etc/fstab

sql 复制代码
10.186.63.26:/ora_data  /ora_data  nfs rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0 0 0
10.186.63.26:/ora_arch  /ora_arch  nfs rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0 0 0

#手动挂载

mount -a

#更改属主和执行权限(rac1&rac2任意节点执行)

bash 复制代码
chown -R grid:asmadmin /ora_data/oracleasm/ocr1
chown -R grid:asmadmin /ora_data/oracleasm/ocr2
chown -R grid:asmadmin /ora_data/oracleasm/ocr3
chown -R grid:asmadmin /ora_data/oracleasm/fra
chown -R grid:asmadmin /ora_data/oracleasm/data

chmod -R 660 /ora_data/oracleasm/ocr1
chmod -R 660 /ora_data/oracleasm/ocr2
chmod -R 660 /ora_data/oracleasm/ocr3
chmod -R 660 /ora_data/oracleasm/fra
chmod -R 660 /ora_data/oracleasm/data

ls -l /ora_data/oracleasm/*

5.上传安装包并解压(rac1节点执行即可)

sql 复制代码
unzip p13390677_112040_Linux-x86-64_1of7.zip -d /u01/software
unzip p13390677_112040_Linux-x86-64_2of7.zip -d /u01/software
unzip p13390677_112040_Linux-x86-64_3of7.zip -d /u01/software
chown -R grid:oinstall /u01/software/grid
chown -R oracle:oinstall /u01/software/database

6.安装依赖包(rac1&&rac2)

sql 复制代码
yum -y install gcc* compat-libstdc* elfutils-libelf-devel* glibc-devel* glibc-headers* libaio-devel* libstdc* ksh* compat-libcap1*
rpm -ivh pdksh-5.2.14-30.x86_64.rpm --force --nodeps
rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm

# 安装Grid软件带的依赖包
rpm -ivh /u01/software/grid/rpm/cvuqdisk-1.0.9-1.rpm

7.安装前校验(一个节点执行即可)

sql 复制代码
[grid@rac1 ~]$ cd /u01/software/grid
# 校验
[grid@rac1 grid]$ ./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -verbose

根据报错调整,重新执行检查

#添加swap

sql 复制代码
dd if=/dev/zero of=/home/swap bs=8M count=1000

mkswap /home/swap

swapon /home/swap

echo "/home/swap swap swap defaults 0 0" >>/etc/fstab

8.静默安装Grid软件

8.1 grid用户登录rac1进行安装

sql 复制代码
# 进入响应文件目录
[grid@rac1 grid]$ cd response
# 编辑Grid软件
[grid@rac1 response]$ vim grid_install.rsp

#文件末尾添加如下内容:

sql 复制代码
INVENTORY_LOCATION=/u01/app/oraInventory
oracle.install.option=CRS_CONFIG
ORACLE_BASE=/u01/app/grid
ORACLE_HOME=/u01/app/11.2.0/grid
oracle.install.asm.OSDBA=asmdba
oracle.install.asm.OSOPER=asmoper
oracle.install.asm.OSASM=asmadmin
oracle.install.crs.config.gpnp.scanName=racscan
oracle.install.crs.config.gpnp.scanPort=1521
oracle.install.crs.config.clusterName=rac
oracle.install.crs.config.autoConfigureClusterNodeVIP=false
oracle.install.crs.config.clusterNodes=rac1:rac1vip,rac2:rac2vip
oracle.install.crs.config.networkInterfaceList=eth0:10.186.63.0:1,eth1:10.186.202.0:2
oracle.install.crs.config.storageOption=ASM_STORAGE
oracle.install.asm.SYSASMPassword=orcl
oracle.install.asm.diskGroup.name=OCR
oracle.install.asm.diskGroup.redundancy=NORMAL
oracle.install.asm.diskGroup.AUSize=4
oracle.install.asm.diskGroup.disks=/ora_data/oracleasm/ocr1,/ora_data/oracleasm/ocr2,/ora_data/oracleasm/ocr3
oracle.install.asm.diskGroup.diskDiscoveryString=/ora_data/oracleasm/*
oracle.install.asm.monitorPassword=orcl

8.2安装

sql 复制代码
cd ..
./runInstaller -silent -responseFile /u01/software/grid/response/grid_install.rsp -ignorePrereq

8.3 配置ohas.service

linux 7安装Oracle11g rac 在执行root.sh时有bug,上面没有打补丁,用如下方式解决。

sql 复制代码
cat<<EOF>/usr/lib/systemd/system/ohas.service
[Unit]
Description=Oracle High Availability Services
After=syslog.target
 
[Service]
ExecStart=/etc/init.d/init.ohasd run >/dev/null 2>&1 Type=simple
Restart=always
 
[Install]
WantedBy=multi-user.target
EOF

#启动服务

sql 复制代码
systemctl daemon-reload && systemctl enable ohas.service && systemctl start ohas.service && systemctl status ohas.service

8.4切换root用户执行root.sh脚本

rac1:

sql 复制代码
[root@rac1 ~]# /u01/app/oraInventory/orainstRoot.sh
[root@rac1 ~]# /u01/app/11.2.0/grid/root.sh

#执行过程中启ohas.service

sql 复制代码
systemctl daemon-reload && systemctl enable ohas.service && systemctl start ohas.service && systemctl status ohas.service

#查看日志

注意:rac1执行完再去rac2执行

rac2:

sql 复制代码
[root@rac2 ~]# /u01/app/oraInventory/orainstRoot.sh
[root@rac2 ~]# /u01/app/11.2.0/grid/root.sh

#执行root.sh过程中ohas.service

sql 复制代码
systemctl daemon-reload && systemctl enable ohas.service && systemctl start ohas.service && systemctl status ohas.service

查看日志:

8.4 检查grid集群进程

#集群状态:crsctl status res -t ,确保rac1和rac2都有相关进程

rac1:

rac2:

9.静默配置其他ASM磁盘

Grid软件安装完成后,就需要配置其他ASM磁盘组了,例如DATA\FRA等。

rac1:

sql 复制代码
# 进入到sqlplus命令行
[grid@rac1 grid]$ sqlplus / as sysasm
# 创建FRA磁盘组
create diskgroup FRA external redundancy disk '/ora_data/oracleasm/fra';
#创建DATA磁盘组
create diskgroup DATA external redundancy disk '/ora_data/oracleasm/data';
#查看磁盘组状态
select state,name,type,total_mb, free_mb from v$asm_diskgroup_stat ;

rac2:

sql 复制代码
[grid@rac2 ~]$ export ORACLE_SID=+ASM2
# 进入到sqlplus命令行
[grid@rac2 grid]$ sqlplus / as sysasm
# 挂载FRA磁盘组
SQL> alter diskgroup FRA mount;
# 挂载DATA磁盘组
SQL> alter diskgroup DATA mount;
# 查看磁盘组状态
SQL> select state,name,type,total_mb, free_mb from v$asm_diskgroup_stat ;

10.静默安装oracle软件

10.1检查产品清单文件crs属性

检查HOME标签中是否有CRS属性,如果没有,则手动加上。注意,CRS必须大写。

sql 复制代码
su - oracle
vim /u01/app/oraInventory/ContentsXML/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" CRS="true">
   <NODE_LIST>
      <NODE NAME="rac-1"/>
      <NODE NAME="rac-2"/>
   </NODE_LIST>
</HOME>
</HOME_LIST>
<COMPOSITEHOME_LIST>
</COMPOSITEHOME_LIST>
</INVENTORY>

10.2静默安装Oracle软件

sql 复制代码
# oracle用户进入到响应文件中
[oracle@rac1 ~]$ cd /u01/software/database/response
# 编辑响应文件
[oracle@rac1 response]$ vim db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.CLUSTER_NODES=rac1,rac2
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES

10.3静默安装

sql 复制代码
# 退至上一级目录
[oracle@rac1 response]$ cd ..
# 静默安装
[oracle@rac1 database]$ ./runInstaller -silent -responseFile /u01/software/database/response/db_install.rsp -ignorePrereq

10.4执行root脚本

执行后根据提示的日志文件目录去查看下日志,看是否有报错。

rac2:

sql 复制代码
 /u01/app/oraInventory/orainstRoot.sh

rac1:

sql 复制代码
 /u01/app/oracle/product/11.2.0/dbhome_1/root.sh

rac2:

sql 复制代码
 /u01/app/oracle/product/11.2.0/dbhome_1/root.sh

11.添加监听至集群中(rac1&rac2)

grid用户登录rac1和rac2执行

sql 复制代码
su - grid
srvctl status listener
# 添加监听
srvctl add listener
srvctl start listener
srvctl status listener

12.安装数据库

12.1编辑dbca.rsp响应文件

sql 复制代码
# 进入响应文件目录
[oracle@rac1 ~]$ cd /u01/software/database/response
# 编辑响应文件
[oracle@rac1 response]$ mv dbca.rsp dbca.rsp_bak
[oracle@rac1 response]$ vim  dbca.rsp 

[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"

[CREATEDATABASE]
GDBNAME = "orcl11g"
SID = "orcl11g"
NODELIST=rac1,rac2
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "orcl"
SYSTEMPASSWORD = "orcl"
DATAFILEDESTINATION ="+DATA"
RECOVERYAREADESTINATION="+FRA"
STORAGETYPE=ASM
DISKGROUPNAME=DATA
CHARACTERSET = "AL32UTF8"
DATABASETYPE = "OLTP"

[createTemplateFromDB]
SOURCEDB = "myhost:1521:orcl"
SYSDBAUSERNAME = "system"
TEMPLATENAME = "My Copy TEMPLATE"

[createCloneTemplate]
SOURCEDB = "orcl"
TEMPLATENAME = "My Clone TEMPLATE"

[DELETEDATABASE]
SOURCEDB = "orcl"

[generateScripts]
TEMPLATENAME = "New Database"
GDBNAME = "orcl11.us.oracle.com"

[CONFIGUREDATABASE]

[ADDINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
SYSDBAUSERNAME = "sys"

[DELETEINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
INSTANCENAME = "orcl11g"
SYSDBAUSERNAME = "sys"

12.1静默安装(在rac1节点执行即可)

sql 复制代码
[oracle@rac1 response]$ dbca -silent -responseFile /u01/software/database/response/dbca.rsp

#登录oracle数据库验证是否安装成功(rac1&rac2)

13.检查集群状态

su - grid

crsctl status res -t

相关推荐
远歌已逝1 小时前
维护在线重做日志(二)
数据库·oracle
qq_433099403 小时前
Ubuntu20.04从零安装IsaacSim/IsaacLab
数据库
Dlwyz3 小时前
redis-击穿、穿透、雪崩
数据库·redis·缓存
工业甲酰苯胺4 小时前
Redis性能优化的18招
数据库·redis·性能优化
没书读了5 小时前
ssm框架-spring-spring声明式事务
java·数据库·spring
i道i6 小时前
MySQL win安装 和 pymysql使用示例
数据库·mysql
小怪兽ysl6 小时前
【PostgreSQL使用pg_filedump工具解析数据文件以恢复数据】
数据库·postgresql
wqq_9922502776 小时前
springboot基于微信小程序的食堂预约点餐系统
数据库·微信小程序·小程序
爱上口袋的天空7 小时前
09 - Clickhouse的SQL操作
数据库·sql·clickhouse
聂 可 以8 小时前
Windows环境安装MongoDB
数据库·mongodb