在Ferora35中安装oracle-database-xe-21c
安装准备文件
使用root用户,来安装oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm
[root@fedora Downloads]# rpm -ivh oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm
警告:oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ad986da3: NOKEY
错误:依赖检测失败:
compat-openssl10 被 oracle-database-preinstall-21c-1.0-1.el8.x86_64 需要
ksh 被 oracle-database-preinstall-21c-1.0-1.el8.x86_64 需要
libnsl 被 oracle-database-preinstall-21c-1.0-1.el8.x86_64 需要
smartmontools 被 oracle-database-preinstall-21c-1.0-1.el8.x86_64 需要
sysstat 被 oracle-database-preinstall-21c-1.0-1.el8.x86_64 需要
xorg-x11-utils 被 oracle-database-preinstall-21c-1.0-1.el8.x86_64 需要
提示缺少了各种库,然后一个一个去安装他。安装这些库有两个办法。
1、如果这些库使用dnf可以找到并安装,那就比较方便
2、如果这些库在dnf中找不到,从 https://pkgs.org/ 搜索并下载,然后使用sftp将文件传输到fedora中,然后并安装。如果安装这些库的时候,会提示库找不见,那就参照这两个办法,使用递归的方式去安装他们。
[root@fedora Downloads]# rpm -ivh compat-openssl10-1.0.2o-4.el8.x86_64.rpm
[root@fedora Downloads]# rpm -ivh xorg-x11-utils-7.5-28.el8.x86_64.rpm
警告:xorg-x11-utils-7.5-28.el8.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 8483c65d: NOKEY
错误:依赖检测失败:
libXxf86dga.so.1()(64bit) 被 xorg-x11-utils-7.5-28.el8.x86_64 需要
libXxf86misc.so.1()(64bit) 被 xorg-x11-utils-7.5-28.el8.x86_64 需要
libdmx.so.1()(64bit) 被 xorg-x11-utils-7.5-28.el8.x86_64 需要
[root@fedora Downloads]# dnf install -y libXxf86dga libXxf86misc libdmx
[root@fedora Downloads]# rpm -ivh xorg-x11-utils-7.5-28.el8.x86_64.rpm
[root@fedora Downloads]# dnf install -y ksh
[root@fedora Downloads]# dnf install -y libnsl
[root@fedora Downloads]# dnf install -y smartmontools
[root@fedora Downloads]# dnf install -y sysstat
运气还不错,很快就安装完了。
安装数据库软件
下面才是真正安装oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm和oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm
[root@fedora Downloads]# rpm -ivh oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm
[root@fedora Downloads]# rpm -ivh oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm
警告:oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ad986da3: NOKEY
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:oracle-database-xe-21c-1.0-1 ################################# [100%]
[INFO] Executing post installation scripts...
[INFO] Oracle home installed successfully and ready to be configured.
To configure Oracle Database XE, optionally modify the parameters in '/etc/sysconfig/oracle-xe-21c.conf' and then execute '/etc/init.d/oracle-xe-21c configure' as root.
[root@fedora Downloads]#
创建数据库
根据上述提示,修改 /etc/sysconfig/oracle-xe-21c.conf 的内容,设置端口号为1521
以下是执行“/etc/init.d/oracle-xe-21c configure”的提示
设置的密码为 baby1234
[root@fedora Downloads]# /etc/init.d/oracle-xe-21c 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 XE.
输入 SYS 用户口令:
*********
输入 SYstem 用户口令:
********
输入 PDBADMIN 用户口令:
********
准备执行数据库操作
已完成 7%
复制数据库文件
已完成 29%
正在创建并启动 Oracle 实例
已完成 30%
已完成 33%
已完成 37%
已完成 40%
已完成 43%
正在进行数据库创建
已完成 47%
已完成 50%
正在创建插接式数据库
已完成 54%
已完成 71%
执行配置后操作
已完成 93%
正在运行定制脚本
已完成 100%
数据库创建完成。有关详细信息, 请查看以下位置的日志文件:
/opt/oracle/cfgtoollogs/dbca/XE。
数据库信息:
全局数据库名:XE
系统标识符 (SID):XE
有关详细信息, 请参阅日志文件 "/opt/oracle/cfgtoollogs/dbca/XE/XE.log"。
Connect to Oracle Database using one of the connect strings:
Pluggable database: fedora/XEPDB1
Multitenant container database: fedora
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
此时,oracle数据库服务器已经在运行了。
[root@fedora Downloads]# ps -ef | grep oracle
设置oracle的环境变量
[root@fedora Downloads]# updatedb
[root@fedora Downloads]# su - oracle
[oracle@fedora ~]$ locate tnsnames.ora
/opt/oracle/homes/OraDBHome21cXE/network/admin/tnsnames.ora
/opt/oracle/product/21c/dbhomeXE/hs/admin/tnsnames.ora.sample
/opt/oracle/product/21c/dbhomeXE/inventory/Templates/hs/admin/tnsnames.ora.sample
/opt/oracle/product/21c/dbhomeXE/network/admin/samples/tnsnames.ora
[oracle@fedora dbhomeXE]$ vi ~/.bash_profile
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/21c/dbhomeXE
ORACLE_SID=XE; export ORACLE_SID
export TNS_ADMIN=$ORACLE_BASE/homes/OraDBHome21cXE/network/admin
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLAsspATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLAsspATH
export PATH=${PATH}:$ORACLE_HOME/bin
[oracle@fedora dbhomeXE]$ . ~/.bash_profile
验证登录数据库
[oracle@fedora ~]$ sqlplus system/baby1234@xe
[oracle@fedora ~]$ sqlplus sys/baby1234@xe as sysdba
sql*Plus: Release 21.0.0.0.0 - Production on Fri Jul 29 11:10:45 2022
Version 21.3.0.0.0
copyright (c) 1982, 2021, Oracle. All rights reserved.
???:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
sql> exit
? Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0 ??
[oracle@fedora ~]$
关闭数据库和监听服务
[oracle@fedora ~]$ sqlplus / as sysdba
sql*Plus: Release 21.0.0.0.0 - Production on Fri Jul 29 11:13:39 2022
Version 21.3.0.0.0
copyright (c) 1982, 2021, Oracle. All rights reserved.
???:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
sql> shutdown immediate
????????
????????
ORACLE ???????
sql> exit
? Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0 ??
[oracle@fedora ~]$ lsnrctl stop
LSNRCTL for Linux: Version 21.0.0.0.0 - Production on 29-JUL-2022 11:14:01
copyright (c) 1991, 2021, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=fedora)(PORT=1521)))
The command completed successfully
[oracle@fedora ~]$
启动数据库和监听服务
此时,如果重启操作系统,oracle数据库服务器是不会随机启动的。
[oracle@fedora ~]$ sqlplus / as sysdba
sql*Plus: Release 21.0.0.0.0 - Production on Fri Jul 29 11:17:44 2022
Version 21.3.0.0.0
copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to an idle instance.
sql> startup
ORACLE instance started.
sql> exit
[oracle@fedora ~]$ lsnrctl start
LSNRCTL for Linux: Version 21.0.0.0.0 - Production on 29-JUL-2022 11:19:29
copyright (c) 1991, 2021, Oracle. All rights reserved.
Starting /opt/oracle/product/21c/dbhomeXE/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 21.0.0.0.0 - Production
System parameter file is /opt/oracle/homes/OraDBHome21cXE/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/fedora/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fedora)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=fedora)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 21.0.0.0.0 - Production
Start Date 29-JUL-2022 11:19:30
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /opt/oracle/homes/OraDBHome21cXE/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/fedora/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fedora)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
[oracle@fedora ~]$ sqlplus system/baby1234@XE
sql> select sysdate from dual;
SYSDATE
----------
29-7? -22
sql> exit
解决显示结果的乱码问题
登录数据库,查询字符集
sql> select userenv('language') from dual;
USERENV('LANGUAGE')
----------------------------------------------------
SIMPLIFIED CHInesE_CHINA.AL32UTF
该字符集的设置在“/etc/sysconfig/oracle-xe-21c.conf”中有配置。
修改操作系统的NLS_LANG的字符集配置
[oracle@fedora ~]$ export NLS_LANG="SIMPLIFIED CHInesE_CHINA.AL32UTF8"
验证字符集的显示结果
[oracle@fedora ~]$ sqlplus system/baby1234@XE
sql*Plus: Release 21.0.0.0.0 - Production on 星期五 7月 29 11:30:45 2022
Version 21.3.0.0.0
copyright (c) 1982, 2021, Oracle. All rights reserved.
上次成功登录时间: 星期五 7月 29 2022 11:26:52 +08:00
连接到:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
sql> select sysdate from dual;
SYSDATE
--------------
29-7月 -22
sql> exit
从 Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0 断开
[oracle@fedora ~]$
可以把上面的字符集设置,写入$HOME/.bash_profile中。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。