目标机已配置CentOS yum源码。
[root@localhost ~]# adduser oracle [root@localhost ~]# passwd oracle [root@localhost ~]# su - oracle
文件列表:
[oracle@localhost ~]$ ll -rw-r--r-- 1 oracle oracle 2694664264 2月 16 15:16 oracle-database-ee-19c-1.0-1.x86_64.rpm -rw-r--r-- 1 oracle oracle 18204 2月 16 15:27 oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
安装preinstall包:
[oracle@localhost ~]$ sudo yum -y install ./oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
安装oracle数据库:
[oracle@localhost ~]$ sudo yum -y install ./oracle-database-ee-19c-1.0-1.x86_64.rpm ... [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 ...
根据提示,需要使用root用户初始化数据库:
[root@localhost ~]# /etc/init.d/oracledb_ORCLCDB-19c configure Configuring Oracle Database ORCLCDB. 准备执行数据库操作 已完成 8% 复制数据库文件 已完成 31% 正在创建并启动 Oracle 实例 已完成 32% 已完成 36% 已完成 40% 已完成 43% 已完成 46% 正在进行数据库创建 已完成 51% 已完成 54% 正在创建插接式数据库 已完成 58% 已完成 77% 执行配置后操作 已完成 100% 数据库创建完成。有关详细信息, 请查看以下位置的日志文件: /opt/oracle/cfgtoollogs/dbca/ORCLCDB。 数据库信息: 全局数据库名:ORCLCDB 系统标识符 (SID):ORCLCDB 有关详细信息, 请参阅日志文件 "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log"。 Database configuration completed successfully. The passwords were auto generated, you must change them by connecting to the database using 'sqlplus / as sysdba' as the oracle user.
使用oracle账户登录:
[oracle@localhost ~]$ sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Thu Feb 17 14:32:33 2022 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle. All rights reserved. Connected to an idle instance. SQL>
准备服务脚本:
[root@localhost ~]# vim /etc/init.d/oracle #!/bin/bash #chkconfig:345 61 61 #description:Apache # # Set ORA_HOME to be equivalent to the $ORACLE_HOME # from which you wish to execute dbstart and dbshut; # # Set ORA_OWNER to the user id of the owner of the # Oracle database in ORA_HOME. ORA_HOME=/opt/oracle/product/19c/dbhome_1 ORA_OWNER=oracle if [ ! -f $ORA_HOME/bin/dbstart ] then echo "Oracle startup: cannot start" exit fi case "$1" in 'start') # Start the Oracle databases: echo "Starting Oracle Databases ... " echo "-------------------------------------------------" date +" %T %a %D : Starting Oracle Databases as part of system up." echo "-------------------------------------------------" su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" echo "Done" # Start the Listener: echo "Starting Oracle Listeners ... " echo "-------------------------------------------------" date +" %T %a %D : Starting Oracle Listeners as part of system up." echo "-------------------------------------------------" su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" echo "Done." echo "-------------------------------------------------" date +" %T %a %D : Finished." echo "-------------------------------------------------" touch /var/lock/subsys/oracle ;; 'stop') # Stop the Oracle Listener: echo "Stoping Oracle Listeners ... " echo "-------------------------------------------------" date +" %T %a %D : Stoping Oracle Listener as part of system down." echo "-------------------------------------------------" su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" echo "Done." rm -f /var/lock/subsys/oracle # Stop the Oracle Database: echo "Stoping Oracle Databases ... " echo "-------------------------------------------------" date +" %T %a %D : Stoping Oracle Databases as part of system down." echo "-------------------------------------------------" su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" echo "Done." echo "" echo "-------------------------------------------------" date +" %T %a %D : Finished." echo "-------------------------------------------------" ;; 'restart') $0 stop $0 start ;; esac
这样,以后可以通过service命令启停Oracle服务了:
[root@localhost ~]# service oracle start [root@localhost ~]# service oracle stop
如果实例未启动,您可以使用以下命令启动实例:
STARTUP;