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

php中文网
发布: 2016-06-07 16:33:34
原创
2750人浏览过

生产环境的Oracle数据库突然登录不上去了,rlwrap生产环境的oracle数据库突然登录不上去了,rlwrap sqlplus / as sysdba报错如

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

灵光
灵光

蚂蚁集团推出的全模态AI助手

灵光 1635
查看详情 灵光

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

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号