su oracle 和 su - oracle的区别

来源:互联网 发布:爱优软件 编辑:程序博客网 时间:2024/05/24 08:33

一、症状


在启动oracle数据库时,报了这个错:

[oracle@ltdit3 ~]$ ./startOracle.sh startStarting Oracle:LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 27-JUN-2013 10:20:45Copyright (coffee) 1991, 2009, Oracle.  All rights reserved.TNS-01106: Listener using listener name LISTENER has already been startedSQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 27 10:20:45 2013Copyright (c) 1982, 2009, Oracle.  All rights reserved.SQL> Connected to an idle instance.SQL> ORA-01078: failure in processing system parametersLRM-00109: could not open parameter file '/opt/oracle/112/dbs/initorcaleexport.ora'SQL> DisconnectedOK


二、原因


注意其中这句话:

SQL> ORA-01078: failure in processing system parametersLRM-00109: could not open parameter file '/opt/oracle/112/dbs/initorcaleexport.ora'


应该是找不到参数文件,但明明我的SID=orcl,并且已经设置了环境变量ORACLE_SID,为什么没生效呢?

还原启动过程,发现执行者用的是su oracle切换到oracle用户,查了一下资料,su oracle 和 su - oracle是有区别的:

-, -l ,--login make the shell a login shell

加了"-",是以login shell登陆的,所以会设置环境变量,如果不加,使用的还是切换前用户的环境变量,所以会出错。


[oracle@ltdit3 ~]$ su --helpUsage: su [OPTION]... [-] [USER [ARG]...]Change the effective user id and group id to that of USER.  -, -l, --login               make the shell a login shell  -c, --command=COMMAND       pass a single COMMAND to the shell with -c  --session-command=COMMAND    pass a single COMMAND to the shell with -c                               and do not create a new session  -f, --fast                   pass -f to the shell (for csh or tcsh)  -m, --preserve-environment   do not reset environment variables  -p                           same as -m  -s, --shell=SHELL            run SHELL if /etc/shells allows it      --help     display this help and exit      --version  output version information and exitA mere - implies -l.   If USER not given, assume root.Report bugs to <bug-coreutils@gnu.org>.[oracle@ltdit3 ~]$ 


三、解决方法


用su - oracle 取代 su oracle就可以了。


四、总结


1、做事要细心。

2、遇到问题多问一个为什么。

开始用户报错给我的时候,直接就在本地解决了,之后突发奇想,为什么用户那里会报错,过去看了一下,发现问题所在,就在一个“-”上,打了一下su --help,就知道加和不加的原因了。

原创粉丝点击