RHEL裝完oracle 11g後遇到的問題

  • 2019 年 10 月 5 日
  • 筆記

1.運行sqlplus,提示

  1. sqlplus: error while loading shared libraries: /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so.11.1: cannot restore segment prot after reloc: Permission denied

這個問題是由於SELINUX引起的。 解決辦法:

編輯/etc/sysconfig/selinux配置文件, 把SELINUX=enforcing 改為 SELINUX=disabled。

  1. # This file controls the state of SELinux on the system.
  2. # SELINUX= can take one of these three values:
  3. # enforcing – SELinux security policy is enforced.
  4. # permissive – SELinux prints warnings instead of enforcing.
  5. # disabled – SELinux is fully disabled.
  6. #SELINUX=enforcing
  7. SELINUX=disabled
  8. # SELINUXTYPE= type of policy in use. Possible values are:
  9. # targeted – Only targeted network daemons are protected.
  10. # strict – Full SELinux protection.
  11. SELINUXTYPE=targeted

保存後重啟系統。

2.用sqlplus,輸入用戶名密碼後,提示:

  1. Enter user-name: system
  2. Enter password:
  3. ERROR:
  4. ORA-01034: ORACLE not available
  5. ORA-27101: shared memory realm does not exist
  6. Linux Error: 2: No such file or directory
  7. Process ID: 0
  8. Session ID: 0 Serial number: 0

原因竟然是oracle沒有啟動成功,用sqlplus '/as sysdba'命令,然後輸入startup來啟動oracle,但發現啟動oracle時報錯:

  1. [oracle@localhost dbs]$ sqlplus '/as sysdba'
  2. SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 25 14:49:49 2012
  3. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  4. Connected to an idle instance.
  5. SQL> startup
  6. ORA-01078: failure in processing system parameters
  7. LRM-00109: could not open parameter file '/u01/app/oracle/dbs/initliusuping.ora'

繼續baigoogledu,這次是百度給了答案:

  1. [oracle@localhost oracle]$ find /u01 -name pfile
  2. /u01/app/admin/orcl/pfile
  3. [oracle@localhost oracle]$ cd /u01/app/admin/orcl/pfile
  4. [oracle@localhost pfile]$ ls
  5. init.ora.5252012131333
  6. [oracle@localhost pfile]$ cp init.ora.5252012131333 /u01/app/oracle/dbs/initliusuping.ora

即找到另外一個ora文件,然後把它複製到/u01/app/oracle/dbs下面,並重命名為initliusuping.ora。靠,為什麼我的sid是liusuping?我裝oracle的時候貌似沒看到有設置sid的地方啊,怎麼給默認這個了。

再次startup,數據庫終於起來了:

  1. [oracle@localhost pfile]$ sqlplus '/as sysdba'
  2. SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 25 15:13:00 2012
  3. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  4. Connected to an idle instance.
  5. SQL> startup
  6. ORACLE instance started.
  7. Total System Global Area 602619904 bytes
  8. Fixed Size 1338168 bytes
  9. Variable Size 360711368 bytes
  10. Database Buffers 234881024 bytes
  11. Redo Buffers 5689344 bytes
  12. Database mounted.
  13. Database opened.

不知道liusuping是怎麼來的,自己建一個庫吧。進入/u01/app/oracle/bin,輸入.dbca,打開管理界面,在這裡可以刪除、創建數據庫。我們創建一個sid為test的數據庫:

3.用客戶端連它,連不上,"沒有監聽程序"。

打開/u01/app/oracle/network/admin/listener.ora,它的內容如下:

  1. # listener.ora Network Configuration File: /u01/app/oracle/network/admin/listener.ora
  2. # Generated by Oracle configuration tools.
  3. LISTENER =
  4. (DESCRIPTION_LIST =
  5. (DESCRIPTION =
  6. (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  7. (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
  8. )
  9. )
  10. ADR_BASE_LISTENER = /u01/app

把它改為:

  1. # listener.ora Network Configuration File: /u01/app/oracle/network/admin/listener.ora
  2. # Generated by Oracle configuration tools.
  3. SID_LIST_LISTENER =
  4. (SID_LIST =
  5. (SID_DESC =
  6. (GLOBAL_DBNAME = test)
  7. (ORACLE_HOME = /u01/app/oracle)
  8. (SID_NAME =test)
  9. )
  10. )
  11. LISTENER =
  12. (DESCRIPTION_LIST =
  13. (DESCRIPTION =
  14. (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  15. (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.199)(PORT = 1521))
  16. )
  17. )
  18. ADR_BASE_LISTENER = /u01/app

然後運行lsnrctl start,結果如下:

  1. [oracle@localhost admin]$ lsnrctl start
  2. LSNRCTL for Linux: Version 11.2.0.1.0 – Production on 25-JUN-2012 18:04:25
  3. Copyright (c) 1991, 2009, Oracle. All rights reserved.
  4. Starting /u01/app/oracle/bin/tnslsnr: please wait…
  5. TNSLSNR for Linux: Version 11.2.0.1.0 – Production
  6. System parameter file is /u01/app/oracle/network/admin/listener.ora
  7. Log messages written to /u01/app/diag/tnslsnr/localhost/listener/alert/log.xml
  8. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  9. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.199)(PORT=1521)))
  10. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
  11. STATUS of the LISTENER
  12. ————————
  13. Alias LISTENER
  14. Version TNSLSNR for Linux: Version 11.2.0.1.0 – Production
  15. Start Date 25-JUN-2012 18:04:25
  16. Uptime 0 days 0 hr. 0 min. 0 sec
  17. Trace Level off
  18. Security ON: Local OS Authentication
  19. SNMP OFF
  20. Listener Parameter File /u01/app/oracle/network/admin/listener.ora
  21. Listener Log File /u01/app/diag/tnslsnr/localhost/listener/alert/log.xml
  22. Listening Endpoints Summary…
  23. (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  24. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.199)(PORT=1521)))
  25. Services Summary…
  26. Service "test" has 1 instance(s).
  27. Instance "test", status UNKNOWN, has 1 handler(s) for this service…
  28. The command completed successfully

然後在用客戶端鏈接一下:

終於連上去了。。。