Oracle

oracle-xe (11g) 服務未掛載數據庫

  • January 29, 2018

幾天前我做了一個系統升級到fedora 27,從那以後oracle服務沒有正確啟動數據庫,我的意思是在執行之後:

sudo service oracle-xe start

數據庫仍然關閉。但是如果我以 oracle 使用者身份登錄然後執行 startdb.sql 的內容:

connect / as sysdba
startup
exit

一切正常。我認為問題是由一些錯誤配置引起的,但我不知道在哪裡看。

執行systemctl status oracle-xe只顯示數據庫沒有啟動:

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 21-JAN-2018 16:32:44

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
  Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
  Linux Error: 111: Connection refused

這是 journalctl 從 oracle-xe 服務的 start 方法報告的內容:

Jan 22 20:55:09 localhost.localdomain su[9121]: (to oracle) root on none
Jan 22 20:55:11 localhost.localdomain oracle-xe[9085]: ORACLE instance started.
Jan 22 20:55:11 localhost.localdomain oracle-xe[9085]: Total System Global Area 1068937216 bytes
Jan 22 20:55:11 localhost.localdomain oracle-xe[9085]: Fixed Size                    2233344 bytes
Jan 22 20:55:11 localhost.localdomain oracle-xe[9085]: Variable Size                  616565760 bytes
Jan 22 20:55:11 localhost.localdomain oracle-xe[9085]: Database Buffers          444596224 bytes
Jan 22 20:55:11 localhost.localdomain oracle-xe[9085]: Redo Buffers                    5541888 bytes
Jan 22 20:55:15 localhost.localdomain oracle-xe[9085]: Database mounted.
Jan 22 20:55:18 localhost.localdomain oracle-xe[9085]: Database opened.
Jan 22 20:55:18 localhost.localdomain systemd[1]: Started SYSV: This is a program that is responsible for taking care of.
Jan 22 21:22:56 localhost.localdomain systemd[1]: Stopping SYSV: This is a program that is responsible for taking care of...
Jan 22 21:22:56 localhost.localdomain oracle-xe[10575]: Shutting down Oracle Database 11g Express Edition instance.
Jan 22 21:22:57 localhost.localdomain oracle-xe[10575]: ORA-01034: ORACLE not available
Jan 22 21:22:57 localhost.localdomain oracle-xe[10575]: ORA-27101: shared memory realm does not exist
Jan 22 21:22:57 localhost.localdomain oracle-xe[10575]: Linux-x86_64 Error: 2: No such file or directory
Jan 22 21:22:57 localhost.localdomain oracle-xe[10575]: Stopping Oracle Net Listener.
Jan 22 21:22:57 localhost.localdomain oracle-xe[10575]: LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 22-JAN-2018 21:22:57
Jan 22 21:22:57 localhost.localdomain oracle-xe[10575]: Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Jan 22 21:22:57 localhost.localdomain oracle-xe[10575]: Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
Jan 22 21:22:58 localhost.localdomain oracle-xe[10575]: TNS-12541: TNS:no listener
Jan 22 21:22:58 localhost.localdomain oracle-xe[10575]:  TNS-12560: TNS:protocol adapter error
Jan 22 21:22:58 localhost.localdomain oracle-xe[10575]:   TNS-00511: No listener
Jan 22 21:22:58 localhost.localdomain oracle-xe[10575]:    Linux Error: 111: Connection refused
Jan 22 21:22:58 localhost.localdomain oracle-xe[10575]: Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
Jan 22 21:22:58 localhost.localdomain oracle-xe[10575]: TNS-12541: TNS:no listener
Jan 22 21:22:58 localhost.localdomain oracle-xe[10575]:  TNS-12560: TNS:protocol adapter error
Jan 22 21:22:58 localhost.localdomain oracle-xe[10575]:   TNS-00511: No listener
Jan 22 21:22:58 localhost.localdomain oracle-xe[10575]:    Linux Error: 111: Connection refused
Jan 22 21:22:58 localhost.localdomain systemd[1]: Stopped SYSV: This is a program that is responsible for taking care of.
Jan 22 21:22:58 localhost.localdomain systemd[1]: Starting SYSV: This is a program that is responsible for taking care of...
Jan 22 21:22:58 localhost.localdomain oracle-xe[10620]: Starting Oracle Net Listener.
Jan 22 21:22:58 localhost.localdomain su[10630]: (to oracle) root on none
Jan 22 21:22:58 localhost.localdomain oracle-xe[10620]: LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 22-JAN-2018 21:22:58
Jan 22 21:22:58 localhost.localdomain oracle-xe[10620]: Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]: Starting /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr: please wait...
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]: TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]: System parameter file is /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]: Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]: Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]: TNS-12555: TNS:permission denied
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]:  TNS-12560: TNS:protocol adapter error
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]:   TNS-00525: Insufficient privilege for operation
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]:    Linux Error: 1: Operation not permitted
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]: Listener failed to start. See the error message(s) above...
Jan 22 21:23:00 localhost.localdomain oracle-xe[10620]: Starting Oracle Database 11g Express Edition instance.
Jan 22 21:23:00 localhost.localdomain su[10655]: (to oracle) root on none
Jan 22 21:23:02 localhost.localdomain oracle-xe[10620]: ORACLE instance started.
Jan 22 21:23:02 localhost.localdomain oracle-xe[10620]: Total System Global Area 1068937216 bytes
Jan 22 21:23:02 localhost.localdomain oracle-xe[10620]: Fixed Size                    2233344 bytes
Jan 22 21:23:02 localhost.localdomain oracle-xe[10620]: Variable Size                  616565760 bytes
Jan 22 21:23:02 localhost.localdomain oracle-xe[10620]: Database Buffers          444596224 bytes
Jan 22 21:23:02 localhost.localdomain oracle-xe[10620]: Redo Buffers                    5541888 bytes
Jan 22 21:23:07 localhost.localdomain oracle-xe[10620]: Database mounted.
Jan 22 21:23:08 localhost.localdomain oracle-xe[10620]: Database opened.
Jan 22 21:23:08 localhost.localdomain systemd[1]: Started SYSV: This is a program that is responsible for taking care of.

如果我lsnrctl start在呼叫sudo service oracle-xe start數據庫後執行,就會再次活躍。

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 22-JAN-2018 21:22:58
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.2.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
TNS-12555: TNS:permission denied
TNS-12560: TNS:protocol adapter error
 TNS-00525: Insufficient privilege for operation
  Linux Error: 1: Operation not permitted
Listener failed to start. See the error message(s) above...

這通常是由於臨時位置的一些剩餘套接字文件具有錯誤的權限(例如,有人以 root 身份啟動了偵聽器)。關閉數據庫並刪除這些文件:

rm -rf /var/tmp/.oracle

然後再試一次。

引用自:https://dba.stackexchange.com/questions/195883