Press "Enter" to skip to content

Centos7 RPM包安装 Oracle数据库

Install Oracle Database 19c from RPM Package.


下载安装包

通过下面的链接下载 Oracle Databse 19c,上传到你的服务器上。

https://www.oracle.com/database/technologies/oracle-database-software-downloads.html

预安装

安装一些需要用到的预安装工具

[root@dlp ~]# curl http://public-yum.oracle.com/public-yum-ol7.repo -o /etc/yum.repos.d/public-yum-ol7.repo
[root@dlp ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/public-yum-ol7.repo
[root@dlp ~]# rpm --import http://yum.oracle.com/RPM-GPG-KEY-oracle-ol7
[root@dlp ~]# yum --enablerepo=ol7_latest -y install oracle-database-preinstall-19c

安装Oracle Database 19c.

执行安装包安装指令

[root@dlp ~]# rpm -Uvh oracle-database-ee-19c-1.0-1.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:oracle-database-ee-19c-1.0-1     ################################# [100%]
[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

[root@dlp ~]# vi /etc/sysconfig/oracledb_ORCLCDB-19c.conf
# change default settings if you need
# listening port for Listener
LISTENER_PORT=1521

# data location
ORACLE_DATA_LOCATION=/opt/oracle/oradata

# EM_EXPRESS_PORT: Oracle EM Express listener
# listening port for Enterprise Manager
EM_EXPRESS_PORT=5500

# create sample Database [ORCLCDB]
[root@dlp ~]# /etc/init.d/oracledb_ORCLCDB-19c configure
Configuring Oracle Database ORCLCDB.
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
Database Information:
Global Database Name:ORCLCDB
System Identifier(SID):ORCLCDB
Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.

Database configuration completed successfully. The passwords were auto generated, you must change them by connecting to the database using 'sqlplus / as sysdba' as the oracle user.

环境配置

为Oracle用户配置环境变量

[oracle@dlp ~]$ vi ~/.bash_profile
# add to the end
umask 022
export ORACLE_SID=ORCLCDB
export ORACLE_BASE=/opt/oracle/oradata
export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
[oracle@dlp ~]$ source ~/.bash_profile
# verify connection
[oracle@dlp ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jan 21 21:22:53 2020
Version 19.3.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

开机启动

创建Systemd配置文件

[root@dlp ~]# vi /etc/oratab
# last line : change
ORCLCDB:/opt/oracle/product/19c/dbhome_1:Y
[root@dlp ~]# vi /etc/sysconfig/ORCLCDB.oracledb
# create new : define environment variables
ORACLE_BASE=/opt/oracle/oradata
ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
ORACLE_SID=ORCLCDB
# configure listener service
[root@dlp ~]# vi /usr/lib/systemd/system/ORCLCDB@lsnrctl.service
# this is an example, modify for free
[Unit]
Description=Oracle Net Listener
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/ORCLCDB.oracledb
ExecStart=/opt/oracle/product/19c/dbhome_1/bin/lsnrctl start
ExecStop=/opt/oracle/product/19c/dbhome_1/bin/lsnrctl stop
User=oracle

[Install]
WantedBy=multi-user.target

# configure database service
[root@dlp ~]# vi /usr/lib/systemd/system/ORCLCDB@oracledb.service
# this is an example, modify for free
[Unit]
Description=Oracle Database service
After=network.target lsnrctl.service

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/ORCLCDB.oracledb
ExecStart=/opt/oracle/product/19c/dbhome_1/bin/dbstart $ORACLE_HOME
ExecStop=/opt/oracle/product/19c/dbhome_1/bin/dbshut $ORACLE_HOME
User=oracle

[Install]
WantedBy=multi-user.target

[root@dlp ~]# systemctl daemon-reload
[root@dlp ~]# systemctl enable ORCLCDB@lsnrctl ORCLCDB@oracledb

使用SQL*Plus工具来查看CDBs和PDBs的信息

[root@localhost ~]# su oracle
[oracle@localhost root]$ source ~/.bash_profile
[oracle@localhost root]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 21 11:20:48 2022
Version 19.3.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL>
SQL> COLUMN NAME FORMAT A8
SQL> SELECT NAME, CON_ID, DBID, CON_UID, GUID FROM V$CONTAINERS ORDER BY CON_ID;

NAME	     CON_ID	  DBID	  CON_UID GUID
-------- ---------- ---------- ---------- --------------------------------
CDB$ROOT	  1 2886641538		1 86B637B62FDF7A65E053F706E80A27CA
PDB$SEED	  2  963926515	963926515 E8CAA1DDCF69289DE055000000000001
ORCLPDB1	  3  594444352	594444352 E8CAC27A92B6313CE055000000000001

参考资料:

https://www.server-world.info/en/note?os=CentOS_7&p=oracle19c&f=6

https://docs.oracle.com/database/121/ADMIN/cdb_mon.htm#ADMIN14174

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注