数据库
首页 > 数据库> > 【Oracle】之Centos7.4安装部署Oracle19c

【Oracle】之Centos7.4安装部署Oracle19c

作者:互联网

【Oracle】之Centos7.4安装部署Oracle19c

项目需求

        在生产环境中,根据企业业务发展和项目需求,会根据业务的重要性,对业务数据库选型,并建立数据模型,数据库设计等。本次主要针对在Linux操作系统上安装部署Oracle19c数据库系统。


一、oracle软件下载

        关于oracle数据库系统软件下载,进入oracle官网,选择对应的操作系统环境版本并下载oracle数据库软件。下载地址:Database Software Downloads | Oracle。19c的安装有两种方式,一种是静默安装,另一种是图形化界面安装,本次采用ZIP的压缩软件,图形化安装。初次学习建议使用图形化安装,可以清晰的了解数据库的安装过程。软件下载如下:

二、安装部署环境

2.1、安装部署环境规划

环境介绍版本
主机环境CentOS Linux release 7.4.1708 (Core) 
oracle环境oracle19c
oracle实例名称orcl19c(普通数据库:如同11gr2创建的数据库)
orclpdb19c(容器数据库:pdb)
服务器IP172.21.109.122

2.2、操作系统环境准备

1、准备好服务器,虚拟机或物理机并安装后操作系统。


2、设置主机名和/etc/hosts文件

[root@manager oracle]# hostname
manager


[root@manager oracle]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

172.21.209.122 manager oracle

3、关闭防火墙和selinux

关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service

关闭selinux
[root@manager oracle]# cat /etc/selinux/config 

# 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=disabled                                            #修改为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

2.3、配置本地yum源

下载并上传ISO镜像文件
[root@manager data]# pwd 
/data
[root@manager data]# ll|grep *.iso
-rw-r--r--  1 root    root    4588568576 May 19 14:30 CentOS-7.6-x86_64-DVD-1810.iso

挂载镜像文件
[root@manager data]# mkdir  centos76
[root@manager data]# mount -o loop /data/CentOS-7.6-x86_64-DVD-1810.iso  /data/centos76/
mount: /dev/loop0 is write-protected, mounting read-only

[root@manager data]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G  4.0K  1.9G   1% /dev/shm
tmpfs           1.9G  9.9M  1.9G   1% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/vda3        96G   22G   70G  24% /
/dev/vda1       488M  262M  191M  58% /boot
tmpfs           379M   40K  379M   1% /run/user/1001
tmpfs           379M     0  379M   0% /run/user/0
/dev/loop0      4.3G  4.3G     0 100% /data/centos76
[root@manager data]# 


编辑repo文件
vi redhat-base.repo

[local]
name=Red Hat Enterprise Linux 6.7
baseurl=file:///mnt
enabled=1
gpgcheck=1
gpgkey=file:///mnt/RPM-GPG-KEY-redhat-release

三、操作系统环境准备

3.1、创建组和用户

/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper
/usr/sbin/useradd -u 54321 -g oinstall -G dba,oper oracle

3.2、修改用户oracle密码

passwd oracle

3.3、创建工作的目录,然后赋予相应的权限。

在root用户下执行命令

mkdir -p /u01/app/oracle/product/19.2.0/db_1
chown -R oracle:oinstall /u01/
chmod -R 775 /u01/

3.4、配置Oracle的环境变量

切换到oracle用户
su - oracle

打开环境变量文件,并输入一下内容
vi .bash_profile

ORACLE_SID=orcl19c;export ORACLE_SID
ORACLE_UNQNAME=orcl19c;export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/19.2.0/db_1; export ORACLE_HOME

NLS_DATE_FORMAT="YYYY:MM:DDHH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=american_america.ZHS16GBK; export NLS_LANG
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$ORA_CRS_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export 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

THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
umask 022

3.5、修改内核参数

首先退出到root用户,然后输入一下内容

vi /etc/sysctl.conf


fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
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
net.ipv4.ip_local_port_range = 9000 65500

执行如下命令,使生效。
sysctl --system

3.6、安装oracle依赖的包

yum install bc gcc gcc-c++ binutils compat-libcap1 compat-libstdc++ dtrace-modules dtrace-modules-headers 
dtrace-modules-provider-headers dtrace-utils elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel 
ksh libaio libaio-devel libdtrace-ctf-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc librdmacm-devel 
libstdc++ libstdc++-devel libxcb make smartmontools sysstat 

注意:需要配置有本地yum源。

4、安装oracle19c数据库系统

4.1、上传下载的软件包并解压

上传文件到指定目录下
[root@manager oracle]# pwd
/data/oracle
[root@manager oracle]# ll
total 2988000
-rw-r--r-- 1 root root 3059705302 May  8 15:38 LINUX.X64_193000_db_home.zip


然后解压压缩包,如果没解压工具,则安装。
yum -y install zip unzip

su - oracle
unzip /data/oracle/LINUX.X64_193000_db_home.zip -d  /u01/app/oracle/product/19.2.0/db_1/  #-d表示解压到指定目录下。

4.2、图形化安装Oracle数据库

1、oracle登陆系统

登陆到操作系统图形化界面,切换到Oracle用户
[oracle@localhost db_1]$ export DISPLAY=:0
[oracle@localhost db_1]$ LANG=en_US ./runInstaller

注意:

linux7操作系统图形化安装Oracle软件时,需要设置DISPLAY环境变量,如果不设置DISPLAY环境变量,在启动图形界面的时候,很可能会遇到下面的错误。
[oracle@manager db_1]$ ./runInstaller 
ERROR: Unable to verify the graphical display setup. This application requires X display. Make sure that xdpyinfo exist under PATH variable.

No X11 DISPLAY variable was set, but this program performed an operation which requires it.

处理方法:root用户查看display 环境变量
查看:xdpyinfo | head
设置:export DISPLAY=:0

2、执行安装脚本,安装oracle19c数据库。

3、选择单实例安装

4、选择企业版

5、oracle安装的基目录,之前已创建完成。

6、清单目录,默认即可

7、数据库管理员,默认即可。

8、认证配置脚本,默认。

9、进入安装环节。

注意:安装进度到63%是会跳出界面如下,需要手动执行两个脚本。

[root@manager ~]# sh /u01/app/oraInventory/orainstRoot.sh 

[root@manager ~]# sh /u01/app/oracle/product/19.2.0/db_1/root.sh

10、执行完成脚本后,完成安装。

5、登陆数据库

oracle19c刚安装完成后,登陆数据库时,是一个空数据库(无监听程序和进程,因此需要创建数据库和监听程序)。

1、登陆数据库

切换到oracle用户
[root@manager ~]# su - oracle
Last login: Thu May 20 12:24:52 CST 2021 on pts/1
[oracle@manager ~]$ 
加载环境变量
[oracle@manager ~]$ source .bash_profile 

以dba角色登陆数据库。
[oracle@manager ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Thu May 20 12:27:41 2021
Version 19.3.0.0.0

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

Connected to an idle instance.

SQL> 

2、查看监听程序。

[oracle@manager ~]$ lsnrctl status 

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 20-MAY-2021 12:31:28

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

3、查看oracle的进程,

[oracle@manager ~]$ ps -ef|grep orcl
oracle   14788 14372  0 12:32 pts/1    00:00:00 grep --color=auto orcl
[oracle@manager ~]$ 

4、查看监听端口

[oracle@manager ~]$ netstat  -lntp|grep orcl
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
[oracle@manager ~]$ 

6、创建数据库

1、以oracle用户登录数据库,命令行输入dbca,弹出会话框。

2、选择高级配置选项

3、创建容器数据库,输入数据库全局名称、SID和PDB的 名称

4、是否创建监听程序,暂时跳过,后期创建。

5、选择data Vault配置下,默认即可。

7、oracle的内存区域配置和字符集配置

8、取消勾选EM选项

9、输入管理员密码

10、创建一个数据库

11、设置sys和system的用户名密码。

等待后,完成数据库的创建。

7、创建监听程序

1、创建数据库后,如果需要通过远程连接,需要创建监听程序。以oracle用户登录,命令行输入netca,调出会话框。如下所示;

2、添加监听配置

3、选择或配置监听端口,然后下一步,默认即可。

8、再次查看数据库的进程,监听端口和数据库。

8.1、查看数据库进程

[oracle@manager oracle]$ ps -ef|grep orcl
oracle   21368     1  0 13:38 ?        00:00:00 ora_pmon_orclpdb19c
oracle   21370     1  0 13:38 ?        00:00:00 ora_clmn_orclpdb19c
oracle   21372     1  0 13:38 ?        00:00:00 ora_psp0_orclpdb19c
oracle   21375     1  2 13:38 ?        00:00:43 ora_vktm_orclpdb19c
oracle   21379     1  0 13:38 ?        00:00:00 ora_gen0_orclpdb19c
oracle   21381     1  0 13:38 ?        00:00:00 ora_mman_orclpdb19c
oracle   21385     1  0 13:38 ?        00:00:00 ora_gen1_orclpdb19c
oracle   21388     1  0 13:38 ?        00:00:00 ora_diag_orclpdb19c
oracle   21390     1  0 13:38 ?        00:00:00 ora_ofsd_orclpdb19c
oracle   21393     1  0 13:38 ?        00:00:02 ora_dbrm_orclpdb19c
oracle   21395     1  0 13:38 ?        00:00:00 ora_vkrm_orclpdb19c
oracle   21397     1  0 13:38 ?        00:00:00 ora_svcb_orclpdb19c
oracle   21399     1  0 13:38 ?        00:00:00 ora_pman_orclpdb19c
oracle   21401     1  0 13:38 ?        00:00:04 ora_dia0_orclpdb19c
oracle   21403     1  0 13:38 ?        00:00:00 ora_dbw0_orclpdb19c
oracle   21405     1  0 13:38 ?        00:00:00 ora_lgwr_orclpdb19c
oracle   21408     1  0 13:38 ?        00:00:00 ora_ckpt_orclpdb19c
oracle   21410     1  0 13:38 ?        00:00:00 ora_lg00_orclpdb19c
oracle   21412     1  0 13:38 ?        00:00:00 ora_smon_orclpdb19c
oracle   21414     1  0 13:38 ?        00:00:00 ora_lg01_orclpdb19c
oracle   21416     1  0 13:38 ?        00:00:00 ora_smco_orclpdb19c
oracle   21418     1  0 13:38 ?        00:00:00 ora_reco_orclpdb19c
oracle   21420     1  0 13:38 ?        00:00:00 ora_w000_orclpdb19c
oracle   21422     1  0 13:38 ?        00:00:00 ora_lreg_orclpdb19c
oracle   21424     1  0 13:38 ?        00:00:00 ora_w001_orclpdb19c
oracle   21426     1  0 13:38 ?        00:00:00 ora_pxmn_orclpdb19c
oracle   21430     1  0 13:38 ?        00:00:03 ora_mmon_orclpdb19c
oracle   21432     1  0 13:38 ?        00:00:00 ora_mmnl_orclpdb19c
oracle   21434     1  0 13:38 ?        00:00:00 ora_d000_orclpdb19c
oracle   21436     1  0 13:38 ?        00:00:00 ora_s000_orclpdb19c
oracle   21438     1  0 13:38 ?        00:00:00 ora_tmon_orclpdb19c
oracle   21443     1  0 13:38 ?        00:00:01 ora_m000_orclpdb19c
oracle   21445     1  0 13:38 ?        00:00:08 ora_m001_orclpdb19c
oracle   21452     1  0 13:38 ?        00:00:00 ora_tt00_orclpdb19c
oracle   21454     1  0 13:38 ?        00:00:00 ora_tt01_orclpdb19c
oracle   21456     1  0 13:38 ?        00:00:00 ora_tt02_orclpdb19c
oracle   21460     1  0 13:38 ?        00:00:00 ora_aqpc_orclpdb19c
oracle   21463     1  0 13:38 ?        00:00:00 ora_w002_orclpdb19c
oracle   21467     1  0 13:38 ?        00:00:00 ora_p000_orclpdb19c
oracle   21469     1  0 13:38 ?        00:00:00 ora_p001_orclpdb19c
oracle   21471     1  0 13:38 ?        00:00:01 ora_p002_orclpdb19c
oracle   21473     1  0 13:38 ?        00:00:00 ora_p003_orclpdb19c
oracle   21475     1  0 13:38 ?        00:00:00 ora_p004_orclpdb19c
oracle   21477     1  0 13:38 ?        00:00:00 ora_p005_orclpdb19c
oracle   21479     1  0 13:38 ?        00:00:00 ora_p006_orclpdb19c
oracle   21481     1  0 13:38 ?        00:00:00 ora_p007_orclpdb19c
oracle   21483     1  0 13:38 ?        00:00:00 ora_p008_orclpdb19c
oracle   21485     1  0 13:38 ?        00:00:00 ora_p009_orclpdb19c
oracle   21487     1  0 13:38 ?        00:00:00 ora_p00a_orclpdb19c
oracle   21489     1  0 13:38 ?        00:00:00 ora_p00b_orclpdb19c
oracle   21491     1  0 13:38 ?        00:00:00 ora_p00c_orclpdb19c
oracle   21493     1  0 13:38 ?        00:00:00 ora_p00d_orclpdb19c
oracle   21495     1  0 13:38 ?        00:00:00 ora_p00e_orclpdb19c
oracle   21497     1  0 13:38 ?        00:00:00 ora_p00f_orclpdb19c
oracle   21499     1  0 13:38 ?        00:00:02 ora_cjq0_orclpdb19c
oracle   21676     1  0 13:38 ?        00:00:00 ora_w003_orclpdb19c
oracle   21715     1  0 13:38 ?        00:00:00 ora_w004_orclpdb19c
oracle   21720     1  0 13:38 ?        00:00:02 ora_m002_orclpdb19c
oracle   21722     1  0 13:38 ?        00:00:00 ora_qm02_orclpdb19c
oracle   21732     1  0 13:38 ?        00:00:00 ora_q003_orclpdb19c
oracle   21752     1  0 13:38 ?        00:00:01 ora_m003_orclpdb19c
oracle   21755     1  0 13:38 ?        00:00:00 ora_q004_orclpdb19c
oracle   21758     1  0 13:38 ?        00:00:00 ora_w005_orclpdb19c
oracle   21826     1  0 13:38 ?        00:00:00 ora_w006_orclpdb19c
oracle   21853     1  0 13:39 ?        00:00:00 ora_w007_orclpdb19c
oracle   22376     1  0 13:48 ?        00:00:01 ora_m004_orclpdb19c
oracle   22382     1  0 13:48 ?        00:00:00 ora_w008_orclpdb19c
oracle   22387     1  0 13:48 ?        00:00:00 ora_w009_orclpdb19c
oracle   22391     1  0 13:48 ?        00:00:00 ora_w00a_orclpdb19c
oracle   22396     1  0 13:48 ?        00:00:00 ora_w00b_orclpdb19c
oracle   22400     1  0 13:48 ?        00:00:00 ora_w00c_orclpdb19c
oracle   22412     1  0 13:48 ?        00:00:00 ora_w00d_orclpdb19c
oracle   22417     1  0 13:48 ?        00:00:00 ora_w00e_orclpdb19c
oracle   22421     1  0 13:48 ?        00:00:00 ora_w00f_orclpdb19c
oracle   23700 14372  0 14:07 pts/1    00:00:00 grep --color=auto orcl
[oracle@manager oracle]$ 

8.2、查看监听程序状态

[oracle@manager oracle]$ lsnrctl  status 

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 20-MAY-2021 14:08:44

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=manager)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                20-MAY-2021 13:59:04
Uptime                    0 days 0 hr. 9 min. 40 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/manager/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=manager)(PORT=1521)))
Services Summary...
Service "86b637b62fdf7a65e053f706e80a27ca" has 1 instance(s).
  Instance "orclpdb19c", status READY, has 1 handler(s) for this service...
Service "c2bd59d85ecf53fce0537ad115acfd2a" has 1 instance(s).
  Instance "orclpdb19c", status READY, has 1 handler(s) for this service...
Service "orclpdb" has 1 instance(s).
  Instance "orclpdb19c", status READY, has 1 handler(s) for this service...
Service "orclpdb19c" has 1 instance(s).
  Instance "orclpdb19c", status READY, has 1 handler(s) for this service...
Service "orclpdb19cXDB" has 1 instance(s).
  Instance "orclpdb19c", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@manager oracle]$ 

8.3、查看监听端口

[oracle@manager oracle]$ netstat  -lntp|grep 1521
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::1521                 :::*                    LISTEN      23076/tnslsnr       
[oracle@manager oracle]$ 

8.4、登陆数据库


登陆数据库。
[oracle@manager oracle]$ sqlplus  / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Thu May 20 14:26:52 2021
Version 19.3.0.0.0

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

Connected to an idle instance.

SQL> 


启动数据库
SQL> startup
ORACLE instance started.

Total System Global Area 4999609728 bytes
Fixed Size                  9145728 bytes
Variable Size             973078528 bytes
Database Buffers         4009754624 bytes
Redo Buffers                7630848 bytes
Database mounted.
Database opened.
SQL> 

关闭数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> 

查看容器数据库
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ORCLPDB                        MOUNTED
SQL> 

至此,oracle19c数据库安装完成。

标签:Oracle19c,38,00,oracle,orclpdb19c,Oracle,Centos7.4,13,ora
来源: https://blog.csdn.net/u011208222/article/details/117020923