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<lang>.msb not found
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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/60aa2e31027a988a8eac2533a53e9f99.html