参考:https://blog.csdn.net/cpeiqing/article/details/109080202
准备rpm包
1.下载rpm安装包,包括以下两个
oracle-database-ee-19c-1.0-1.x86_64.rpm
oracle-database-preinstall-19c-1.0-3.el7.x86_64.rpm
2. 上传至服务器opt文件夹
安装ORACLE数据库
1. 安装preinstall
yum localinstall -y oracle-database-preinstall-19c-1.0-3.el7.x86_64.rpm
2. 安装Oracle
yum localinstall -y oracle-database-ee-19c-1.0-1.x86_64.rpm
等待安装结果即可。安装完成后的结果如下图:
3. 修改字符集以及其他的配置
oracle19c的修改配置文件为
vim /etc/init.d/oracledb_ORCLCDB-19c
主要是修改字符编码 export CHARSET=ZHS16GBK
export ORACLE_VERSION=19c
export ORACLE_SID=ORCLCDB
export TEMPLATE_NAME=General_Purpose.dbc
export CHARSET=ZHS16GBK
export PDB_NAME=ORCLPDB1
export LISTENER_NAME=LISTENER
export NUMBER_OF_PDBS=1
export CREATE_AS_CDB=true
初始化数据库
使用root用户进行Oracle数据化操作
/etc/init.d/oracledb_ORCLCDB-19c configure
等待Oracle数据库执行初始化操作即可,等待时间较久
配置环境变量
1.修改oracle用户密码
passwd oracle
2.切换至oracle用户,设置环境变量
su oracle
vim .bash_profile
增加环境变量内容
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
export ORACLE_SID=ORCLCDB
export ORACLE_PDB_SID=ORCLPDB1
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export NLS_LANG=american_america.ZHS16GBK
3.使用Oracle登录进行相关的处理
sqlplus / as sysdba
4.创建自动启动pdb的触发器
不设置PDB的开机启动 很多程序无法连接上PDB, 建议使用show pdbs 查看状态, 手工启动也可以. 不能在CDB创建业务数据, 会提示创建的用户名不符合 c###的要求
CREATE TRIGGER open_all_pdbs
AFTER STARTUP ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'alter pluggable database all open';
END open_all_pdbs;
/
5.安装完毕重启数据库服务器
启动数据库
1.却换至oracle用户
su oracle
2.启动数据库
sqlplus / as sysdba
startup
3.修改用户密码
查看已启用的用户
select username from dba_users where account_status='OPEN';
修改sys、system密码
alter user sys identified by 密码
alter user system identified by 密码
4.切换pdb
alter session set container=ORCLPDB1;
startup
到此,Oracle19c安装配置完成,本地防火墙开放1521端口,即可通过PLSQL登录。
常见问题
1.执行lsnrctl status查看无服务,修改listener.ora
2.程序无法链接数据库,数据库连接串修改如下
jdbc:oracle:thin:@IP:端口/ORCLPDB1
ora文件配置
1. listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IP地址需修改)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ORCLPDB1)
(SID_NAME = ORCLCDB)
(ORACLE_HOME=/opt/oracle/product/19c/dbhome_1)
)
)
2.tnsnames.ora
ORCLCDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCLCDB)
)
)
LISTENER_ORCLCDB =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
3.sqlnet.ora
# sqlnet.ora Network Configuration File: /opt/oracle/product/19c/dbhome_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
SQLNET.ALLOWED_LOGON_VERSION=8
数据导入导出
1.导入
impdp 用户名/密码@192.168.152.5/ORCLPDB1 dumpfile=123.dmp