在 Linux 上启动 Oracle 数据库服务,通常是指启动 Oracle 实例(数据库) 和 监听(Listener)。下面按常见场景说明。
su - oracle
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
orcl替换为你的实际数据库名
lsnrctl start
查看状态:
lsnrctl status
sqlplus / as sysdba
进入 SQL*Plus 后:
startup;
正常输出类似:
ORACLE instance started.
Database mounted.
Database opened.
退出:
exit;
shutdown immediate;
Oracle 提供脚本:
dbstart $ORACLE_HOME
需在 /etc/oratab 中设置为:
orcl:/u01/app/oracle/product/19.3.0/dbhome_1:Y
/etc/orataborcl:/u01/app/oracle/product/19.3.0/dbhome_1:Y
vi /etc/systemd/system/oracle.service
内容示例:
[Unit]
Description=Oracle Database
After=network.target
[Service]
User=oracle
Type=forking
ExecStart=/u01/app/oracle/product/19.3.0/dbhome_1/bin/dbstart /u01/app/oracle/product/19.3.0/dbhome_1
ExecStop=/u01/app/oracle/product/19.3.0/dbhome_1/bin/dbshut /u01/app/oracle/product/19.3.0/dbhome_1
[Install]
WantedBy=multi-user.target
启用:
systemctl enable oracle
systemctl start oracle
❌ command not found
→ 环境变量没设置或没切到 oracle 用户
❌ ORA-01034
→ 数据库没启动
❌ 监听启动但连不上
→ 检查 listener.ora 和 tnsnames.ora
如果你告诉我:
我可以给你更精确的启动命令。