oracle用户怎么启动sqlplus,oracle linux实现自启动及sqlplus环境变量的设置,rlwrap的设置...

开机自启动ORACLE实现

使用/etc/rc.local系统开机启动脚本,启动oracle

配置系统使dbstart和dbshut脚本起作用:

1)、以root编辑/etc/oratab,类似

orcl:/u01/product/10.2.0/db_1:N

这种格式,其中orcl是你的ORACLE_SID,/u01/product/10.2.0/db_1是ORACLE_HOME,这里需要把N改为Y,

即orcl:/u01/product/10.2.0/db_1:Y这样。

2)、以oracle编辑$ORACLE_HOME/bin/dbstart,找到其中第78行:ORACLE_HOME_LISTNER=改为你自己的路径,或者可以改成ORACLE_HOME_LISTNER=$ORACLE_HOME

保存脚本,以oracle用户运行dbshut和dbstart看是否能关闭、启动数据库。如果不能,一般是参数设置,根据报错找到对应位置更改。

经过上一步的配置,可以直接用dbstart命令启动数据listener、instance、asm instances,但是还没有启动oracle10g的EM,ORACLE利用web页面管理数据库相当方便,也是10g的一个特色,所以应该一并启动起该服务来。

$ORACLE_HOME/bin/emctl start dbconsole

因此我们可以用rc.local或者redhat服务都可以实现要求的开机启动。下面分别说一下:

1)、利用rc.local。直接把dbstart加到rc.local中,实现开机自动启动。这里需要注意的是必须以oracle启动该脚本。

用root编辑/etc/rc.local,添加下面一行:

# This script. will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style. init stuff.

touch /var/lock/subsys/local

su - oracle -c "/boot/u01/app/oracle/product/11.2.0/bin/dbstart"(使用完整路径)

su - oracle -c "/boot/u01/app/oracle/product/11.2.0/bin/lsnrctl start"

su - oracle -c "/boot/u01/app/oracle/product/11.2.0/bin/emctl start dbconsole"

这里/boot/u01/app/oracle/product/11.2.0/需要替换成实际的ORACLE_HOME

保存并退出后,reboot服务器测试一下,可以看到,当系统启动以后oracle监听、实例和em都已经起来了[root@localhost ~]# su - oracle

-bash: [oracle=oracle]: command not found

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Jan 4 21:50:15 2002

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

2 sqlplus环境变量的设置

设置SQLPATH变量路径 找到用户概要文件login.sql

也可以使用glogin.sql

设置如下login.sql

set long 80

set newpage 0

set feedback on

set define on

set serveroutput on

set termout on

set time off

set timing on

set verify on

set linesize 80

set pagesize 30

set sqlprompt "_USER'@'_CONNECT_IDENTIFIER _DATE>"

alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';

3   rlwrap的回显功能

在用户的环境变量文件设置中添加            即 /home/oracle/.bash_profile

alias sqlplus="rlwrap sqlplus"

alias rman="rlwrap rman"

4  su - name 和 su name 的区别 自己观察

[root@localhost ~]# su - xpj

[xpj@localhost ~]$ su oracle

口令:

[oracle@localhost xpj]$ sqlplus / as sysdba

rlwrap: Cannot execute sqlplus: No such file or directory

[oracle@localhost xpj]$ exit

[xpj@localhost ~]$ su -  oracle

口令:

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Apr 3 14:17:35 2011

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Session altered.

Elapsed: 00:00:00.00

SYS@orcl 2011-04-03 14:17:35>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值