/u01/app/oracle/product/11.2.0/dbhome_1/ bin/dbstart 启动数据库实例(包含监听器)
u01/app/oracle/product/11.2.0/dbhome_1/ bin/dbshut 关闭数据库实例(包括监听器)
[oracle@localhost ~]$ vi /etc/oratab
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
myoracle:/u01/app/oracle/product/11.2.0/dbhome_1:N 改成Y
vi /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart
# First argument is used to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=$1 改掉
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
echo "Usage: $0 ORACLE_HOME"
else
LOG=$ORACLE_HOME_LISTNER/listener.log
# Set the ORACLE_HOME for the Oracle Net Listener, it gets reset to
# a different ORACLE_HOME for each entry in the oratab.
export ORACLE_HOME=$ORACLE_HOME_LISTNER
# Start Oracle Net Listener
if [ -x $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
echo "$0: Starting Oracle Net Listener" >> $LOG 2>&1
$ORACLE_HOME_LISTNER/bin/lsnrctl start >> $LOG 2>&1 &
VER10LIST=`$ORACLE_HOME_LISTNER/bin/lsnrctl version | grep "LSNRCTL for " | cut -d' ' -f5 | cut -d'.' -f1`
export VER10LIST
else
vi /u01/app/oracle/product/11.2.0/dbhome_2/bin/dbshut
将此处的 ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
case $ORACLE_TRACE in
T) set -x ;;
esac
# Set path if path not set (if called from /etc/rc)
SAVE_PATH=/bin:/usr/bin:/etc:${PATH} ; export PATH
SAVE_LLP=$LD_LIBRARY_PATH
# The this to bring down Oracle Net Listener
ORACLE_HOME_LISTNER=$1
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener"
echo "Usage: $0 ORACLE_HOME"
else
LOG=$ORACLE_HOME_LISTNER/listener.log
# Set the ORACLE_HOME for the Oracle Net Listener, it gets reset to
# a different ORACLE_HOME for each entry in the oratab.
export ORACLE_HOME=$ORACLE_HOME_LISTNER
# Stop Oracle Net Listener
if [ -f $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
echo "$0: Stoping Oracle Net Listener" >> $LOG 2>&1
用root用户在rc.local里添加如下内容:
[root@primary ~]# vi /etc/rc.d/rc.local
su oracle -lc "/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start"
su oracle -lc /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart
-l 表示同时切换用户目录。比如你要换到oracle用户下你的目录就同时在oracle目录下了。
-c则表示执行完命令好再返回到原来的用户。
[oracle@primary ~]$ ps -ef | grep tnslsnr 查看监听
[oracle@primary ~]$ ps -ef | grep -i "ora_" 查看oracle进程
[root@primary ~]# ps -efw | grep ora_ 查看oracle进程
oracle 4480 1 0 04:54 ? 00:00:00 ora_pmon_myoracle
oracle 4482 1 0 04:54 ? 00:00:00 ora_vktm_myoracle
oracle 4486 1 0 04:54 ? 00:00:00 ora_gen0_myoracle
oracle 4488 1 0 04:54 ? 00:00:00 ora_diag_myoracle
oracle 4490 1 0 04:54 ? 00:00:00 ora_dbrm_myoracle
oracle 4492 1 0 04:54 ? 00:00:00 ora_psp0_myoracle
oracle 4494 1 0 04:54 ? 00:00:00 ora_dia0_myoracle
oracle 4496 1 2 04:54 ? 00:00:04 ora_mman_myoracle
oracle 4498 1 0 04:54 ? 00:00:00 ora_dbw0_myoracle
oracle 4500 1 0 04:54 ? 00:00:00 ora_lgwr_myoracle
oracle 4502 1 0 04:54 ? 00:00:00 ora_ckpt_myoracle
oracle 4504 1 0 04:54 ? 00:00:00 ora_smon_myoracle
oracle 4506 1 0 04:54 ? 00:00:00 ora_reco_myoracle
oracle 4508 1 0 04:54 ? 00:00:01 ora_mmon_myoracle
oracle 4510 1 0 04:54 ? 00:00:00 ora_mmnl_myoracle
oracle 4514 1 0 04:54 ? 00:00:00 ora_s000_myoracle
oracle 4549 1 0 04:55 ? 00:00:00 ora_qmnc_myoracle
oracle 4740 1 0 04:55 ? 00:00:00 ora_q000_myoracle
oracle 4746 1 0 04:55 ? 00:00:00 ora_q001_myoracle
oracle 4751 1 0 04:55 ? 00:00:01 ora_cjq0_myoracle
oracle 5109 5108 0 04:57 ? 00:00:00 ora_d000_myoracle
root 5111 5084 0 04:57 pts/1 00:00:00 grep ora_
[root@primary ~]# ps -efw | grep LISTEN | grep -v grep 查看监听是否启动
oracle 4317 1 0 04:53 ? 00:00:00 /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr LISTENER -inherit
[oracle@primary ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 15-MAY-2015 04:58:59
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 15-MAY-2015 04:53:41
Uptime 0 days 0 hr. 5 min. 19 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/primary/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services Summary...
Service "myoracle" has 1 instance(s).
Instance "myoracle", status READY, has 1 handler(s) for this service...
The command completed successfully
/u01/app/oracle/product/11.2.0/dbhome_2/bin/dbstart: Starting up database "myoracle"
Mon Apr 27 08:40:56 PDT 2015
SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 27 08:41:03 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> Connected to an idle instance.
SQL> ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1336960 bytes
Variable Size 314575232 bytes
Database Buffers 100663296 bytes
Redo Buffers 6094848 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
/u01/app/oracle/product/11.2.0/dbhome_2/bin/dbstart: Database instance "myoracle" warm started.
[root@localhost dbhome_2]# cat listener.log 通过监听日志查看是否启动
/u01/app/oracle/product/11.2.0/dbhome_2/bin/dbstart: Starting Oracle Net Listener
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 27-APR-2015 08:40:51
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_2/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 27-APR-2015 08:40:55
Uptime 0 days 0 hr. 0 min. 4 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully
emctl start dbconsole
http://localhost.localdomain:1158/em
[oracle@localhost ~]$ lsnrctl status
[oracle@localhost ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 27-APR-2015 06:15:34
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_2/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 27-APR-2015 06:15:37
Uptime 0 days 0 hr. 0 min. 1 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully