实现Oracle 11g快速部署:利用响应文件在Oracle Linux 7.6上进行静默式安装

2023年 10月 31日 46.3k 0

目录

  • 一、前言
  • 二、安装前准备工作
    • 1、硬件要求
      • 1.1、内存要求
      • 1.2、Swap Space
      • 1.3、Automatic Memory Management
      • 1.4、磁盘空间要求
    • 2、软件要求
      • 2.1、适用于 Linux x86-64 操作系统要求
      • 2.2、适用于 Linux x86-64 内核要求
      • 2.3、适用于 Linux x86-64 的 Oracle 数据库包要求
    • 3、关闭透明页
    • 4、配置主机名解析
    • 5、创建所需的操作系统组和用户
    • 6、配置Oracle软件安装用户的资源限制
    • 7、为Linux配置内核参数
    • 8、创建所需的软件目录并授权
    • 9、关闭numa功能
    • 10、禁用SELINUX
    • 11、关闭防火墙
    • 12、修改 /dev/shm大小
    • 13、安装Oracle数据库所需软件包
      • 13.1、配置YUM源
      • 13.2、安装必要的软件包
    • 14、配置Oracle软件所有者环境
    • 15、重启操作系统
  • 三、关于响应文件
    • 1、什么是静默安装
    • 2、什么是响应文件
    • 3、响应文件的工作原理
    • 4、选择静默安装的原因
  • 四、安装Oracle数据库软件
    • 1、上传Oracle数据库安装软件到服务器并解压
    • 2、准备响应文件
    • 3、编辑db_install.rsp响应文件
    • 4、创建oraInst.loc文件
    • 5、安装数据库软件
    • 6、执行配置脚本
  • 五、配置监听
    • 1、使用netca.rsp创建监听
    • 2、监听管理
      • 2.1、查看监听状态
      • 2.2、关闭监听
      • 2.3、启动监听
  • 六、创建数据库
    • 1、编辑dbca.rsp响应文件
    • 2、使用响应文件创建数据库
  • 七、数据库管理入门
    • 1、启用SQL*Plus从命令行连接到数据库
    • 2、查看数据库基础信息
    • 3、查看数据库版本
    • 4、查看数据库字符集
    • 5、查看数据库块大小
    • 6、实例的启动与关闭
      • 6.1、启动
      • 6.2、关闭
    • 7、取消180天密码过期限制
    • 8、关闭审计
    • 9、调整db_files
  • 八、总结
  • 九、写在后面

一、前言

  Oracle数据库是业内广泛使用的关系型数据库管理系统,Oracle 11g是Oracle公司推出的最重要的一个版本,具有高效、可靠、安全等特点。在安装Oracle 11g数据库时,使用响应文件可以简化安装过程,提高安装效率。
 
  本文详细介绍了在Oracle Linux 6.9文件系统中使用响应文件静默安装Oracle 11g数据库的步骤以及响应文件的概念和作用,通过本文的学习,读者可以轻松掌握在Oracle Linux 6.9文件系统中使用响应文件静默安装Oracle 11g数据库的技巧和方法。使用响应文件可以减少手动配置的繁琐过程,提高安装的一致性和效率。希望本文能为读者在搭建Oracle数据库环境时提供指导和帮助,使其能够顺利完成安装工作,并为后续的数据库应用开发提供良好的基础。

二、安装前准备工作

1、硬件要求

1.1、内存要求

最低:1 GB 内存
建议:2 GB 或更多内存
[root@hellodba ~]# grep MemTotal /proc/meminfo
MemTotal: 2774432 kB

1.2、Swap Space

        RAM       Swap Space
在1GB到2GB之间 RAM大小的1.5倍
2GB到16GB之间 等于RAM的大小
超过16GB 等于16GB

[root@hellodba ~]# grep SwapTotal /proc/meminfo
SwapTotal: 3170300 kB

1.3、Automatic Memory Management

//关于/dev/shm
从Oracle Database 11g开始,自动内存管理功能需要更多的共享内存(/dev/shm)和文件描述符。在Linux系统中,’/dev/shm’目录是一个特殊的目录,用于实现共享内存,默认是系统内存的50%。它是一个临时文件系统,通常位于RAM(内存)中,而不是硬盘上,并且在系统重启时会被清空。因此,’/dev/shm’目录只适合用于短期存储和进程间通信,不能用于长期存储数据。’/dev/shm’大小应该大于SGA+PGA的总内存大小,在Linux系统上,如果操作系统’/dev/shm’装载大小对于Oracle系统全局区域(SGA)和程序全局区域(PGA)来说太小,则会导致ORA-00845错误。

1.4、磁盘空间要求

目录/tmp至少有1GB空间,如果小于所需空间,请从目录中删除不必要的文件满足磁盘空间需求。
[root@hellodba ~]# df -h /tmp
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 47G 5.2G 39G 12% /

       安装类型   软件文件的磁盘空间要求(GB)
企业版 1.7
标准版 1.5

 

       安装类型   数据文件的磁盘空间要求(GB)
企业版 1.7
标准版 1.5

[root@hellodba ~]# df -h /u01
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 30G 44M 28G 1% /u01

2、软件要求

2.1、适用于 Linux x86-64 操作系统要求

//需要以下或更高版本的操作系统:
Asianux Server 3 SP2
Asianux Server 4 SP3
Oracle Linux 4 Update 7
Oracle Linux 5 Update 2 (with Red Hat Compatible Kernel)
Oracle Linux 5 Update 5
Oracle Linux 6
Oracle Linux 6 (with Red Hat Compatible Kernel)
Oracle Linux 7
Oracle Linux 7 (with Red Hat Compatible Kernel)
Red Hat Enterprise Linux 4 Update 7
Red Hat Enterprise Linux 5 Update 2
Red Hat Enterprise Linux 6
Red Hat Enterprise Linux 7
SUSE Linux Enterprise Server 10 SP2
SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 12 SP1
NeoKylin Linux Advanced Server 6
NeoKylin Linux Advanced Server 7

[root@hellodba ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.9 (Santiago)

2.2、适用于 Linux x86-64 内核要求

On Oracle Linux 4 and Red Hat Enterprise Linux 4
2.6.9 or later

On Oracle Linux 5 Update 2 with Red Hat Compatible Kernel
2.6.18 or later

On Oracle Linux 5 Update 5 with Red Hat Compatible Kernel
2.6.18 or later

On Oracle Linux 5 Update 5 with Unbreakable Enterprise Kernel
2.6.32-100.0.19 or later

On Oracle Linux 6
2.6.32-100.28.5.el6.x86_64 or later

On Oracle Linux 6 with Red Hat Compatible Kernel
2.6.32-71.el6.x86_64 or later

On Oracle Linux 7
3.8.13-33.el7uek.x86_64 or later

On Oracle Linux 7 with Red Hat Compatible Kernel
3.10.0-54.0.1.el7.x86_64 or later

On Red Hat Enterprise Linux 5 Update 2
2.6.18 or later

On Red Hat Enterprise Linux 5 Update 5
2.6.18 or later

On Red Hat Enterprise Linux 6
2.6.32-71.el6.x86_64 or later

On Red Hat Enterprise Linux 7
3.10.0-54.0.1.el7.x86_64 or later

On Asianux Server 3
2.6.18 or later

On Asianux Server 4
2.6.32-71.el6.x86_64 or later

On SUSE Linux Enterprise Server 10
2.6.16.21 or later

On SUSE Linux Enterprise Server 11
2.6.27.19 or later

On SUSE Linux Enterprise Server 12
3.12.49-11 or later

On NeoKylin Linux Advanced Server 6
2.6.32-431.el6.x86_64 or later

On NeoKylin Linux Advanced Server 7
3.10.0-327.el7.x86_64 or later

[root@hellodba ~]# uname -r
4.1.12-61.1.28.el6uek.x86_64

2.3、适用于 Linux x86-64 的 Oracle 数据库包要求

//Oracle Linux 7 and Red Hat Enterprise Linux 7:
binutils-2.23.52.0.1-12.el7.x86_64
compat-libcap1-1.10-3.el7.x86_64
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64
gcc-c++-4.8.2-3.el7.x86_64
glibc-2.17-36.el7.i686
glibc-2.17-36.el7.x86_64
glibc-devel-2.17-36.el7.i686
glibc-devel-2.17-36.el7.x86_64
ksh
libaio-0.3.109-9.el7.i686
libaio-0.3.109-9.el7.x86_64
libaio-devel-0.3.109-9.el7.i686
libaio-devel-0.3.109-9.el7.x86_64
libgcc-4.8.2-3.el7.i686
libgcc-4.8.2-3.el7.x86_64
libstdc++-4.8.2-3.el7.i686
libstdc++-4.8.2-3.el7.x86_64
libstdc++-devel-4.8.2-3.el7.i686
libstdc++-devel-4.8.2-3.el7.x86_64
libXi-1.7.2-1.el7.i686
libXi-1.7.2-1.el7.x86_64
libXtst-1.2.2-1.el7.i686
libXtst-1.2.2-1.el7.x86_64
make-3.82-19.el7.x86_64
sysstat-10.1.5-1.el7.x86_64
unixODBC-2.3.1-6.el7.x86_64 or later
unixODBC-2.3.1-6.el7.i686 or later
unixODBC-devel-2.3.1-6.el7.x86_64 or later
unixODBC-devel-2.3.1-6.el7.i686 or later

3、关闭透明页

从Red Hat Enterprise Linux 6、Oracle Linux 6、SUSE 11和Unbreakable Enterprise Kernel 2(UEK2)内核开始,Transparent HugePages在运行时默认启用。然而,透明的HugePages可能会导致内存分配延迟,因为内存是动态分配的。因此,甲骨文建议您在所有甲骨文数据库服务器上禁用透明HugePages,以避免性能问题。

//查看透明页是否启用,显示[always]表示Transparent HugePages是启用的
[root@hellodba ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
[root@hellodba ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

//禁用透明页
[root@hellodba ~]# vi /etc/rc.d/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@hellodba ~]# chmod +x /etc/rc.d/rc.local
[root@hellodba ~]# reboot

//透明页已关闭
[root@hellodba ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
[root@hellodba ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

4、配置主机名解析

[root@hellodba ~]# echo "192.168.0.55 hellodba" >> /etc/hosts
[root@hellodba ~]# ping hellodba
PING hellodba (192.168.0.55) 56(84) bytes of data.
64 bytes from hellodb (192.168.0.55): icmp_seq=1 ttl=64 time=0.013 ms

5、创建所需的操作系统组和用户

[root@hellodba ~]# /usr/sbin/groupadd -g 501 oinstall
[root@hellodba ~]# /usr/sbin/groupadd -g 502 dba
[root@hellodba ~]# /usr/sbin/groupadd -g 503 oper
[root@hellodba ~]# /usr/sbin/useradd -u 502 -g oinstall -G dba,oper oracle
[root@hellodba ~]# echo "hellodba" | passwd --stdin oracle
[root@hellodba ~]# id oracle
uid=502(oracle) gid=501(oinstall) 组=501(oinstall),502(dba),503(oper)

6、配置Oracle软件安装用户的资源限制

[root@hellodba ~]# vi /etc/security/limits.conf
#ORACLE SETTING
#打开文件描述符大小
oracle soft nproc 16384
oracle hard nproc 16384
#单个用户可用的进程数
oracle soft nofile 16384
oracle hard nofile 65536
#进程堆栈段的大小
oracle soft stack 10240
oracle hard stack 32768

7、为Linux配置内核参数

在Oracle数据库安装期间,可以生成并运行修复脚本,以检查和设置成功安装数据库所需的内核参数值。建议手动预先修改好。

[root@hellodba ~]# vi /etc/sysctl.conf
#ORACLE SETTING
#可以拥有的异步IO请求数
fs.aio-max-nr = 1048576
#允许文件句柄的最大数目
fs.file-max = 6815744
#信号参数
kernel.sem = 250 32000 100 128
#IP V4的端口范围
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 = 1048586
#当系统检测到oops时,重新启动系统,以便系统能够重新初始化恢复正常工作
kernel.panic_on_oops = 1
#单个共享内存段最大值,让数据库在一个共享段里面的可以容纳整个SGA
#最大值:比物理内存小1字节
#(kernel.shmmax = 物理内存*1024*1024*1024-1)
kernel.shmmax = 2684354560
#控制共享内存页数(kernel.shmall = shmmax/4096)
kernel.shmall = 2097152
#共享内存的最大数量
kernel.shmmni = 4096
#当系统内存使用90%的时候开始使用交换页面
vm.swappiness=10
#默认是100,增大这个参数设置了虚拟内存回收directory和i-node缓冲的倾向,这个值越大。越容易回收。
vm.vfs_cache_pressure=200

8、创建所需的软件目录并授权

[root@hellodba ~]# mkdir -p /u01/app/oracle
[root@hellodba ~]# mkdir -p /u01/app/oraInventory
[root@hellodba ~]# mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
[root@hellodba ~]# mkdir -p /soft
[root@hellodba ~]# chown -R oracle:oinstall /u01
[root@hellodba ~]# chown -R oracle:oinstall /soft
[root@hellodba ~]# chmod -R 775 /u01
[root@hellodba ~]# chmod -R 775 /soft

9、关闭numa功能

//NUMA关闭前
[root@hellodba ~]# dmesg | grep -i numa
[ 0.000000] NUMA: Node 0 [mem 0x00000000-0x0009ffff] + [mem 0x00100000-0xbfffffff] -> [mem 0x00000000-0xbfffffff]
[ 0.000000] NUMA: Node 0 [mem 0x00000000-0xbfffffff] + [mem 0x100000000-0x1017fffff] -> [mem 0x00000000-0x1017fffff]

//关闭NUMA
[root@hellodba ~]# vi /boot/grub/grub.conf

kernel /boot/vmlinuz-4.1.12-61.1.28.el6uek.x86_64 ro root=UUID=6d97d615-d2a7-480d-b44a-b96778e351ac rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=256M LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
kernel /boot/vmlinuz-2.6.32-696.el6.x86_64 ro root=UUID=6d97d615-d2a7-480d-b44a-b96778e351ac rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet

kernel /boot/vmlinuz-4.1.12-61.1.28.el6uek.x86_64 ro root=UUID=6d97d615-d2a7-480d-b44a-b96778e351ac rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=256M LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet numa=off
kernel /boot/vmlinuz-2.6.32-696.el6.x86_64 ro root=UUID=6d97d615-d2a7-480d-b44a-b96778e351ac rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet numa=off

[root@hellodba ~]# reboot

//NUMA关闭后
[root@hellodba ~]# dmesg | grep -i numa
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.10.0-957.el7.x86_64 root=UUID=cacc2dc0-9441-473d-ad25-dad067800baa ro crashkernel=auto rhgb quiet numa=off
[ 0.000000] NUMA turned off
[ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-3.10.0-957.el7.x86_64 root=UUID=cacc2dc0-9441-473d-ad25-dad067800baa ro crashkernel=auto rhgb quiet numa=off

10、禁用SELINUX

[root@hellodba ~]# getenforce
Enforcing
[root@hellodba ~]# vi /etc/selinux/config
将 SELINUX=enforcing
改 SELINUX= disabled
[root@hellodba ~]# setenforce 0
[root@hellodba ~]# getenforce
Permissive

11、关闭防火墙

[root@hellodba ~]# service iptables stop
[root@hellodba ~]# chkconfig iptables off

12、修改 /dev/shm大小

[root@hellodba ~]# df -h /dev/shm
Filesystem Size Used Avail Use% Mounted on
tmpfs 1.4G 72K 1.4G 1% /dev/shm

[root@hellodba ~]# vi /etc/fstab

tmpfs /dev/shm tmpfs defaults 0 0

tmpfs /dev/shm tmpfs defaults,size=3g 0 0

[root@hellodba ~]# mount -o remount /dev/shm
[root@hellodba ~]# df -h /dev/shm
Filesystem Size Used Avail Use% Mounted on
tmpfs 3.0G 72K 3.0G 1% /dev/shm

13、安装Oracle数据库所需软件包

13.1、配置YUM源

[root@hellodba ~]# mount /dev/cdrom /mnt
[root@hellodba ~]# cd /etc/yum.repos.d
[root@hellodba yum.repos.d]# rm -rf *.repo
[root@hellodba yum.repos.d]# echo "[EL]" >> hellodba.repo
[root@hellodba yum.repos.d]# echo "name=Linux 6.9 DVD" >> hellodba.repo
[root@hellodba yum.repos.d]# echo "baseurl=file:///mnt" >> hellodba.repo
[root@hellodba yum.repos.d]# echo "gpgcheck=0" >> hellodba.repo
[root@hellodba yum.repos.d]# echo "enabled=1" >> hellodba.repo

13.2、安装必要的软件包

[root@hellodba ~]#
yum -y install binutils*
yum -y install compat-libcap1*
yum -y install compat-libstdc++-33*
yum -y install gcc-*
yum -y install gcc-c*
yum -y install glibc*
yum -y install glibc-devel*
yum -y install ksh*
yum -y install libaio*
yum -y install libaio-devel*
yum -y install libgcc*
yum -y install libstdc++*
yum -y install libstdc++-devel*
yum -y install libXi*
yum -y install libXtst*
yum -y install *make*
yum -y install sysstat*
yum -y install unixODBC
yum -y install elfutils-libelf*

14、配置Oracle软件所有者环境

[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ vi ~/.bash_profile
umask=022
export PS1
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_UNQNAME=hellodb
export ORACLE_SID=hellodb;
export ORACLE_BASE=/u01/app/oracle;
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1;
export ORACLE_TERM=xterm;
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS";
export NLS_LANG=AMERICAN_AMERICA.UTF8;
export LANG=en_US.UTF8;
export PATH=.:$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_BASE/product/11.2.0/dbhome_1/bin:$ORACLE_HOME/bin;
export THREADS_FLAG=native;

[oracle@hellodba ~]$ source ~/.bash_profile

15、重启操作系统

[root@hellodba ~]# reboot

三、关于响应文件

1、什么是静默安装

静默安装在控制台中运行,不使用GUI。您通常看到的交互式对话框不会在静默安装中显示。
Oracle Universal Installer不会提示您选择一系列安装选项,而是使用存储在响应文件中或在命令行中传递的预定义选项集来安装软件。您可以在控制台中查看静默安装的进度。

2、什么是响应文件

响应文件是一个规范文件,包含在交互式安装会话期间通常通过Oracle Universal Installer用户界面获取的信息。每个参数都存储在响应文件中标识的变量的值。

3、响应文件的工作原理

通过在启动 Oracle Universal Installer 时指定响应文件,可以完全或部分自动执行 Oracle 软件的安装和配置。Oracle Universal Installer 使用响应文件中包含的值来提供部分或全部 Oracle Universal Installer 提示的选项。

4、选择静默安装的原因

在未安装图形界面的操作系统上安装Oracle数据库。
在多台计算机上多次安装Oracle产品,则静默安装非常有用。如果在每台计算机上安装时选择的选项始终相同,则可以节省查看每个安装屏幕和选择各种安装选项的时间。

四、安装Oracle数据库软件

1、上传Oracle数据库安装软件到服务器并解压

//通过oracle用户上传Oracle数据库安装软件到服务器 /soft 目录
[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ cd /soft
[oracle@hellodba soft]$ ll
-rwxrwxr-x 1 oracle oinstall 1395582860 Oct 30 11:20 p13390677_112040_Linux-x86-64_1of7.zip
-rwxrwxr-x 1 oracle oinstall 1151304589 Oct 30 11:20 p13390677_112040_Linux-x86-64_2of7.zip
[oracle@hellodba soft]$ unzip -q p13390677_112040_Linux-x86-64_1of7.zip
[oracle@hellodba soft]$ unzip -q p13390677_112040_Linux-x86-64_2of7.zip
[oracle@hellodba soft]$ ll
drwxr-xr-x 7 oracle oinstall 4096 Aug 27 2013 database
-rwxrwxr-x 1 oracle oinstall 1395582860 Oct 30 11:20 p13390677_112040_Linux-x86-64_1of7.zip
-rwxrwxr-x 1 oracle oinstall 1151304589 Oct 30 11:20 p13390677_112040_Linux-x86-64_2of7.zip

2、准备响应文件

在解压目录/soft/database/response下有三个响应文件模板。
db_install.rsp:数据库软件安装响应文件
netca.rsp:创建监听响应文件
dbca.rsp:创建数据库响应文件

[oracle@hellodba ~]$ ls -l /soft/database/response
-rwxr-xr-x 1 oracle oinstall 44533 Aug 27 2013 dbca.rsp
-rw-r--r-- 1 oracle oinstall 25116 Aug 27 2013 db_install.rsp
-rwxr-xr-x 1 oracle oinstall 5871 Aug 27 2013 netca.rsp

3、编辑db_install.rsp响应文件

//先将db_install.rsp文件备份一份
[oracle@hellodba ~]$ cd /soft/database/response
[oracle@hellodba response]$ cp db_install.rsp db_install.rsp_bak
[oracle@hellodba response]$ echo '' > db_install.rsp
[oracle@hellodba response]$ vi db_install.rsp
#软件版本信息
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
#安装选项-仅安装数据库软件
oracle.install.option=INSTALL_DB_SWONLY
#主机名称
ORACLE_HOSTNAME=hellodba
#oracle用户用于安装软件的组名
UNIX_GROUP_NAME=oinstall
#oracle产品清单目录
INVENTORY_LOCATION=/u01/app/oraInventory
#oracle运行语言环境,英文和简体中文
SELECTED_LANGUAGES=en,zh_CN
#oracle安装目录
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
#oracle基础目录
ORACLE_BASE=/u01/app/oracle
#安装版本类型:企业版
oracle.install.db.InstallEdition=EE
#不手动指定企业安装组件
oracle.install.db.EEOptionsSelection=false
#当EEOptionsSelection=false时,该参数不用填写
oracle.install.db.optionalComponents=
#指定拥有DBA组
oracle.install.db.DBA_GROUP=dba
#指定oper用户组
oracle.install.db.OPER_GROUP=oper
#不配置安全更新
DECLINE_SECURITY_UPDATES=true
#跳过更新
oracle.installer.autoupdates.option=SKIP_UPDATES

4、创建oraInst.loc文件

# 以root用户需创建/etc/oraInst.loc文件,否则安装会报错
root@hellodba ~]# vi /etc/oraInst.loc
inventory_loc=/u01/oracle/oraInventory
inst_group=oinstall
[root@hellodba ~]# chown oracle:oinstall /etc/oraInst.loc
[root@hellodba ~]# chmod 664 /etc/oraInst.loc

5、安装数据库软件

[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ cd /soft/database
[oracle@hellodba database]$ ./runInstaller -silent -noconfig -ignorePrereq -responseFile /soft/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB. Actual 34097 MB Passed
Checking swap space: must be greater than 150 MB. Actual 3095 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2023-10-30_05-40-10PM. Please wait ...[oracle@hellodba database]$ You can find the log of this install session at:
/u01/oracle/oraInventory/logs/installActions2023-10-30_05-40-10PM.log
The installation of Oracle Database 11g was successful.
Please check '/u01/oracle/oraInventory/logs/silentInstall2023-10-30_05-40-10PM.log' for more details.

As a root user, execute the following script(s):
1. /u01/app/oracle/product/11.2.0/dbhome_1/root.sh

Successfully Setup Software.

6、执行配置脚本

[root@hellodba ~]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
Check /u01/app/oracle/product/11.2.0/dbhome_1/install/root_hellodba_2023-10-30_17-42-28.log for the output of root script

五、配置监听

1、使用netca.rsp创建监听

netca.rsp不用做修改,默认建一个名为Listener的监听

[oracle@hellodba response]$ netca -silent -responseFile /soft/database/response/netca.rsp

Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /soft/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

2、监听管理

2.1、查看监听状态

[oracle@hellodba ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 30-OCT-2023 17:54:52

Copyright (c) 1991, 2013, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 30-OCT-2023 17:52:32
Uptime 0 days 0 hr. 2 min. 19 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/hellodba/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hellodba)(PORT=1521)))
The listener supports no services
The command completed successfully

2.2、关闭监听

[oracle@hellodba ~]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 30-OCT-2023 17:55:14

Copyright (c) 1991, 2013, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully

2.3、启动监听

[oracle@hellodba ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 30-OCT-2023 17:55:32

Copyright (c) 1991, 2013, Oracle. All rights reserved.

Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/hellodba/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hellodba)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 30-OCT-2023 17:55:32
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/hellodba/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hellodba)(PORT=1521)))
The listener supports no services
The command completed successfully

六、创建数据库

1、编辑dbca.rsp响应文件

//先将dbca.rsp文件备份一份
[oracle@hellodba ~]$ cd /soft/database/response
[oracle@hellodba response]$ cp dbca.rsp dbca.rsp_bak
[oracle@hellodba response]$ echo '' > dbca.rsp
[oracle@hellodba response]$ vi dbca.rsp
[GENERAL]
#响应文件版本号
RESPONSEFILE_VERSION = "11.2.0"
#操作选项-创建数据库
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
#数据库全局名
GDBNAME = "hellodb"
#SID
SID = "hellodb"
#数据库模板名称
#TEMPLATENAME = "hellodb.dbc"
#设置SYS账户密码
SYSPASSWORD = "Hell0o@Dba"
#设置SYSTEM账户密码
SYSTEMPASSWORD = "Hell0o@Dba"
#数据库字符集
CHARACTERSET = "AL32UTF8"
#国家字符集
NATIONALCHARACTERSET= "UTF8"
#数据库类型-多用途
DATABASETYPE = "MULTIPURPOSE"
#Oracle所占物理内存百分比
MEMORYPERCENTAGE = "40"

2、使用响应文件创建数据库

[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ dbca -silent -responseFile /soft/database/response/dbca.rsp
Copying database files
1% complete
3% complete
11% complete
18% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/hellodb/hellodb3.log" for further details.

七、数据库管理入门

1、启用SQL*Plus从命令行连接到数据库

//登录数据库
[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ sqlplus / as sysdba

2、查看数据库基础信息

//查看数据库基础信息
SQL> select name,log_mode,open_mode,platform_name,db_unique_name from v$database;
NAME LOG_MODE OPEN_MODE PLATFORM_NAME DB_UNIQUE_NAME
--------------------------------------------------------------------------------------
HELLODB NOARCHIVELOG READ WRITE Linux x86 64-bit hellodb

3、查看数据库版本

//查看数据库版本
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

4、查看数据库字符集

//查看数据库字符集
SQL> select * from nls_database_parameters where parameter like '%CHARACTERSET%';
PARAMETER VALUE
--------------------------------------------------------------------------------
NLS_CHARACTERSET AL32UTF8
NLS_NCHAR_CHARACTERSET UTF8

5、查看数据库块大小

//查看数据库块大小
SQL> show parameter db_block_size
NAME TYPE VALUE
-------------------------------------------
db_block_size integer 8192

6、实例的启动与关闭

6.1、启动

[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ lsnrctl start
[oracle@hellodba ~]$ sqlplus / as sysdba
SQL> startup

6.2、关闭

[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ lsnrctl stop
[oracle@hellodba ~]$ sqlplus / as sysdba
SQL> shutdown immediate;

7、取消180天密码过期限制

SQL> select * from dba_profiles where profile='DEFAULT' and RESOURCE_NAME='PASSWORD_LIFE_TIME';
PROFILE RESOURCE_NAME RESOURCE_TYPE LIMIT
-----------------------------------------------------------------------------------------------
DEFAULT PASSWORD_LIFE_TIME PASSWORD 180

SQL> alter profile default limit password_life_time unlimited;

SQL> select * from dba_profiles where profile='DEFAULT' and RESOURCE_NAME='PASSWORD_LIFE_TIME';
PROFILE RESOURCE_NAME RESOURCE_TYPE LIMIT
-----------------------------------------------------------------------------------------------
DEFAULT PASSWORD_LIFE_TIME PASSWORD UNLIMITED

8、关闭审计

SQL> show parameter audit;
NAME TYPE VALUE
-----------------------------------------------------------------------------------------------
audit_file_dest string /u01/app/oracle/admin/hellodb/adump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string DB

SQL> alter system set audit_trail=none scope=spfile; (重启数据库生效)

9、调整db_files

SQL> show parameter db_files;
NAME TYPE VALUE
---------------------------------------------------------------------------
db_files integer 200

SQL> alter system set db_files=1024 scope=spfile; (重启数据库生效)

八、总结

  到此通过响应文件静默安装Oracle数据库就完成了,并进行了一些常规的设置。与图形化交互方式安装Oracle数据库相比,使用响应文件安装Oracle数据库更方便、更便捷,更适合批量安装相同配置参数的Oracle数据库。希望通过以上的安装方法,能让您对Oracle数据库的安装有了更进一步的理解和体会。安装Oracle数据库需要有一定的专业知识和经验,在实际操作中,可能还会遇到其他问题和挑战,建议在进行安装之前详细阅读相关文档和指南,并确保有必要的技术支持和备份措施。

九、写在后面

  由于本人有限的能力和知识储备,可能存在错误或疏漏之处,如有错误敬请批评指正!

 
公众号:Hello DBA
 

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论