Windows 下 Oracle 服務通常隨作業系統自動啟動/關閉。若因強制終止進程導致服務異常,需透過命令列依序重置服務與監聽器:
C:\> net stop OracleService
-- 若提示「無法停止」,請先在工作管理員強制結束相關 oracle.exe 進程,再重試
C:\> net start OracleService
-- 服務啟動成功
C:\> lsnrctl stop
-- 停止監聽器
C:\> lsnrctl start
-- 啟動監聽器,提示「The command completed successfully」
C:\> sqlplus /nolog
SQL> CONNECT sys/password AS SYSDBA
-- 連線成功,資料庫實例已可用
關鍵點:OracleService 中的 SID 需替換為實際執行個體名稱(如 OracleServiceORCL)。
Linux 下需手動啟動監聽器與資料庫實例,標準流程如下:
[oracle@localhost ~]$ cd $ORACLE_HOME/bin
[oracle@localhost bin]$ lsnrctl
LSNRCTL> start
Starting /home/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
...
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
The command completed successfully
LSNRCTL> exit
[oracle@localhost bin]$ sqlplus /nolog
SQL> CONN / AS SYSDBA
Connected to an idle instance.
SQL> STARTUP
ORACLE instance started.
Total System Global Area 2147483648 bytes
...
Database mounted.
Database opened.
SQL> EXIT
SQL> SHUTDOWN IMMEDIATE
-- 等待完成
SQL> EXIT
[oracle@localhost bin]$ lsnrctl stop
| 操作 | Windows | Linux |
|---|---|---|
| 服務管理 | net start/stop OracleService | 透過 sqlplus 執行 STARTUP/SHUTDOWN |
| 監聽器控制 | lsnrctl start/stop | lsnrctl start/stop(指令相同) |
| 權限需求 | 系統管理員權限 | oracle 使用者與 dba 群組 |
| 環境變數 | 通常自動設定 | 需確認 ORACLE_HOME、ORACLE_SID、PATH |
listener.ora/tnsnames.ora 設定不符,請檢查 SID_NAME 與 SERVICE_NAME 一致性。oracle.exe 進程樹,再執行 net start。/etc/sysctl.conf 中 kernel.shmmax、kernel.shmall 設定。pmmon、smon、tnslsnr 進程存活狀態。