概述
2023 年 4 月 3 日,Oracle Database 23c Free—Developer Release 正式推出,供开发测试。
相关地址如下。
地址:https://www.oracle.com/cn/database/free/
地址:https://www.oracle.com/cn/database/23c/
Oracle Database Free 资源限制
Oracle Database Free 使用限制:
2 个用于前台进程的 CPU
2 GB RAM(SGA 和 PGA 组合)
磁盘上 12 GB 的用户数据(与压缩系数无关)
只能开一个实例
实施过程
下载安装包
下载地址:https://www.oracle.com/database/free/download/
[root@localhost soft]# pwd
/soft
[root@localhost soft]# ll
总用量 1717588
-rw-r--r-- 1 root root 1758776440 8月 17 09:51 oracle-database-free-23c-1.0-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 30688 8月 17 10:04 oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm
更新yum源
[root@localhost soft]# dnf -y localinstall oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm
CentOS Linux 8 - AppStream 92 B/s | 38 B 00:00
错误:为仓库 'appstream' 下载元数据失败 : Cannot prepare internal mirrorlist: No URLs in mirrorlist
sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*
注:出现这个错误提示是因为在2022年1月31日,CentOS 团队从官方镜像中移除 CentOS 8 的所有包。CentOS 8 于2021年12月31日停止官方服务了,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到 https://vault.centos.org。如果仍然需要运行 CentOS 8,你可以在 /etc/yum.repos.d 中更新一下源。使用 vault.centos.org 代替 mirror.centos.org 即可
安装oracle-database-preinstall
[root@db23c soft]# dnf -y localinstall oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm
# 执行日志
[root@db23c results]# pwd
/var/log/oracle-database-preinstall-23c/results
[root@db23c results]#
[root@db23c results]#
[root@db23c results]# ll
总用量 8
-rw-r--r-- 1 root root 22 8月 17 13:24 network
-rw-r--r-- 1 root root 3796 8月 17 13:24 orakernel.log
[root@db23c results]# tail -10f orakernel.log
Successfully added parameter NOZEROCONF to /etc/sysconfig/network
Setting /etc/sysconfig/network parameters passed
Disabling Transparent Hugepages.
Refer Oracle Note:1557478.1
Disabling defrag.
Refer Oracle Note:1557478.1
Taking a backup of old config files under /var/log/oracle-database-preinstall-23c/backup/Aug-17-2023-13-24-13
注: 执行上面rpm实现自动oracle用户创建,一些资源设置等操作。
可以利用rpm2cpio 解压rpm看到里面具体的脚本,了解执行此rpm的具体操作。
[root@localhost tmp]# ll
总用量 32
-rw-r--r-- 1 root root 30688 8月 17 13:29 oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm
[root@localhost tmp]# cd usr/share/licenses/^C
[root@localhost tmp]# pwd
/soft/tmp
[root@localhost tmp]# rpm2cpio oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm | cpio -div
./etc/rc.d/init.d/oracle-database-preinstall-23c-firstboot
./etc/sysconfig/oracle-database-preinstall-23c
./etc/sysconfig/oracle-database-preinstall-23c/oracle-database-preinstall-23c-verify
./etc/sysconfig/oracle-database-preinstall-23c/oracle-database-preinstall-23c.param
./usr/bin/oracle-database-preinstall-23c-verify <==============
./usr/share/licenses/oracle-database-preinstall-23c
./usr/share/licenses/oracle-database-preinstall-23c/LICENSE
./var/log/oracle-database-preinstall-23c
./var/log/oracle-database-preinstall-23c/results
159 块
安装oracle-database-free
[root@db23c soft]# dnf -y localinstall oracle-database-free-23c-1.0-1.el8.x86_64.rpm
上次元数据过期检查:0:41:42 前,执行于 2023年08月17日 星期四 13时24分23秒。
依赖关系解决。
=================================================================================================================================================================================================
软件包 架构 版本 仓库 大小
=================================================================================================================================================================================================
安装:
oracle-database-free-23c x86_64 1.0-1 @commandline 1.6 G
事务概要
=================================================================================================================================================================================================
安装 1 软件包
总计:1.6 G
安装大小:5.2 G
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
运行脚本: oracle-database-free-23c-1.0-1.x86_64 1/1
安装 : oracle-database-free-23c-1.0-1.x86_64 1/1
运行脚本: oracle-database-free-23c-1.0-1.x86_64 1/1
[INFO] Executing post installation scripts...
[INFO] Oracle home installed successfully and ready to be configured.
To configure Oracle Database Free, optionally modify the parameters in '/etc/sysconfig/oracle-free-23c.conf' and then run '/etc/init.d/oracle-free-23c configure' as root.
验证 : oracle-database-free-23c-1.0-1.x86_64 1/1
已安装:
oracle-database-free-23c-1.0-1.x86_64
完毕!
配置数据库
[root@db23c oracle]# /etc/init.d/oracle-free-23c configure
Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database FREE.
输入 SYS 用户口令:
************
输入 SYSTEM 用户口令:
*********
输入 PDBADMIN 用户口令:
*********
准备执行数据库操作
已完成 7%
复制数据库文件
已完成 29%
正在创建并启动 Oracle 实例
已完成 30%
已完成 33%
已完成 36%
已完成 39%
已完成 43%
正在进行数据库创建
已完成 47%
已完成 49%
已完成 50%
正在创建插接式数据库
已完成 54%
已完成 71%
执行配置后操作
已完成 93%
正在运行定制脚本
已完成 100%
数据库创建完成。有关详细信息, 请查看以下位置的日志文件:
/opt/oracle/cfgtoollogs/dbca/FREE。
数据库信息:
全局数据库名:FREE
系统标识符 (SID):FREE
有关详细信息, 请参阅日志文件 "/opt/oracle/cfgtoollogs/dbca/FREE/FREE.log"。
Connect to Oracle Database using one of the connect strings:
Pluggable database: db23c/FREEPDB1
Multitenant container database: db23c
相关目录
目录 | 用途 |
---|---|
/opt/oracle | Oracle base目录,产品根目录 |
/opt/oracle/product/23c/dbhomeFree | oracle 数据库安装目录 |
/opt/oracle/oradata/FREE | FREE实例的数据目录 |
/opt/oracle/diag | 诊断日志目录 |
/opt/oracle/cfgtoollogs/dbca/FREE | FREE实例的初始化目录 |
/etc/sysconfig/oracle-free-23c.conf | 实例默认配置文件 |
/etc/init.d/oracle-free-23c | 服务脚本 |
连接测试
[oracle@db23c ~]$ export ORACLE_SID=FREE
[oracle@db23c ~]$ export ORAENV_ASK=NO
[oracle@db23c ~]$ . /opt/oracle/product/23c/dbhomeFree/bin/oraenv
[oracle@db23c ~]$ sqlplus / as sysdba
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Thu Aug 17 14:46:44 2023
Version 23.2.0.0.0
Copyright (c) 1982, 2023, Oracle. All rights reserved.
???:
Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
SQL> select userenv('language');
USERENV('LANGUAGE')
----------------------------------------------------
SIMPLIFIED CHINESE_CHINA.AL32UTF8
# 出现乱码,设置NLS_LANG
[oracle@db23c ~]$ export NLS_LANG='SIMPLIFIED CHINESE_CHINA.AL32UTF8'
[oracle@db23c ~]$ sqlplus / as sysdba
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on 星期四 8月 17 14:48:11 2023
Version 23.2.0.0.0
Copyright (c) 1982, 2023, Oracle. All rights reserved.
连接到:
Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
SQL>
可以设置环境变量,后续就无需执行oraenv
[oracle@db23c ~]$ vi .bash_profile
export ORACLE_SID=FREE
export ORACLE_BASE=/opt/oracle
export LANG=zh_CN.UTF-8
export ORACLE_HOME=/opt/oracle/product/23c/dbhomeFree
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/product/23c/dbhomeFree/lib
export NLS_LANG='SIMPLIFIED CHINESE_CHINA.AL32UTF8'
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export TMP=/tmp
export TMPDIR=
umask 022
设置SQL提示符
[oracle@db23c admin]$ pwd
/opt/oracle/product/23c/dbhomeFree/sqlplus/admin
[oracle@db23c admin]$ cat glogin.sql
--
-- Copyright (c) 1988, 2005, Oracle. All Rights Reserved.
--
-- NAME
-- glogin.sql
--
-- DESCRIPTION
-- SQL*Plus global login "site profile" file
--
-- Add any SQL*Plus commands here that are to be executed when a
-- user starts SQL*Plus, or uses the SQL*Plus CONNECT command.
--
-- USAGE
-- This script is automatically run
--
set feedback on
set termout off
define prpt=idle
column display_prompt new_value prpt
select lower(user)||'@'||global_name display_prompt from global_name;
set sqlprompt '&prpt>'
set termout on
创建测试pdb
SQL> create pluggable database zspdb ADMIN USER zs IDENTIFIED BY 123456 FILE_NAME_CONVERT = ('/opt/oracle/oradata/FREE/pdbseed','/opt/oracle/oradata/FREE/zspdb');
插接式数据库已创建。
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 FREEPDB1 READ WRITE NO
4 ZSPDB MOUNTED
SQL> alter pluggable database all open;
数据库管理
使用 SQL*Plus 启动关闭
$ sqlplus / as sysdba
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP
SQL> ALTER PLUGGABLE DATABASE ALL OPEN;
使用配置服务脚本 启动关闭
[root@db23c ~]# /etc/init.d/oracle-free-23c
Usage: /etc/init.d/oracle-free-23c {start|stop|restart|configure|delete|status}
# stop 命令会同时关闭监听和数据库
[root@db23c ~]# /etc/init.d/oracle-free-23c stop
Shutting down Oracle Database instance FREE.
Oracle Database instance FREE shut down.
Stopping Oracle Net Listener.
Oracle Net Listener stopped.
# start 命令会同时开启监听和数据库
[root@db23c ~]# /etc/init.d/oracle-free-23c start
Starting Oracle Net Listener.
Oracle Net Listener started.
Starting Oracle Database instance FREE.
Oracle Database instance FREE started.
[root@db23c ~]# /etc/init.d/oracle-free-23c status
Status of the Oracle FREE 23c service:
LISTENER status: RUNNING
FREE Database status: RUNNING
使用系统自启动
[root@db23c ~]# systemctl daemon-reload
[root@db23c ~]# systemctl enable oracle-free-23c
oracle-free-23c.service is not a native service, redirecting to systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable oracle-free-23c
[root@db23c ~]# systemctl start oracle-free-23c
[root@db23c ~]# systemctl status oracle-free-23c
● oracle-free-23c.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services.
Loaded: loaded (/etc/rc.d/init.d/oracle-free-23c; generated)
Active: active (exited) since Thu 2023-08-17 15:07:09 CST; 8s ago
Docs: man:systemd-sysv-generator(8)
Process: 45994 ExecStart=/etc/rc.d/init.d/oracle-free-23c start (code=exited, status=0/SUCCESS)
8月 17 15:06:45 db23c systemd[1]: Starting SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services....
8月 17 15:06:45 db23c oracle-free-23c[45994]: Starting Oracle Net Listener.
8月 17 15:06:45 db23c su[46001]: (to oracle) root on none
8月 17 15:06:45 db23c su[46001]: pam_unix(su:session): session opened for user oracle by (uid=0)
8月 17 15:06:55 db23c oracle-free-23c[45994]: Oracle Net Listener started.
8月 17 15:06:55 db23c oracle-free-23c[45994]: Starting Oracle Database instance FREE.
8月 17 15:06:55 db23c su[46055]: (to oracle) root on none
8月 17 15:06:55 db23c su[46055]: pam_unix(su:session): session opened for user oracle by (uid=0)
8月 17 15:07:09 db23c oracle-free-23c[45994]: Oracle Database instance FREE started.
8月 17 15:07:09 db23c systemd[1]: Started SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services..
[root@db23c ~]# systemctl stop oracle-free-23c
[root@db23c ~]# systemctl status oracle-free-23c
● oracle-free-23c.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services.
Loaded: loaded (/etc/rc.d/init.d/oracle-free-23c; generated)
Active: inactive (dead) since Thu 2023-08-17 15:07:45 CST; 11s ago
Docs: man:systemd-sysv-generator(8)
Process: 46500 ExecStop=/etc/rc.d/init.d/oracle-free-23c stop (code=exited, status=0/SUCCESS)
Process: 45994 ExecStart=/etc/rc.d/init.d/oracle-free-23c start (code=exited, status=0/SUCCESS)
8月 17 15:07:29 db23c oracle-free-23c[46500]: Shutting down Oracle Database instance FREE.
8月 17 15:07:29 db23c su[46507]: (to oracle) root on none
8月 17 15:07:29 db23c su[46507]: pam_unix(su:session): session opened for user oracle by (uid=0)
8月 17 15:07:40 db23c oracle-free-23c[46500]: Oracle Database instance FREE shut down.
8月 17 15:07:40 db23c oracle-free-23c[46500]: Stopping Oracle Net Listener.
8月 17 15:07:40 db23c su[46517]: (to oracle) root on none
8月 17 15:07:40 db23c su[46517]: pam_unix(su:session): session opened for user oracle by (uid=0)
8月 17 15:07:45 db23c oracle-free-23c[46500]: Oracle Net Listener stopped.
8月 17 15:07:45 db23c systemd[1]: oracle-free-23c.service: Succeeded.
8月 17 15:07:45 db23c systemd[1]: Stopped SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services..
[root@db23c systemd]# cat /run/systemd/generator.late/oracle-free-23c.service
# Automatically generated by systemd-sysv-generator
[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/rc.d/init.d/oracle-free-23c
Description=SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services.
Before=multi-user.target
Before=multi-user.target
Before=multi-user.target
Before=graphical.target
Before=oracle-database-preinstall-23c-firstboot.service
[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/rc.d/init.d/oracle-free-23c start <===========
ExecStop=/etc/rc.d/init.d/oracle-free-23c stop <===========
[root@db23c systemd]# cat /etc/rc.d/init.d/oracle-free-23c|wc -l
697
[root@db23c systemd]# cat /etc/init.d/oracle-free-23c |wc -l
697
注:systemctl管理的oracle-free-23c服务,实际上调用的依然是最初的/etc/init.d/oracle-free-23c脚本管理的数据库。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。