一、在Linux下启动Oracle
1.登录到Linux服务器,切换到oracle用户权限(命令是:# su –l oracle)
[oracle@localhost ~]$ sqlplus / as sysdba --进入sqlplus界面
2.进入sqlplus界面(命令是:$ sqlplus /nolog 或 sqlplus / as sysdba)
原本的画面会变为
SQL>
接着请输入
SQL>conn / as sysdba ;
输入
SQL> startup --(作用:启动数据库实例)
另外停止数据库的指令如下:
SQL> shutdown immediate
[oracle@localhost ~]$ sqlplus / as sysdba --进入sqlplus界面SQL*Plus: Release 11.2.0.1.0 Production on Thu Mar 17 10:48:08 2022Copyright © 1982, 2009, Oracle. All rights reserved.Connected to an idle instance.SQL> quitDisconnected[oracle@localhost ~]$ sqlplus /nolog --进入sqlplus界面SQL*Plus: Release 11.2.0.1.0 Production on Thu Mar 17 10:48:42 2022Copyright © 1982, 2009, Oracle. All rights reserved.SQL> conn / as sysdba --sysdba登录Connected to an idle instance.SQL> startup --启动数据库实例ORACLE instance started.Total System Global Area 1068937216 bytesFixed Size 2220200 bytesVariable Size 281022296 bytesDatabase Buffers 780140544 bytesRedo Buffers 5554176 bytesDatabase mounted.Database opened.SQL> shutdown immediate --关闭数据库实例Database closed.Database dismounted.ORACLE instance shut down.SQL>quit --退出
二、检查Oracle 数据库是否启动
回到终端机模式,输入:ps -ef|grep ora_ (作用是:查看是否有Oracle的进程,如果有,大多数情况说明启动了。)
[oracle@localhost ~]$ ps -ef|grep ora_oracle 12193 1 0 11:00 ? 00:00:00 ora_pmon_orcloracle 12195 1 0 11:00 ? 00:00:00 ora_vktm_orcloracle 12199 1 0 11:00 ? 00:00:00 ora_gen0_orcloracle 12201 1 0 11:00 ? 00:00:00 ora_diag_orcloracle 12203 1 0 11:00 ? 00:00:00 ora_dbrm_orcloracle 12205 1 0 11:00 ? 00:00:00 ora_psp0_orcloracle 12207 1 0 11:00 ? 00:00:00 ora_dia0_orcloracle 12209 1 0 11:00 ? 00:00:00 ora_mman_orcloracle 12211 1 0 11:00 ? 00:00:00 ora_dbw0_orcloracle 12213 1 0 11:00 ? 00:00:00 ora_lgwr_orcloracle 12215 1 0 11:00 ? 00:00:00 ora_ckpt_orcloracle 12217 1 0 11:00 ? 00:00:00 ora_smon_orcloracle 12219 1 0 11:00 ? 00:00:00 ora_reco_orcloracle 12221 1 0 11:00 ? 00:00:00 ora_mmon_orcloracle 12223 1 0 11:00 ? 00:00:00 ora_mmnl_orcloracle 12225 1 0 11:00 ? 00:00:00 ora_d000_orcloracle 12227 1 0 11:00 ? 00:00:00 ora_s000_orcloracle 12239 1 0 11:00 ? 00:00:00 ora_qmnc_orcloracle 12257 1 0 11:00 ? 00:00:00 ora_cjq0_orcloracle 12277 1 0 11:00 ? 00:00:00 ora_q000_orcloracle 12279 1 0 11:00 ? 00:00:00 ora_q001_orcloracle 12389 10058 0 11:01 pts/0 00:00:00 grep --color=auto ora_[oracle@localhost ~]$
三、检查Oracle DB监听器是否正常
输入:$ lsnrctl status (作用是:检查监听是否启动。) 以下为没有启动。
[oracle@localhost ~]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 17-MAR-2022 11:03:33Copyright © 1991, 2009, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))TNS-12541: TNS:no listenerTNS-12560: TNS:protocol adapter errorTNS-00511: No listenerLinux Error: 2: No such file or directoryConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))TNS-12541: TNS:no listenerTNS-12560: TNS:protocol adapter errorTNS-00511: No listenerLinux Error: 111: Connection refused[oracle@localhost ~]$ ^C[oracle@localhost ~]$
如果没有启动,可以输入:$ lsnrctl start (作用是:启动监听器)
[oracle@localhost ~]$ lsnrctl startLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 17-MAR-2022 11:04:48Copyright © 1991, 2009, Oracle. All rights reserved.Starting /data/oracle/product/11.2.0/bin/tnslsnr: please wait…TNSLSNR for Linux: Version 11.2.0.1.0 - ProductionSystem parameter file is /data/oracle/product/11.2.0/network/admin/listener.oraLog messages written to /data/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening 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 LISTENERAlias LISTENERVersion TNSLSNR for Linux: Version 11.2.0.1.0 - ProductionStart Date 17-MAR-2022 11:04:48Uptime 0 days 0 hr. 0 min. 0 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /data/oracle/product/11.2.0/network/admin/listener.oraListener Log File /data/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary…(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))The listener supports no servicesThe command completed successfully[oracle@localhost ~]$
另外停止监听的指令如下:
$ lsnrctl stop