su oracle 和 su - oracle的区别

一、症状


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

[sql]  view plain  copy
  1. [oracle@ltdit3 ~]$ ./startOracle.sh start  
  2. Starting Oracle:  
  3. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 27-JUN-2013 10:20:45  
  4.   
  5. Copyright (coffee) 1991, 2009, Oracle.  All rights reserved.  
  6.   
  7. TNS-01106: Listener using listener name LISTENER has already been started  
  8.   
  9. SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 27 10:20:45 2013  
  10.   
  11. Copyright (c) 1982, 2009, Oracle.  All rights reserved.  
  12.   
  13. SQL> Connected to an idle instance.  
  14. SQL> ORA-01078: failure in processing system parameters  
  15. LRM-00109: could not open parameter file '/opt/oracle/112/dbs/initorcaleexport.ora'  
  16. SQL> Disconnected  
  17. OK  


二、原因


注意其中这句话:

[sql]  view plain  copy
  1. SQL> ORA-01078: failure in processing system parameters  
  2. LRM-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登陆的,所以会设置环境变量,如果不加,使用的还是切换前用户的环境变量,所以会出错。


[sql]  view plain  copy
  1. [oracle@ltdit3 ~]$ su --help  
  2. Usage: su [OPTION]... [-] [USER [ARG]...]  
  3. Change the effective user id and group id to that of USER.  
  4.   
  5.   
  6.   -, -l, --login               make the shell a login shell  
  7.   -c, --command=COMMAND       pass a single COMMAND to the shell with -c  
  8.   --session-command=COMMAND    pass a single COMMAND to the shell with -c  
  9.                                and do not create a new session  
  10.   -f, --fast                   pass -f to the shell (for csh or tcsh)  
  11.   -m, --preserve-environment   do not reset environment variables  
  12.   -p                           same as -m  
  13.   -s, --shell=SHELL            run SHELL if /etc/shells allows it  
  14.       --help     display this help and exit  
  15.       --version  output version information and exit  
  16.   
  17.   
  18. A mere - implies -l.   If USER not given, assume root.  
  19.   
  20.   
  21. Report bugs to <bug-coreutils@gnu.org>.  
  22. [oracle@ltdit3 ~]$   


三、解决方法


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


四、总结


1、做事要细心。

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值