当前位置:  数据库>oracle

Oracle中su切换进去sqlplus登录失败的问题处理

    来源: 互联网  发布时间:2017-06-13

    本文导语: 问题描述:生产环境的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...

问题描述:
生产环境的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.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


#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)
    )
  )

Oracle学习笔记:sqlplus用户登录

sqlplus登录Oracle时ORA-01017: invalid username/password; logon denied的错误 

在CentOS 6.4下安装Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虚拟机中安装步骤

Debian 下 安装 Oracle 11g XE R2


    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • 在ubuntu10.04上安装oracle11g失败
  • jsp文件连接oracle失败
  • Oracle 11G SELinux原因启动失败的解决办法
  • linux 4虚拟机下安装oracle 10g失败。
  • 请教:为什么删除不掉?我用超级用户删除某一文件夹rm -R oracle失败。
  • 解决oracle用户连接失败的解决方法
  • SOS!!!环境:Tomcat4+Oracle8i;链接数据库失败,请各位大虾帮忙指正
  • Oracle用户密码含特殊字符时登陆失败问题
  • oracle客户端PLSQL连接失败解决方法
  • 安装Oracle失败后是否一定要重装系统
  • rh9下安装oracle9.2失败,(确切说是在install完毕后的配置里面),救命!
  • Oracle Dataguard备库失败与主库响应测试
  • Oracle 12c发布简单介绍及官方下载地址
  • 在linux下安装oracle,如何设置让oracle自动启动!也就是让oracle那个服务自动启动,不是手动的
  • oracle 11g最新版官方下载地址
  • 请问su oracle 和su - oracle有什么不同?
  • Oracle 数据库(oracle Database)Select 多表关联查询方式
  • 虚拟机装Oracle R12与Oracle10g
  • Oracle数据库(Oracle Database)体系结构及基本组成介绍
  • Oracle 数据库开发工具 Oracle SQL Developer
  • 如何设置让Oracle SQL Developer显示的时间包含时分秒
  • Oracle EBS R12 支持 Oracle Database 11g
  • Oracle 10g和Oracle 11g网格技术介绍
  • SCO unix下安装oracle,但没有光盘,请大家推荐一个oracle下载站点(unix版本的)。谢谢!!!!
  • oracle中如何把表中具有相同值列的多行数据合并成一行
  • 请问大家用oracle数据库, 用import oracle.*;下的东西么? 还是用标准库?
  • Oracle 数据库(oracle Database)性能调优技术详解
  • Linux /$ORACLE_HOME $ORACLE_HOME
  • ORACLE日期相关操作
  • Linux系统下Oracle的启动与Oracle监听的启动
  • ORACLE数据库常用字段数据类型介绍


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,