Oracle中su切換進去sqlplus登入失敗的問題處理
問題描述:
生產環境的oracle資料庫突然登入不上去了,rlwrap生產環境的oracle資料庫突然登入不上去了,rlwrap sqlplus "/ as sysdba"報錯如下:rlwrap
[oracle@localhost root]$ rlwrap sqlplus "/ as sysdba"
rlwrap: warning: your $TERM is 'xterm' but rlwrap couldn't find it in the terminfo database. Expect some problems.
rlwrap: Cannot execute sqlplus: Permission denied
[oracle@localhost root]$ sqlplus "/ as sysdba"
bash: sqlplus: command not found
[oracle@localhost root]$
1,oracle登入報錯
[oracle@localhost root]$ rlwrap sqlplus "/ as sysdba"
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
[oracle@localhost root]$
[oracle@localhost root]$
2,檢視ORACLE_HOME變數,為空值
[oracle@localhost root]$ echo $ORACLE_HOME
[oracle@localhost root]$
3,在/etc/profile設定ORACLE_HOME變數
[root@localhost ~]# vim /etc/profile
export ORACLE_HOME=/opt/oracle/app/oracle/product/11.2.0/dbhome_1
[root@localhost ~]# source /etc/profile
[root@localhost ~]# su oracle
[oracle@localhost root]$
[oracle@localhost root]$ echo $ORACLE_HOME
/oracle/app/oracle/product/11.2.0/dbhome_1/
[oracle@localhost root]$
4,ORACLE_HOME環境變數有值了,再去用sqlplus登入一下,試試看
[oracle@localhost root]$ rlwrap sqlplus "/ as sysdba"
rlwrap: warning: your $TERM is 'xterm' but rlwrap couldn't find it in the terminfo database. Expect some problems.
rlwrap: Cannot execute sqlplus: Permission denied
[oracle@localhost root]$
5,做一下sqlplus的軟連線
[oracle@localhost root]$ exit
exit
[root@localhost ~]# ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
[root@localhost ~]# su oracle
[oracle@localhost root]$ sqlplus "/ as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jan 16 10:19:39 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
[oracle@localhost root]$
[oracle@localhost root]$ echo $ORACLE_SID
[oracle@localhost root]$
系統環境變數裡面沒有ORACLE_SID
6,設定ORACLE_SID
[oracle@localhost root]$ exit
exit
[root@localhost ~]# vim /etc/profile
export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=pxxerxxs
[root@localhost ~]# source /etc/profile
[oracle@localhost root]$ exit
exit
[root@localhost ~]# vim /etc/profile
[root@localhost ~]# source /etc/profile
[root@localhost ~]# su oracle
[oracle@localhost root]$ rlwrap sqlplus "/ as sysdba"
rlwrap: warning: your $TERM is 'xterm' but rlwrap couldn't find it in the terminfo database. Expect some problems.
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jan 16 10:25:33 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL>
SQL>
SQL>
7,去oracle使用者下檢視系統變數
[oracle@localhost root]$ cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
#added for oracle
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=pxxerxxs
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME/bin
[oracle@localhost root]$
配置裡面有值,問題在哪裡?
8,su的時候有差異
不加-的話的話只是切換使用者 不去更換使用者的配置,加上-後 再去sqlplus 試試
[oracle@localhost ~]$ exit
logout
[root@localhost ~]# su oracle
[oracle@localhost root]$ echo $ORACLE_BASE
[oracle@localhost root]$ exit
exit
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ echo $ORACLE_BASE
/oracle/app/oracle
[oracle@localhost ~]$
9,驗證下su - oracle
[oracle@localhost ~]$ rlwrap sqlplus "/ as sysdba"
rlwrap: warning: your $TERM is 'xterm' but rlwrap couldn't find it in the terminfo database. Expect some problems.
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jan 16 10:36:51 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL>
10,OK,嘗試使用非sys賬號登入報錯
[oracle@localhost ~]$ rlwrap sqlplus "plas_prd/plrd_1628@pxxerxxs as sysdba"
rlwrap: warning: your $TERM is 'xterm' but rlwrap couldn't find it in the terminfo database. Expect some problems.
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jan 16 16:53:11 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied
Enter user-name:
[oracle@localhost ~]$
11,去check下,tnsping pxxerxxs 能否成功
[oracle@localhost ~]$ tnsping pxxerxxs
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 16-JAN-2015 16:53:27
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
TNS-03505: Failed to resolve name
[oracle@localhost ~]$
tnsping失敗,得知pxxerxxs這個失效
12,去找tnsnames.ora
[oracle@localhost admin]$ more /oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
也可以more $ORACLE_HOME/network/admin/tnsnames.ora
找到
MPMD2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.110.107)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME= pxxerxxs)
)
)
然後用非sys使用者登入
[oracle@localhost ~]$ rlwrap sqlplus "pxxerxxsk/pa141215@MPMD2"
rlwrap: warning: your $TERM is 'xterm' but rlwrap couldn't find it in the terminfo database. Expect some problems.
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jan 16 20:30:30 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL>
OK登入顯示成功。
總結,
(1)linux系統裡面,su切換到oracle使用者的時候,加上-就會更換oracle使用者單獨配置生效,如果不加-就不會使用oracle使用者單獨的配置。
(2)在使用sqlplus登入的時候,用非sys使用者登入,@後面的是$ORACLE_HOME/network/admin/tnsnames.ora定義的那個字首符號MPMD2,而不是SERVICE_NAME所指的oracle_sid,tnsnames.ora中MPMD2字首定義如下所示
MPMD2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.110.101)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME= pxxerxxs)
)
)
----------------------------------------------------------------------------------------------------------------
有,文章允許轉載,但必須以連結方式註明源地址,否則追究法律責任!>
原部落格地址: http://blog.itpub.net/26230597/viewspace-1404602/
原作者:黃杉 (mchdba)
----------------------------------------------------------------------------------------------------------------
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26230597/viewspace-1404602/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Mac openssl 未找到 / 載入失敗問題處理Mac
- 啟用系統登入失敗處理功能
- SSH 登入失敗:Host key verification failed 的處理方法AI
- selinux導致sqlplus登入失敗LinuxSQL
- oracle對JOB失敗的處理Oracle
- laravel社會化登入 iframe微信網頁登入失敗的問題Laravel網頁
- ssh登入慢問題處理
- linux swap掛載失敗問題處理Linux
- python+selenium切換彈框的iframe框架失敗處理方法Python框架
- oracle schedule 任務失敗處理Oracle
- vs 中“包載入失敗”問題【轉】
- gitment 登入失敗Git
- Oracle DG同步失敗故障處理(二)Oracle
- 某省ORACLE10G RAC資料庫CRS啟動失敗問題處理Oracle資料庫
- Service Worker 圖片載入失敗處理
- 【問題處理】“sqlplus / as sysdba”無法登陸——多餘的斜槓!SQL
- js登陸三次失敗問題JS
- Oracle_dg歸檔丟失問題處理Oracle
- Ubuntu中fcitx安裝失敗問題,及軟體換源問題Ubuntu
- Oracle全部索引丟失導致的效率問題處理Oracle索引
- Aix 7一次補丁安裝失敗問題處理AI
- Gaussdb: CN修復失敗對openssl版本依賴問題處理
- svn dump 失敗後的處理
- Linux mint系統安裝出現grub2安裝失敗,開機進入grub問題處理Linux
- 探討寶塔切換php版本切換失敗的原因和解決方法PHP
- 【問題處理】使用trim和 replace處理字串中的換行符號字串符號
- 使用strace診斷奇怪的sqlplus登入問題SQL
- 整合手機平臺待辦資料失敗問題跟蹤和處理(Mongodb、Oracle、SQLServer)MongoDBOracleSQLServer
- postgresql登入失敗怎麼辦SQL
- docker login 登入harbor失敗Docker
- SQL登入失敗注意事項SQL
- oracle DG VCS切換異常問題Oracle
- SQLServer執行儲存過程失敗(sys.xp_cmdshell)問題處理SQLServer儲存過程
- Oracle資料庫中的逐行處理問題NEOracle資料庫
- native 切換 webview 失敗,求大神協助WebView
- 如何對專案中的問題進行分析——FPGA失敗案例小結FPGA
- postgresql連線失敗如何處理SQL
- 標籤 圖片載入失敗時候處理方案