1. 环境描述
1.1. 操作系统
-
CPU
~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 2 Intel(R) Xeon(R) CPU E5-2683 v4 @ 2.10GHz
-
内存
~]# free -m total used free shared buff/cache available Mem: 7982 626 6832 13 524 7063 Swap: 8063 0 8063
-
操作系统
~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)
1.2. 对物理磁盘进行逻辑卷管理
两块磁盘分别为:sdb 与 sdc,使用 lvm
创建多个逻辑卷来用作 Oracle ASM
磁盘。
- LVM 操作命令
# 创建 PV
~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
~]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.
# 创建 VG
~]# vgcreate vgOra /dev/sdb /dev/sdc
Volume group "vgOra" successfully created
# 查看 VG
~]# vgs vgOra
VG #PV #LV #SN Attr VSize VFree
vgOra 2 0 0 wz--n- 319.99g 319.99g
# 创建 LV
~]# lvcreate -n lvASM1 -L 10G vgOra
Logical volume "lvASM1" created.
~]# lvcreate -n lvASM2 -L 10G vgOra
Logical volume "lvASM2" created.
~]# lvcreate -n lvASM3 -L 10G vgOra
Logical volume "lvASM3" created.
~]# lvcreate -n lvASM4 -L 10G vgOra
Logical volume "lvASM4" created.
~]# lvcreate -n lvASM5 -L 10G vgOra
Logical volume "lvASM5" created.
~]# lvcreate -n lvASM6 -L 120G vgOra
Logical volume "lvASM6" created.
~]# lvcreate -n lvXFS -l 100%FREE vgOra
Logical volume "lvXFS" created.
~]# lvs vgOra
LV VG Attr LSize
lvASM1 vgOra -wi-a----- 10.00g
lvASM2 vgOra -wi-a----- 10.00g
lvASM3 vgOra -wi-a----- 10.00g
lvASM4 vgOra -wi-a----- 10.00g
lvASM5 vgOra -wi-a----- 10.00g
lvASM6 vgOra -wi-a----- 120.00g
lvXFS vgOra -wi-a----- 149.99g
2. 安装前置软件包
前置安装包的版本必须与操作系统相匹配,否则会安装失败。
2.1. 配置YUM源
挂载操作系统ISO文件,并配置好repo文件,如下:
mkdir -p /mnt/cdrom
mount -t iso9660 -o loop /media/CentOS-7.6-x86_64-DVD-1810.iso /mnt/cdrom/
vim /etc/yum.repos.d/rhel7.repo
添加如下内容:
[rhel7]
name=base
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1
2.2. 下载预(前置)安装rpm包并安装
如果服务器可以上网,可以直接使用如下命令进行前置软件包安装:
yum install -y https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-2.el7.x86_64.rpm
如果服务器不能上网,可以先下载前置安装包,地址为:http://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/ ,在此目录下找到oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm 下载后上传到数据库服务器上。安装oracle-database-preinstall需要很多依赖包,如果有yum源可以自动解决依赖关系,如果没有只能提前准备好安装包。
yum localinstall -y /media/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
部分内容显示如下:
~]# yum installoracle-database-preinstall-19c-1.0-2.el7.x86_64.rpm -y
Loaded plugins: product-id,search-disabled-repos, subscription-manager
This system is not registered with anentitlement server. You can use subscription-manager to register.
Examiningoracle-database-preinstall-19c-1.0-2.el7.x86_64.rpm:oracle-database-preinstall-19c-1.0-2.el7.x86_64
Marking oracle-database-preinstall-19c-1.0-2.el7.x86_64.rpmto be installed
Resolving Dependencies
..........省略部分信息..........
Installed:
oracle-database-preinstall-19c.x86_64 0:1.0-2.el7
Dependency Installed:
bc.x86_64 0:1.06.95-13.el7 bind-libs.x86_64 32:9.9.4-50.el7 bind-utils.x86_64 32:9.9.4-50.el7 compat-libcap1.x86_64 0:1.10-7.el7
gssproxy.x86_64 0:0.7.0-4.el7 keyutils.x86_64 0:1.5.8-3.el7 libXinerama.x86_64 0:1.1.3-2.1.el7 libXmu.x86_64 0:1.1.2-2.el7
libXrandr.x86_64 0:1.5.1-2.el7 libXt.x86_64 0:1.1.5-3.el7 libXv.x86_64 0:1.0.11-1.el7 libXxf86dga.x86_64 0:1.1.4-2.1.el7
libXxf86misc.x86_64 0:1.0.3-7.1.el7 libaio-devel.x86_64 0:0.3.109-13.el7 libbasicobjects.x86_64 0:0.1.1-27.el7 libcollection.x86_64 0:0.6.2-27.el7
libdmx.x86_64 0:1.1.3-3.el7 libevent.x86_64 0:2.0.21-4.el7 libini_config.x86_64 0:1.3.0-27.el7 libnfsidmap.x86_64 0:0.25-17.el7
libpath_utils.x86_64 0:0.2.1-27.el7 libref_array.x86_64 0:0.1.5-27.el7 libstdc++-devel.x86_64 0:4.8.5-16.el7 libtirpc.x86_64 0:0.2.4-0.10.el7
libverto-libevent.x86_64 0:0.2.5-4.el7 mailx.x86_64 0:12.5-16.el7 nfs-utils.x86_64 1:1.3.0-0.48.el7 psmisc.x86_64 0:22.20-15.el7
quota.x86_64 1:4.01-14.el7 quota-nls.noarch 1:4.01-14.el7 rpcbind.x86_64 0:0.2.0-42.el7 smartmontools.x86_64 1:6.2-8.el7
tcp_wrappers.x86_64 0:7.6-77.el7 unzip.x86_64 0:6.0-16.el7 xorg-x11-utils.x86_640:7.5-22.el7 xorg-x11-xauth.x86_641:1.0.9-1.el7
Complete!
2.3. 预安装rpm包对操作系统的更改
Oracle 数据库预安装 RPM 将执行以下操作:
-
Automatically downloads and installs any additional RPM packages needed for installing Oracle Grid Infrastructure and Oracle Database, and resolves any dependencies.
自动下载和安装安装 Oracle Grid Infrastructure 和 Oracle 数据库所需的任何其他 RPM 包,并解决任何依赖关系。 -
Creates an oracle user, and creates the oraInventory (oinstall) and OSDBA (dba) groups for that user(创建一个 oracle 用户,并为该用户创建 oraInventory (oinstall) 和 OSDBA (dba) 组)
预安装rpm包创建了oinstall组、dba组、oper组、backupdba组、dgdba组、kmdba组、racdba组,同时创建了oracle用户。Oracle用户与各组的关系为:~]# id oracle uid=54324(oracle) gid=54332(oinstall) 组=54332(oinstall),54333(dba),54334(oper),54335(backupdba),54336(dgdba),54337(kmdba),54338(racdba)
-
As needed, sets sysctl.conf settings, system startup parameters, and driver parameters to values based on recommendations from the Oracle Database Preinstallation RPM program(根据需要,根据 Oracle 数据库预安装 RPM 程序的建议将 sysctl.conf 设置、系统启动参数和驱动程序参数设置为值)
预安装rpm包在目录/etc/sysctl.d/
下创建了两个文件,分别为:99-initial-sysctl.conf
、99-oracle-database-preinstall-19c-sysctl.conf
。 -
Sets hard and soft resource limits(设置硬资源和软资源限制)
预安装rpm包在目录/etc/security/limits.d/
下创建了一个文件:oracle-database-preinstall-19c.conf
。 -
Sets other recommended parameters, depending on your kernel version(设置其他推荐参数,具体取决于您的内核版本)
比如NOZEROCONF参数的配置~]# echo "NOZEROCONF=yes" >> /etc/sysconfig/network
-
Sets numa=off in the kernel for Linux x86_64 machines.(在 Linux x86_64 机器的内核中设置 numa=off。)
修改了文件/etc/default/grub
,在GRUB_CMDLINE_LINUX配置中增加了numa=off
:~]# 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="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet numa=off transparent_hugepage=never" GRUB_DISABLE_RECOVERY="true"
重新编译
grub2-mkconfig -o /etc/grub2.cfg
3. 其他系统配置
3.1. 配置 /etc/hosts 文件
~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.5.103 dbtest dbtest.zytk.com
3.2. 关闭selinux
使用root用户执行下列命令:
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
setenforce 0
3.3. 添加asm相关的组以及grid用户
使用root用户执行下列命令:
groupadd -g 54327 asmdba
groupadd -g 54328 asmoper
groupadd -g 54329 asmadmin
useradd -u 54322 -g oinstall -G asmadmin,asmdba,asmoper,dba,racdba -d /home/grid grid
3.4. 为grid用户与oracle用户设置密码
使用root用户执行下列命令:
echo "60%7hNPUe" | passwd --stdin oracle
echo "ylzVbZ5F6+" | passwd --stdin grid
3.5. 修改grid用户的资源限制
使用 root
用户在文件 /etc/security/limits.d/oracle-database-preinstall-19c.conf
末尾添加如下内容:
grid soft nofile 1024
grid hard nofile 65536
grid soft nproc 16384
grid hard nproc 16384
grid soft stack 10240
grid hard stack 32768
grid hard memlock 134217728
grid soft memlock 134217728
grid soft data unlimited
grid hard data unlimited
其中:
-
设置限制数量,第一列表示用户,* 表示所有用户
-
hard xxx : 代表严格的设定,不允许超过这个设定的值。
-
soft xxx : 代表警告的设定,可以超过这个设定值,但是超过后会有警告。
如:soft 设为1024,hard设为2048 ,则当你使用数在1~1024之间时可以随便使用,1024~2048时会出现警告信息,大于2048时,就会报错。 -
"nproc" 和 "nofile"的区别
nproc : 是操作系统级别对每个用户创建的进程数的限制
nofile : 是每个进程可以打开的文件数的限制
soft nproc :单个用户可用的最大进程数量(超过会警告);
hard nproc:单个用户可用的最大进程数量(超过会报错);
soft nofile :可打开的文件描述符的最大数(超过会警告);
hard nofile :可打开的文件描述符的最大数(超过会报错); -
data----------最大数据大小(KB)
-
memlock-----最大可用内存空间(KB)
-
stack----------最大堆栈空间(KB)
-
重启后生效,另外需要注意:
①. 一般soft的值会比hard小,也可相等。
②. /etc/security/limits.d/里面配置会覆盖/etc/security/limits.conf的配置
③. 只有root用户才有权限修改/etc/security/limits.conf
④. 如果limits.conf没有做设定,则默认值是1024
3.6. 创建目录并赋目录权限
使用root用户执行下列命令,具体的目录结构可根据实际情况进行创建。
mkdir -p /opt/oracle # 使用rpm安装时,Oracle软件被安装在/opt/oracle目录
mkdir -p /opt/oracle/product/19c/grid
mkdir -p /u01/app/19c/grid
mkdir -p /u01/app/grid
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/19c/grid
3.7. 配置grid用户环境变量
切换到 grid
用户,并编辑 ~/.bash_profile
文件,在其末尾添加如下内容:
export ORACLE_SID=+ASM
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/19c/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:.
export NLS_LANG=American_america.ZHS16GBK
export PATH=$PATH:$ORACLE_HOME/bin:.
3.8. 配置oracle用户环境变量
切换到 oracle
用户,并编辑 ~/.bash_profile
文件,在其末尾添加如下内容:
export ORACLE_SID=zyzh
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19c/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:.
export NLS_LANG=american_america.ZHS16GBK
export NLS_DATE_FORMAT="yyyy-MM-dd hh24:mi:ss"
export PATH=$PATH:$ORACLE_HOME/bin:.
4. 配置ASM磁盘
使用asmlib+逻辑卷来配置ASM磁盘。
主要参考:https://www.xmmup.com/dbbao7oracle-19c-asmdbdeanzhuangpeizhi.html/2
4.1. 安装kmod-oracleasm
-
下载kmod-oracleasm
在http://rpm.pbone.net/
下载对应版本的 kmod-oracleasm,我这里下载的是:
-
安装kmod-oracleasm
~]# rpm -Uvh kmod-oracleasm-2.0.8-22.el7.x86_64.rpm 准备中... ################################# [100%] 正在升级/安装... 1:kmod-oracleasm-2.0.8-22.el7 ################################# [ 50%] 正在清理/删除... 2:kmod-oracleasm-2.0.8-19.el7 ################################# [100%]
4.3. 安装oracleasmlib和oracleasm-support
-
下载oracleasmlib和oracleasm-support
地址为:https://www.oracle.com/linux/downloads/linux-asmlib-rhel7-downloads.html
下载到的文件分别为:oracleasm-support-2.1.11-2.el7.x86_64.rpm
、oracleasmlib-2.0.12-1.el7.x86_64.rpm
-
安装oracleasmlib和oracleasm-support
~]# rpm -ivh oracleasm-support-2.1.11-2.el7.x86_64.rpm 警告:oracleasm-support-2.1.11-2.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:oracleasm-support-2.1.11-2.el7 ################################# [100%] 注意:正在将请求转发到“systemctl enable oracleasm.service”。 Created symlink from /etc/systemd/system/multi-user.target.wants/oracleasm.service to /usr/lib/systemd/system/oracleasm.service. ~]# rpm -ivh oracleasmlib-2.0.12-1.el7.x86_64.rpm 警告:oracleasmlib-2.0.12-1.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:oracleasmlib-2.0.12-1.el7 ################################# [100%]
4.3. 配置asmlib
~]# oracleasm configure -i
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting <ENTER> without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: grid <-----
Default group to own the driver interface []: asmadmin <-----
Start Oracle ASM library driver on boot (y/n) [n]: y <-----
Scan for Oracle ASM disks on boot (y/n) [y]: y <-----
Writing Oracle ASM library driver configuration: done
~]# oracleasm configure -d
Writing Oracle ASM library driver configuration: done
~]# oracleasm configure -e
Writing Oracle ASM library driver configuration: done
~]# oracleasm init <----若初始化失败,则尝试重启OS
Creating /dev/oracleasm mount point: /dev/oracleasm
Loading module "oracleasm": oracleasm
Configuring "oracleasm" to use device physical block size
Mounting ASMlib driver filesystem: /dev/oracleasm
- 最终状态
~]# oracleasm status Checking if ASM is loaded: yes Checking if /dev/oracleasm is mounted: yes
4.4. 创建ASM磁盘
-
清空磁头信息
dd if=/dev/zero of=/dev/vgOra/lvASM1 bs=1k count=1 dd if=/dev/zero of=/dev/vgOra/lvASM2 bs=1k count=1 dd if=/dev/zero of=/dev/vgOra/lvASM3 bs=1k count=1 dd if=/dev/zero of=/dev/vgOra/lvASM4 bs=1k count=1 dd if=/dev/zero of=/dev/vgOra/lvASM5 bs=1k count=1 dd if=/dev/zero of=/dev/vgOra/lvASM6 bs=1k count=1
-
创建ASM磁盘
oracleasm createdisk ASM1 /dev/vgOra/lvASM1 oracleasm createdisk ASM2 /dev/vgOra/lvASM2 oracleasm createdisk ASM3 /dev/vgOra/lvASM3 oracleasm createdisk ASM4 /dev/vgOra/lvASM4 oracleasm createdisk ASM5 /dev/vgOra/lvASM5 oracleasm createdisk ASM6 /dev/vgOra/lvASM6
-
修改设备文件的权限
chown grid:asmadmin /dev/vgOra/lvASM1 chown grid:asmadmin /dev/vgOra/lvASM2 chown grid:asmadmin /dev/vgOra/lvASM3 chown grid:asmadmin /dev/vgOra/lvASM4 chown grid:asmadmin /dev/vgOra/lvASM5 chown grid:asmadmin /dev/vgOra/lvASM6
-
在创建完成后,结果示例
~]# oracleasm listdisks ASM1 ASM2 ASM3 ASM4 ASM5 ASM6
5. Grid安装
5.1. 下载grid安装包并上传到数据库服务器
从Oracle官方网站:https://www.oracle.com/database/technologies/oracle19c-linux-downloads.html 上,下载grid的安装包:Oracle Database 19c Grid Infrastructure (19.3) for Linux x86-64
,然后利用工具将其上传到数据库服务器。
上传路径为:/u01/app/19c/grid
5.2. 解压grid安装包
使用grid用户执行下列命令:
cd /u01/app/19c/grid
unzip LINUX.X64_193000_grid_home.zip
5.3. 安装cvuqdisk
使用root用户执行下列命令:
cd /u01/app/19c/grid/cv/rpm
rpm -ivh cvuqdisk-1.0.10-1.rpm
5.4. 编辑响应文件
模板在 $GRID_HOME/inventory/response/grid_install.rsp
想了解参数具体用途的可以看模板里的说明:
-- touch /home/grid/gi.rsp 内容如下:
oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v19.0.0
INVENTORY_LOCATION=/u01/app/oraInventory
oracle.install.option=HA_CONFIG
ORACLE_BASE=/u01/app/grid
oracle.install.asm.OSDBA=asmdba
oracle.install.asm.OSOPER=asmoper
oracle.install.asm.OSASM=asmadmin
oracle.install.crs.config.scanType=LOCAL_SCAN
oracle.install.crs.config.ClusterConfiguration=STANDALONE
oracle.install.crs.config.configureAsExtendedCluster=false
oracle.install.crs.config.gpnp.configureGNS=false
oracle.install.crs.config.autoConfigureClusterNodeVIP=false
oracle.install.crs.config.gpnp.gnsOption=CREATE_NEW_GNS
oracle.install.crs.configureGIMR=false
oracle.install.asm.configureGIMRDataDG=false
oracle.install.crs.config.useIPMI=false
oracle.install.asm.SYSASMPassword=Password123!
oracle.install.asm.diskGroup.name=DG1
oracle.install.asm.diskGroup.redundancy=NORMAL
oracle.install.asm.diskGroup.AUSize=4
oracle.install.asm.diskGroup.disks=/dev/vgOra/lvASM1,/dev/vgOra/lvASM2,/dev/vgOra/lvASM3
oracle.install.asm.diskGroup.diskDiscoveryString=/dev/vgOra/lvASM*
oracle.install.asm.monitorPassword=Password123!
oracle.install.asm.configureAFD=false
oracle.install.crs.configureRHPS=false
oracle.install.crs.config.ignoreDownNodes=false
oracle.install.config.managementOption=NONE
oracle.install.config.omsPort=0
oracle.install.crs.rootconfig.executeRootScript=false
5.5. 安装前precheck
使用grid用户执行下列命令,如有问题按提示调整:
$ORACLE_HOME/runcluvfy.sh stage -pre crsinst -n dbtest -fixup -verbose
5.6. 安装过程
使用grid用户执行下列命令:
$ORACLE_HOME/gridSetup.sh -silent -responseFile /home/grid/gi.rsp
执行脚本的日志如下
~]# /u01/app/19c/grid/root.sh
Check /u01/app/19c/grid/install/root_dbtest.zytk.com_2022-06-27_17-48-28-191608815.log for the output of root script
~]# cat /u01/app/19c/grid/install/root_dbtest.zytk.com_2022-06-27_17-48-28-191608815.log
Performing root user operation.
The following environment variables are set as:
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/19c/grid
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
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.
Using configuration parameter file: /u01/app/19c/grid/crs/install/crsconfig_params
The log of current session can be found at:
/u01/app/grid/crsdata/dbtest/crsconfig/roothas_2022-06-27_05-48-29PM.log
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node dbtest successfully pinned.
2022/06/27 17:48:41 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'
dbtest 2022/06/27 17:49:22 /u01/app/grid/crsdata/dbtest/olr/backup_20220627_174922.olr 724960844
2022/06/27 17:49:23 CLSRSC-327: Successfully configured Oracle Restart for a standalone server
5.7. 配置
使用grid用户执行下列命令:
$ORACLE_HOME/gridSetup.sh -executeConfigTools -responseFile /home/grid/gi.rsp -silent
5.8. 查看Resource状态
使用grid用户执行下列命令:
crsctl status resource -t
5.9. 创建DG2、DG3磁盘组
使用grid用户执行下列命令:
sqlplus / as sysasm
create diskgroup DG2 EXTERNAL redundancy disk '/dev/vgOra/lvASM4','/dev/vgOra/lvASM5' attribute 'compatible.rdbms'='19.0','compatible.asm'='19.0','au_size'='4M';
create diskgroup DG3 EXTERNAL redundancy disk '/dev/vgOra/lvASM6' attribute 'compatible.rdbms'='19.0','compatible.asm'='19.0','au_size'='4M';
-
查看磁盘组信息
column name format a10 set line 120 SELECT name,state,type,total_mb,free_mb,usable_file_mb,offline_disks FROM v$asm_diskgroup;
-
查看ASM磁盘信息
SET LINES 300 PAGES 999 COLUMN groupname FORMAT a5 COLUMN diskname FORMAT a10 COLUMN path FORMAT a30 SELECT a.group_number,a.name as groupname,b.name as diskname,a.type, b.state as diskstate,b.total_mb,b.free_mb,b.mount_status,b.path FROM v$asm_diskgroup a,v$asm_disk b WHERE a.group_number=b.group_number ORDER BY 1,2;
6. 利用RPM包安装Oracle软件
6.1. 下载RPM包并上传到数据库服务器
从Oracle官方网站:https://www.oracle.com/database/technologies/oracle19c-linux-downloads.html 上,下载Oracle 19c的RPM包文件:oracle-database-ee-19c-1.0-1.x86_64.rpm
,然后利用工具将其上传到数据库服务器。
6.2. 安装 oracle-database-ee-19c-1.0-1.x86_64.rpm
使用root用户执行下列命令安装Oracle软件,注意Oracle软件被安装在 /opt/oracle
目录下。
~]# yum localinstall /media/oracle-database-ee-19c-1.0-1.x86_64.rpm
已加载插件:fastestmirror, langpacks
正在检查 oracle-database-ee-19c-1.0-1.x86_64.rpm: oracle-database-ee-19c-1.0-1.x86_64
oracle-database-ee-19c-1.0-1.x86_64.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 oracle-database-ee-19c.x86_64.0.1.0-1 将被 安装
--> 解决依赖关系完成
依赖关系解决
============================================================================================================================================================================================================================
Package 架构 版本 源 大小
============================================================================================================================================================================================================================
正在安装:
oracle-database-ee-19c x86_64 1.0-1 /oracle-database-ee-19c-1.0-1.x86_64 6.9 G
事务概要
============================================================================================================================================================================================================================
安装 1 软件包
总计:6.9 G
安装大小:6.9 G
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
** 发现 2 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
2:postfix-2.10.1-7.el7.x86_64 有缺少的需求 libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-7.el7.x86_64 有缺少的需求 libmysqlclient.so.18(libmysqlclient_18)(64bit)
正在安装 : oracle-database-ee-19c-1.0-1.x86_64 1/1
[INFO] Executing post installation scripts...
[INFO] Oracle home installed successfully and ready to be configured.
To configure a sample Oracle Database you can execute the following service configuration script as root: /etc/init.d/oracledb_ORCLCDB-19c configure
验证中 : oracle-database-ee-19c-1.0-1.x86_64 1/1
已安装:
oracle-database-ee-19c.x86_64 0:1.0-1
完毕!
7. 创建数据库(使用DG3磁盘组)
7.1. 配置创建数据库的响应文件
静默方式使用dbca.rsp来创建数据库
# 切换到 oracle 用户
su - oracle
mkdir ~/response
cp $ORACLE_HOME/assistants/dbca/dbca.rsp /home/oracle/response/
设置以下参数(注意:Oracle11g安装时字符串参数带引号输入,但Oracle 19c需要删除引号,否则会报错,变量设置路径是也不支持$ORACLE_BASE的写法)
以 oracle 用户执行如下命令:
vim ~/response/dbca.rsp
以下每个配置参数都请根据实际情况进行填写:
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0
gdbName=zyzh.zytk.com
sid=zyzh
databaseConfigType=SI
policyManaged=FALSE
createServerPool=FALSE
serverPoolName=
createAsContainerDatabase=true
numberOfPDBs=1
pdbName=etdb
useLocalUndoForPDBs=TRUE
pdbAdminPassword=Hz571!xy00yz
templateName=/opt/oracle/product/19c/dbhome_1/assistants/dbca/templates/General_Purpose.dbc
sysPassword=Hz571!xy00yz
systemPassword=Hz571!xy00yz
runCVUChecks=true
dbsnmpPassword=Hz571!xy00yz
dvConfiguration=False
olsConfiguration=False
datafileJarLocation=/opt/oracle/product/19c/dbhome_1/assistants/dbca/templates/
storageType=ASM
datafileDestination=DG3
diskGroupName=DG3
asmsnmpPassword=Hz571!xy00yz
recoveryGroupName=DG2
characterSet=ZHS16GBK
nationalCharacterSet=AL16UTF16
registerWithDirService=FALSE
sampleSchema=FALSE
memoryPercentage=50
databaseType=MULTIPURPOSE
automaticMemoryManagement=FALSE
dbsnmpPassword=Hz571!xy00yz
emConfiguration=NONE
7.2. 修改oracle用户的属组
以 root 用户执行如下命令:
usermod -g oinstall -G dba,oper,asmdba oracle
如果Oracle用户不属于asmdba组的话,则静默安装时无法使用ASM磁盘组,报: [DBT-05801] There are no ASM disk groups detected。具体见MOS文档:(Doc ID 2318267.1)
7.3. 确认$ORACLE_HOME/bin/oracle文件权限是否有问题
确认$ORACLE_HOME/bin/oracle文件权限是否有问题(在rac下需要查看$ORACLE_HOME/bin/oracle和$GRID_HOME/bin/oracle两个文件),如果权限不对会出现 ORA-12547: TNS:lost contact 错误,如下:
~]$ dbca -silent -createDatabase -responseFile /home/oracle/response/dbca.rsp
Prepare for db operation
7% complete
Registering database with Oracle Restart
11% complete
Copying database files
33% complete
Creating and starting Oracle instance
35% complete
38% complete
42% complete
45% complete
48% complete
Completing Database Creation
53% complete
56% complete
100% complete
[FATAL] PRCR-1079 : Failed to start resource ora.zyzh.db
CRS-5017: The resource action "ora.zyzh.db start" encountered the following error:
ORA-12547: TNS:lost contact
. For details refer to "(:CLSN00107:)" in "/u01/app/grid/diag/crs/dbtest/crs/trace/ohasd_oraagent_grid.trc".
CRS-2674: Start of 'ora.zyzh.db' on 'dbtest' failed
ORA-12547: TNS:lost contact
48% complete
33% complete
11% complete
7% complete
0% complete
Look at the log file "/opt/oracle/cfgtoollogs/dbca/zyzh/zyzh1.log" for further details.
正确的权限应在Oracle用户下执行如下命令进行修改:
chmod 6751 $ORACLE_HOME/bin/oracle
7.4. 使用dbca.rsp静默建库
注意:#responseFile必须使用绝对路径
以 oracle 用户执行如下命令
dbca -silent -createDatabase -responseFile /home/oracle/dbca.rsp
显示内容如下:
Prepare for db operation
7% complete
Registering database with Oracle Restart
11% complete
Copying database files
33% complete
Creating and starting Oracle instance
35% complete
38% complete
42% complete
45% complete
48% complete
Completing Database Creation
53% complete
55% complete
56% complete
Creating Pluggable Databases
60% complete
78% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/zyzh.
Database Information:
Global Database Name:zyzh.zytk.com
System Identifier(SID):zyzh
Look at the log file "/opt/oracle/cfgtoollogs/dbca/zyzh/zyzh4.log" for further details.
DBCA静默建库的日志在哪里?
11g开始:$ORACLE_BASE/cfgtoollogs/dbca
10g:$ORACLE_HOME/cfgtoollogs/dbca
从该日志中可以找到DBCA静默建库的详细过程,值得我们深入分析。