CENTOS 7系统Oracle 19C安装配置

1.前言

  继11G、12C、18C之后,闲来准备捣鼓一下19C,依然从最简单的下载安装开始。

  下面引入一段机翻官文:Oracle Database 19c中Oracle数据库安装提供的新功能。

  | 对Oracle数据库安装的root脚本自动化支持

  从Oracle Database 19c开始,数据库安装程序或设置向导提供了一些选项,用于设置权限以在数据库安装期间根据需要自动运行root配置脚本,当然仍然可以选择手动运行root配置脚本。

  设置root配置脚本的运行权限而无需用户干预,可以简化数据库的安装,并有助于避免意外的权限错误

  | 简化基于映像的Oracle数据库客户端安装

  从Oracle Database 19c开始,Oracle数据库客户端软件可以作为映像文件下载和安装,必须将映像软件解压到Oracle主目录中,再运行runInstaller脚本以开始Oracle数据库客户端安装,另外继续以传统非映像zip文件格式提供Oracle数据库客户端二进制方式安装。

  与Oracle数据库和Oracle Grid Infrastructure映像文件安装一样,Oracle Database客户端映像安装可简化Oracle Database客户端安装并确保最佳实践部署。

  | Oracle Database 19c开始不推荐使用的功能

  • 弃用clone.pl:clone.pl脚本在Oracle Database 19c中已弃用, software-only安装模式需使用gold image,建议使用安装程序将解压提取的gold image安装在home目录。
  • 弃用SERVICE_NAMES参数:不支持将服务名称参数用于任何HA操作,此限制包括FAN,负载平衡,FAILOVER_TYPE,FAILOVER_RESTORE,SESSION_STATE_CONSISTENCY,和任何其它用途。

2.安装环境准备

  操作系统(版本略低):CentOS Linux release 7.2.1511 (Core)

  数据库版本:Oracle 19.3.0

2.1 用于Oracle数据库安装的服务器硬件清单

[root@chengyu ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core) 
[root@chengyu ~]# cat /proc/version
Linux version 3.10.0-1127.18.2.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Sun Jul 26 15:27:06 UTC 2020
--确定服务器的物理RAM大小
[root@chengyu ~]#  grep MemTotal /proc/meminfo
MemTotal:        7829052 kB

2.2 Oracle数据库安装的服务器配置需求

  检查Oracle数据库安装满足最低服务器配置要求:

--确定已配置交换空间的大小
[root@chengyu ~]#  grep SwapTotal /proc/meminfo
SwapTotal:       8126452 kB
--/tmp磁盘空间至少1GB,如果不足1G,需设置oracle用户的TMP和TMPDIR环境变量。
[root@chengyu ~]# df -h /tmp
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G   13G   38G  25% /
[root@chengyu ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G   13G   38G  25% /
devtmpfs                 3.8G     0  3.8G   0% /dev
tmpfs                    3.8G     0  3.8G   0% /dev/shm
tmpfs                    3.8G  9.4M  3.8G   1% /run
tmpfs                    3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/mapper/centos-home  412G   64G  348G  16% /home
/dev/sda1                494M  237M  258M  48% /boot
tmpfs                    765M   32K  765M   1% /run/user/0

如果/tmp目录中的可用空间小于所需空间,请完成以下步骤之一:

  • 从/tmp目录中删除不需要的文件,以满足磁盘空间要求。
  • 设置Oracle用户的环境时,设置TMP和TMPDIR环境变量代替/tmp。

  增加swap空间大小如下:of指定swap文件位置,if表示增加swap,bs是块大小,count是块数,bs*count是swap文件的大小,下面是在/home下增加1G虚拟内存。

[root@chengyu ~]# dd if=/dev/zero of=/home/swap bs=1M count=1024
[root@chengyu ~]# mkswap /home/swap
[root@chengyu ~]# swapon /home/swap
--查看swap空间
[root@chengyu ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           7645         824        5675          16        1144        6492
Swap:          7935           0        7935
[root@chengyu ~]#  grep SwapTotal /proc/meminfo
SwapTotal:       8126452 kB
--如果不需要了,可以停用新增的swap
[root@chengyu ~]# swapoff -v /home/swap
--设置开机启用swap
[root@chengyu ~]# vim /etc/fstab
/home/swap swap swap defaults  0 0

2.3 Oracle用户环境、安装目录配置

  配置用于Oracle数据库管理的操作系统用户,组和环境。

[root@chengyu ~]# /usr/sbin/groupadd -g 54321 oinstall
[root@chengyu ~]# /usr/sbin/groupadd -g 54322 dba
[root@chengyu ~]# groupadd -g 54323 oper
[root@chengyu ~]# /usr/sbin/groupadd -g 54324 backupdba
[root@chengyu ~]# /usr/sbin/groupadd -g 54325 dgdba
[root@chengyu ~]# /usr/sbin/groupadd -g 54326 kmdba
[root@chengyu ~]# /usr/sbin/useradd -u 54321 -g oinstall -G dba,oper,backupdba,dgdba,kmdba oracle
--创建安装目录
[root@chengyu ~]# mkdir -p /home/app/oracle
[root@chengyu ~]# mkdir -p /home/app/oraInventory
[root@chengyu ~]# mkdir -p /home/app/oracle/product/19.0.0/dbhome_1/
[root@chengyu ~]# chown -R oracle:oinstall /home/app
[root@chengyu ~]# chmod -R 775 /home/app
--解压缩安装包到oracle_home目录下
[root@chengyu ~]# cd /home/app/oracle/product/19.0.0/dbhome_1/
[root@chengyu ~]# unzip -q /home/softwares/oracle/LINUX.X64_193000_db_home.zip

2.4 RPM依赖包安装

  根据Linux发行版本确保在开始安装之前已安装了受支持的内核和必需的软件包。
Packages for Red Hat Enterprise Linux 7:
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
unixODBC-2.3.4 or later
Optional Packages for Red Hat Enterprise Linux 7:
ipmiutil (for Intelligent Platform Management Interface)
net-tools (for Oracle RAC and Oracle Clusterware)
nfs-utils (for Oracle ACFS)
python (for Oracle ACFS Remote)
python-configshell (for Oracle ACFS Remote)
python-rtslib (for Oracle ACFS Remote)
python-six (for Oracle ACFS Remote)
targetcli (for Oracle ACFS Remote)

[root@chengyu ~]# rpm -q 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 unixODBC
bc-1.06.95-13.el7.x86_64
binutils-2.23.52.0.1-55.el7.x86_64
compat-libcap1-1.10-7.el7.x86_64
package compat-libstdc++33 is not installed
elfutils-libelf-0.176-2.el7.x86_64
elfutils-libelf-0.176-2.el7.i686
package elfutils-libelf-devel is not installed
package fontconfig-devel is not installed
glibc-2.17-307.el7.1.x86_64
glibc-2.17-307.el7.1.i686
glibc-devel-2.17-307.el7.1.i686
glibc-devel-2.17-307.el7.1.x86_64
ksh-20120801-137.el7.x86_64
libaio-0.3.109-13.el7.x86_64
libaio-0.3.109-13.el7.i686
libaio-devel-0.3.109-13.el7.x86_64
libaio-devel-0.3.109-13.el7.i686
libX11-1.6.7-2.el7.x86_64
libX11-1.6.7-2.el7.i686
libXau-1.0.8-2.1.el7.x86_64
libXau-1.0.8-2.1.el7.i686
libXi-1.7.9-1.el7.x86_64
libXi-1.7.9-1.el7.i686
libXtst-1.2.3-1.el7.x86_64
libXtst-1.2.3-1.el7.i686
libXrender-0.9.10-1.el7.x86_64
package libXrender-devel is not installed
libgcc-4.8.5-39.el7.x86_64
libgcc-4.8.5-39.el7.i686
libstdc++-4.8.5-39.el7.x86_64
libstdc++-4.8.5-39.el7.i686
libstdc++-devel-4.8.5-39.el7.x86_64
libstdc++-devel-4.8.5-39.el7.i686
libxcb-1.13-1.el7.x86_64
libxcb-1.13-1.el7.i686
make-3.82-21.el7.x86_64
smartmontools-7.0-2.el7.x86_64
sysstat-10.1.5-13.el7.x86_64
unixODBC-2.3.1-11.el7.x86_64
unixODBC-2.3.1-11.el7.i686

[root@chengyu ~]# yum -y install compat-libstdc++33 elfutils-libelf-devel fontconfig-devel libXrender-devel
Installed:
  elfutils-libelf-devel.x86_64 0:0.176-4.el7          fontconfig-devel.x86_64 0:2.13.0-4.3.el7         
  libXrender-devel.x86_64 0:0.9.10-1.el7             

Dependency Installed:
  expat-devel.x86_64 0:2.1.0-11.el7                  freetype-devel.x86_64 0:2.8-14.el7               
  libpng-devel.x86_64 2:1.5.13-7.el7_2               libsmartcols.x86_64 0:2.23.2-63.el7              
  libuuid-devel.x86_64 0:2.23.2-63.el7              

Dependency Updated:
  elfutils.x86_64 0:0.176-4.el7                       elfutils-libelf.i686 0:0.176-4.el7               
  elfutils-libelf.x86_64 0:0.176-4.el7                elfutils-libs.i686 0:0.176-4.el7                 
  elfutils-libs.x86_64 0:0.176-4.el7                  expat.x86_64 0:2.1.0-11.el7                      
  libblkid.x86_64 0:2.23.2-63.el7                     libmount.x86_64 0:2.23.2-63.el7                  
  libuuid.x86_64 0:2.23.2-63.el7                      util-linux.x86_64 0:2.23.2-63.el7                

Complete!

  注意:如果打算使用32位客户端应用程序访问64位服务器,则还必须安装(如果可用)此表中列出的软件包的最新32位版本;Oracle 12.2和更高版本安装Oracle数据库或Oracle Grid基础架构不需要编译器软件包gcc和gcc-c++。

2.5 配置Oracle用户的资源限制

  在limits.conf文件中设置资源限制:

[root@chengyu ~]#  vim /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 3145728
 oracle hard memlock 3145728

  要使/etc/security/limits.conf 文件配置生效,必须要确保PAM验证模块pam_limits.so文件被加入到启动文件中,在/etc/pam.d/login文本最后添加:session required pam_limits.so或者session required /lib/security/pam_limits.so使shell limit生效:

[root@chengyu ~]# vim /etc/pam.d/login
session  required  pam_limits.so

2.6 配置内核参数

  注意:除非另有说明,否则下表中显示的内核参数和外壳极限值仅是最小值。对于生产数据库系统,Oracle建议根据操作系统文档调整这些值以优化系统性能。如果任何参数的当前值大于此表中列出的值,则Fixup脚本不会更改该参数的值。

[root@chengyu ~]#  vim /etc/sysctl.conf
  fs.aio-max-nr = 1048576
  fs.file-max = 6815744
  kernel.shmall = 1073741824
  kernel.shmmax = 4398046511104
  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
[root@chengyu ~]# sysctl -p
或者
[root@chengyu ~]# /sbin/sysctl --system

2.7 配置域名解析文件/etc/hosts

  在/etc/hosts文件中添加IP地址和域名的映射关系,进入hosts文件,在文件末尾加上本机实际IP和主机用户名。

[root@chengyu ~]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.183.3.194 chengyu

2.8 配置Oracle的环境变量

  Oracle环境变量文件用户进程限制:

[root@chengyu ~]# vim /etc/profile
#For Oracle
if [ \$USER = "oracle" ]; then
 if [ \$SHELL = "/bin/ksh" ]; then
     ulimit -p 16384
     ulimit -n 65536
  else
     ulimit -u 16384 -n 65536
fi
 fi

-p:限制管道缓冲区的大小为16384;
-n:设置内核可以同时打开的文件描述符的最大值;
-u:设置用户最多可开启的程序数目。

  Oracle用户环境变量配置:

[root@chengyu ~]# su - oracle
Last login: Tue Aug 25 10:35:24 CST 2020 on pts/0
[oracle@chengyu ~]$ vim ~/.bash_profile
export ORACLE_BASE=/home/app/oracle
export ORACLE_SID=primpdb
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_1
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
[oracle@chengyu ~]$ source /home/oracle/.bash_profile

2.9 关闭selinux和防火墙

--关闭selinux
[root@chengyu ~]# vim /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
--查看当前防火墙状态
[root@chengyu ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
--关闭防火墙
[root@chengyu ~]# systemctl stop firewalld
[root@chengyu ~]# systemctl disable firewalld

3. 安装数据库软件

  通过VNC Viewer远程连接到指定的Linux图形界面:

[root@chengyu ~]# xhost +
[root@chengyu ~]# su - oracle
[oracle@chengyu ~]$ export DISPLAY=:2.0
[oracle@chengyu ~]$ cd /home/app/oracle/product/19.0.0/dbhome_1
[oracle@chengyu ~]$ ./runInstaller 

  弹出图形化安装界面:

  选择“Set Up Software Only”:

   选择“单实例安装”,下一步:
   选择“企业版”,下一步:
   安装位置配置,下一步:
   操作系统组选择,下一步:
   自动运行配置脚本,输入root用户密码,下一步:
   先决条件检查,这里选择忽略kmod-libs版本的问题,进入下一步:
   安装配置概要预览:
   下一步进入安装:
   提示确认root用户执行必要的配置脚本,“Yes”进入下一步:
   安装完毕:

4. 创建数据库实例

  Oracle用户下通过dbca图形界面创建数据库:

[oracle@chengyu dbhome_1]$ dbca

  选择高级配置,下一步:

   这里选择单实例一般用途的数据库类型,下一步:

  输入全库数据库名字和SID名,确定是否创建为容器数据库:

   根据模板文件定义数据存储方式和路径,下一步:

  开启归档和闪回,下一步:

   前面没有创建监听,所以这里选择创建新监听,当然也可以使用netca图形界面创建监听:
   使用自动内存管理,根据需要调整大小,还有字符集,连接模式等这里都默认:

  指定数据库的管理选项:

  指定数据库用户密码:

   创建数据库:
   数据库信息概览:

  开始创建:

   创建完成:

5. 安装完成检查

5.1 监听配置

  仅有动态监听如下:

[oracle@chengyu app]$ lsnrctl status

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 19-AUG-2020 15:37:40

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=chengyu)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                19-AUG-2020 09:42:32
Uptime                    0 days 5 hr. 55 min. 8 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File         /home/app/oracle/diag/tnslsnr/chengyu/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=chengyu)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=chengyu)(PORT=5500))(Security=(my_wallet_directory=/home/app/oracle/admin/primpdb/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "86b637b62fdf7a65e053f706e80a27ca" has 1 instance(s).
  Instance "primpdb", status READY, has 1 handler(s) for this service...
Service "ad0e7d4cc36b564be053c203b7c0aa9a" has 1 instance(s).
  Instance "primpdb", status READY, has 1 handler(s) for this service...
Service "pdb" has 1 instance(s).
  Instance "primpdb", status READY, has 1 handler(s) for this service...
Service "primpdb" has 2 instance(s).
  Instance "primdb", status BLOCKED, has 1 handler(s) for this service...
  Instance "primpdb", status READY, has 1 handler(s) for this service...
Service "primpdbXDB" has 1 instance(s).
  Instance "primpdb", status READY, has 1 handler(s) for this service...
The command completed successfully

配置静态监听:

[oracle@chengyu app]$ vim /home/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_NAME = primpdb)
     (ORACLE_HOME = /home/app/oracle/product/19.0.0/dbhome_1)
      (SID_NAME = primpdb)
    )
 )

重启监听查看配置结果:

[oracle@chengyu app]$ lsnrctl stop

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 19-AUG-2020 15:39:42

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=chengyu)(PORT=1521)))
The command completed successfully
[oracle@chengyu app]$ lsnrctl start

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 19-AUG-2020 15:39:45

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

Starting /home/app/oracle/product/19.0.0/dbhome_1/bin/tnslsnr: please wait...

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=chengyu)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                19-AUG-2020 15:39:45
Uptime                    0 days 0 hr. 0 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File         /home/app/oracle/diag/tnslsnr/chengyu/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=chengyu)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "primpdb" has 1 instance(s).
  Instance "primpdb", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

5.2 启动数据库

[oracle@chengyu ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Aug 26 14:48:48 2020
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 2415918608 bytes
Fixed Size		    9137680 bytes
Variable Size		  536870912 bytes
Database Buffers	 1862270976 bytes
Redo Buffers		    7639040 bytes
Database mounted.
Database opened.

SQL> select instance_name,status from v$instance;

INSTANCE_NAME	 STATUS
---------------- ------------
primpdb 	 OPEN
SQL> select con_id,name,open_mode from v$pdbs;

    CON_ID NAME 		OPEN_MODE
---------- -------------------- ----------
	 2 PDB$SEED		READ ONLY
	 3 PDB			MOUNTED

猜你喜欢

转载自blog.csdn.net/u010257584/article/details/108195333
今日推荐