CENTOS Linux 下 ORACLE 19C RPM 安装详细步骤
1 基础环境准备
CentOS Linux release 7.8.2003 (Core)
oracle-database-ee-19c-1.0-1.x86_64.rpm
oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
2关闭防火墙
sellinux 设置为 SELINUX=disabled
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]#
[root@localhost ~]# setenforce 0
[root@localhost ~]#
3更改主机名,配置host文件
[root@localhost ~]# hostnamectl set-hostname oracle
[root@localhost ~]# bash
bash
[root@oracle ~]#
[root@oracle ~]# more etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.5.133 oracle
[root@oracle ~]#
4配置yum源,DNS
[root@oracle ~]# cd etc/yum.repos.d/
[root@oracle yum.repos.d]# ls
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo CentOS-x86_64-kernel.repo
CentOS-Debuginfo.repo CentOS-Sources.repo
[root@oracle yum.repos.d]# rm -rf *
[root@oracle yum.repos.d]#
[root@oracle yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
--2021-02-27 11:50:39-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 58.221.54.116, 58.221.54.115, 61.155.221.135, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|58.221.54.116|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘Centos-7.repo’
Centos-7.repo 100%[===================>] 2.46K --.-KB/s in 0s
2021-02-27 11:50:39 (14.5 MB/s) - ‘Centos-7.repo’ saved [2523/2523]
[root@oracle ~]# more etc/resolv.conf
# Generated by NetworkManager
search localdomain
nameserver 192.168.5.2
nameserver 1.2.4.8
[root@oracle ~]#
4 oralce preinstall
[root@oracle ~]# yum -y install oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
Loaded plugins: fastestmirror
Examining oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm: oracle-database-preinstall-19c-1.0-1.el7.x86_64
Marking oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package oracle-database-preinstall-19c.x86_64 0:1.0-1.el7 will be installed
--> Processing Dependency: bc for package: oracle-database-preinstall-19c-1.0-1.el7.x86_64
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
--> Processing Dependency: bind-utils for package: oracle-database-preinstall-19c-1.0-1.el7.x86_64
--> Processing Dependency: compat-libcap1 for package: oracle-database-preinstall-19c-1.0-1.el7.x86_64
--> Processing Dependency: compat-libstdc++-33 for package: oracle-database-preinstall-19c-1.0-1.el7.x86_64
--> Processing Dependency: glibc-devel for package: oracle-database-preinstall-19c-1.0-1.el7.x86_64
--> Processing Dependency: ksh for package: oracle-database-preinstall-19c-1.0-1.el7.x86_64
--> Processing Dependency: libaio for package: oracle-database-preinstall-19c-1.0-1.el7.x86_64
...
...
libverto-libevent.x86_64 0:0.2.5-4.el7 libxcb.x86_64 0:1.13-1.el7
lm_sensors-libs.x86_64 0:3.4.0-8.20160601gitf9185e5.el7 mailx.x86_64 0:12.5-19.el7
net-tools.x86_64 0:2.0-0.25.20131004git.el7 nfs-utils.x86_64 1:1.3.0-0.68.el7
psmisc.x86_64 0:22.20-17.el7 quota.x86_64 1:4.01-19.el7
quota-nls.noarch 1:4.01-19.el7 rpcbind.x86_64 0:0.2.0-49.el7
smartmontools.x86_64 1:7.0-2.el7 sysstat.x86_64 0:10.1.5-19.el7
tcp_wrappers.x86_64 0:7.6-77.el7 unzip.x86_64 0:6.0-21.el7
xorg-x11-utils.x86_64 0:7.5-23.el7 xorg-x11-xauth.x86_64 1:1.0.9-1.el7
Dependency Updated:
glibc.x86_64 0:2.17-323.el7_9 glibc-common.x86_64 0:2.17-323.el7_9 libstdc++.x86_64 0:4.8.5-44.el7
Complete!
[root@oracle ~]#
5 安装数据库软件
[root@oracle ~]# yum -y install oracle-database-ee-19c-1.0-1.x86_64.rpm
Loaded plugins: fastestmirror
Examining oracle-database-ee-19c-1.0-1.x86_64.rpm: oracle-database-ee-19c-1.0-1.x86_64
Marking oracle-database-ee-19c-1.0-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package oracle-database-ee-19c.x86_64 0:1.0-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
oracle-database-ee-19c x86_64 1.0-1 oracle-database-ee-19c-1.0-1.x86_64 6.9 G
Transaction Summary
====================================================================================================================
Install 1 Package
Total size: 6.9 G
Installed size: 6.9 G
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 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
Verifying : oracle-database-ee-19c-1.0-1.x86_64 1/1
Installed:
oracle-database-ee-19c.x86_64 0:1.0-1
Complete!
[root@oracle ~]#
6安装数据库
oracle19c的修改配置文件为:
/etc/init.d/oracledb_ORCLCDB-19c,可自行修改
[root@oracle ~]# /etc/init.d/oracledb_ORCLCDB-19c configure
Configuring Oralce Database ORCLCDB
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and staring Oracle instance
32% complete
36% complete
...
7切换oracle用户,.bash_profile添加环境变量
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
export ORACLE_SID=ORCLCDB
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin
8 创建用户,表空间
[oracle@localhost ~]$ sqlplus as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Feb 27 22:28:59 2021
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> select name ,con_id from v$services;
NAME CON_ID
---------------------------------------------------------------- ----------
ORCLCDBXDB 1
SYS$BACKGROUND 1
SYS$USERS 1
ORCLCDB 1
orclpdb1 3
Elapsed: 00:00:00.01
SQL> alter session set container=orclpdb1;
Session altered.
SQL>
SQL> startup;
Pluggable Database opened.
SQL> create tablespace carl datafile '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/carl.dbf' size 100m autoextend on next 100m;
Tablespace created.
Elapsed: 00:00:01.43
SQL> create user carl identified by oracle default tablespace carl;
User created.
Elapsed: 00:00:00.46
SQL> grant connect,resource,dba to carl;
Grant succeeded.
Elapsed: 00:00:00.02
SQL>
9 19c连接数据库分为两种方式
一种为 alter session set container=orclpdb1;
[oracle@localhost ~]$ sqlplus as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Feb 27 22:42:07 2021
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> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB1 READ WRITE NO
SQL> alter session set container=ORCLPDB1;
Session altered.
Elapsed: 00:00:00.00
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 ORCLPDB1 READ WRITE NO
SQL>
另一种更改 $ORACLE_HOME/network/admin/tnsnames.ora
[oracle@localhost ~]$ sqlplus carl/oracle@orclpdb1
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Feb 27 22:47:18 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Sat Feb 27 2021 22:45:03 +08:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL>