Oracle官方提供了安装好的Oracle 19c虚拟机,打包成ova文件。可以使用这个文件建立一个oracle 19c的学习环境。
下载Oracle官方的虚拟机(OVA文件)
Oracle官方提供了ova文件创建虚拟机,其中安装好Oracle 19c 的ova完的下载地址是:https://www.oracle.com/database/technologies/databaseappdev-vm.html
使用OVA文件创建新的虚拟机
可以使用Oracle提供的OVA在VirtualBox上创建虚拟机。在VirtualBox中选择File 再选择 Import Appliance ,然后选择前面下载的ova文件,如下图:
接着出现配置界面:
这里的配置可以修改,我把2GB的内存改成了4GB。然后点击import,同意协议后导入:
导入后启动虚拟机,增加了一个bridge的网卡:
登录oracle用户,密码也是oracle,配置网络:
检查环境
看看Oracle为我们提供的虚拟机的环境:
[oracle@localhost network-scripts]$ chkconfig --list oracle
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。要列出 systemd 服务,请执行 'systemctl list-unit-files'。查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。oracle 0:关 1:关 2:开 3:开 4:开 5:开 6:关
可以看到多了一个oracle的服务,这样一开机oracle数据库就启动了,这个服务的管理脚本是/etc/rc.d/init.d/oracle文件。
查看一个oracle工具用到的配置文件:
[oracle@localhost ~]$ cat /etc/oratab ... orclcdb:/u01/app/oracle/product/version/db_1:Y
发现已经有了一个sid为orclcdb的实例。
检查一下oracle用户的环境变量,发现居然没有配置:
[oracle@localhost ~]$ env|grep -i oracle USER=oracle MAIL=/var/spool/mail/oracle PATH=/home/oracle/Desktop/Database_Track/coffeeshop:/home/oracle/java/jdk1.8.0_201/bin:/home/oracle/bin:/home/oracle/sqlcl/bin:/home/oracle/sqldeveloper:/home/oracle/datamodeler:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/oracle/sqlcl/bin:/home/oracle/sqldeveloper:/home/oracle/bin:/home/oracle/.local/bin:/home/oracle/bin PWD=/home/oracle JAVA_HOME=/home/oracle/java/jdk1.8.0_201 HOME=/home/oracle LOGNAME=oracle XDG_DATA_DIRS=/home/oracle/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
手工增加下面的配置到.bash_profile文件中:
export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/version/db_1 export LD_LIBRARY_PATH=$ORACLE_HOME/lib export PATH=$PATH:$ORACLE_HOME/bin:$JAVA_HOME/bin export ORACLE_SID=orclcdb export PATH=$JAVA_HOME/bin:$ORACLE_HOME/bin:$PATH
检查监听的状态:
[oracle@localhost ~]$ lsnrctl status LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 16-MAR-2022 01:59:51 Copyright (c) 1991, 2019, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production Start Date 16-MAR-2022 09:42:48 Uptime 496 days 18 hr. 44 min. 56 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Default Service orclcdb Listener Parameter File /u01/app/oracle/product/version/db_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=8081))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "86b637b62fdf7a65e053f706e80a27ca" has 1 instance(s). Instance "orclcdb", status READY, has 1 handler(s) for this service... Service "8a34def16cd55c76e0530100007f040c" has 1 instance(s). Instance "orclcdb", status READY, has 1 handler(s) for this service... Service "orcl" has 1 instance(s). Instance "orclcdb", status READY, has 1 handler(s) for this service... Service "orclcdb" has 2 instance(s). Instance "orclcdb", status UNKNOWN, has 1 handler(s) for this service... Instance "orclcdb", status READY, has 1 handler(s) for this service... Service "orclcdbXDB" has 1 instance(s). Instance "orclcdb", status READY, has 1 handler(s) for this service... The command completed successfully
使用操作系统认证登录sqlplus,居然登录失败:
[oracle@localhost ~]$ sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 16 01:59:59 2022 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle. All rights reserved. ERROR: ORA-01017: invalid username/password; logon denied
检查一下TWO_TASK环境变量的设置,果然是设置了TWO_TASK,取消设置后就可以使用操作系统认证登录了:
[oracle@localhost ~]$ echo $TWO_TASK ORCL [oracle@localhost ~]$ unset TWO_TASK [oracle@localhost ~]$ echo $TWO_TASK [oracle@localhost ~]$ sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 16 02:06:56 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>
TWO_TASK设置了默认的服务名连接,例如下面的连接使用了TWO_TASK指定的服务:
[oracle@localhost ~]$ sqlplus oracleace/oracleace SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 16 02:11:42 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>
结束
好了,现在一套Oracle 19c的模版已经建好了,可以开始学习了!