Oracle一些比较常用的命令(持续更新)

前端之家收集整理的这篇文章主要介绍了Oracle一些比较常用的命令(持续更新)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
方法一:登录时会显示版本号
[oracle@ogg1~]$sqlplus/assysdba#有时直接输入#sqlplus
sql*Plus:Release11.2.0.3.0Productionon骀涓7?2017:51:142015
Copyright(c)1982,2011,Oracle.Allrightsreserved.
方法二:
sql>select*fromv$version;
BANNER
--------------------------------------------------------------------------------
OracleDatabase11gEnterpriseEditionRelease11.2.0.3.0-64bitProduction
PL/sqlRelease11.2.0.3.0-Production
CORE11.2.0.3.0Production
TNSforLinux:Version11.2.0.3.0-Production
NLSRTLVersion11.2.0.3.0-Production


用sysdba身份登录比如conn/assysdba匿名管理员登陆

查看SID
1.用sysdba身份登录比如conn/assysdba
2.selectinstance_namefromv$instance;

查看用户名
select*fromdba_users;--查看数据库里面所有用户,前提是你是有dba权限的帐号,如sys,system
select*fromall_users;--查看你能管理的所有用户!
select*fromuser_users;--查看当前用户信息!

-------------------------------------------------------------------------------------------
[oracle@redhat4~]$lsnrctlstatus
LSNRCTLforLinux:Version11.2.0.1.0-Productionon06-OCT-201521:10:05
Copyright(c)1991,2009,Oracle.Allrightsreserved.
Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUSoftheLISTENER
------------------------
AliasLISTENER
VersionTNSLSNRforLinux:Version11.2.0.1.0-Production
StartDate06-OCT-201519:45:16
Uptime0days1hr.24min.49sec
TraceLeveloff
SecurityON:LocalOSAuthentication
SNMPOFF
ListenerParameterFile/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
ListenerLogFile/u01/app/oracle/diag/tnslsnr/redhat4/listener/alert/log.xml
ListeningEndpointsSummary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat4.7)(PORT=1521)))
ServicesSummary...
Service"ora11g"has1instance(s).
Instance"ora11g",statusREADY,has1handler(s)forthisservice...
Service"ora11gXDB"has1instance(s).
Instance"ora11g",has1handler(s)forthisservice...
Service"orcl.7"has1instance(s).
Instance"orcl",has1handler(s)forthisservice...
Service"orclXDB.7"has1instance(s).
Instance"orcl",has1handler(s)forthisservice...
Thecommandcompletedsuccessfully
[oracle@redhat4~]$lsnrctlstop
LSNRCTLforLinux:Version11.2.0.1.0-Productionon06-OCT-201521:10:14
Copyright(c)1991,Oracle.Allrightsreserved.
Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Thecommandcompletedsuccessfully
[oracle@redhat4~]$lsnrctlstart
LSNRCTLforLinux:Version11.2.0.1.0-Productionon06-OCT-201521:10:26
Copyright(c)1991,Oracle.Allrightsreserved.
Starting/u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr:pleasewait...
TNSLSNRforLinux:Version11.2.0.1.0-Production
Systemparameterfileis/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Logmessageswrittento/u01/app/oracle/diag/tnslsnr/redhat4/listener/alert/log.xml
Listeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat4.7)(PORT=1521)))
Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUSoftheLISTENER
------------------------
AliasLISTENER
VersionTNSLSNRforLinux:Version11.2.0.1.0-Production
StartDate06-OCT-201521:10:26
Uptime0days0hr.0min.0sec
TraceLeveloff
SecurityON:LocalOSAuthentication
SNMPOFF
ListenerParameterFile/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
ListenerLogFile/u01/app/oracle/diag/tnslsnr/redhat4/listener/alert/log.xml
ListeningEndpointsSummary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat4.7)(PORT=1521)))
Thelistenersupportsnoservices
Thecommandcompletedsuccessfully

-------------------------------------------------------------------------

(总结)Oracle监听服务lsnrctl参数及查询状态详解

lsnrctl命令常用参数详解:

lsnrctl
start
启动指定的监听器

stop
关闭指定的监听器

status
显示监听器的状态。status命令显示监听器是不是活动的,日志与跟踪文件的位置,监听器已经持续运行了多长时间,以及监听器所监听的任务。如下图所示:

services
列举监听器的服务信息,比如这些服务是否有任何专用的预生成服务器进程或与之相关的调度进程,以及每个服务已有多少连接被接受或拒绝。这种方法用来检查一个监听器是否在监听一个指定服务。
列出服务的一个汇总表及为每个协议服务处理程序所建立和拒绝的连接信息个数。

Version
显示oracle net软件与协议适配器的版本。

reload
重新装入监听器,重新读取listener.ora文件,但不关闭监听器。如果该文件发生了变化,重新刷新监听器。

save_config
当从lsnrctl工具中对listener.ora文件进行了修改时,复制一个叫做listener.bak的listener.ora的文件

trace
打开监听器的跟踪特性。

change_password
允许用户修改关闭监听器所需要的密码。

quit
退出lsnrctl工具。

exit
退出lsnrctl工具。

set*
password
指定在lsnrctl命令行工具中执行管理任务所需要的密码。

rawmode
displaymode
trc_file
指定监听器跟踪信息的位置。默认设置是$ORACLE_HOME\network\trace\listener.trc

trc_directory
trc_level
跟踪级别
OFF – 未启用跟踪功能。OFF 为默认设置。
USER – 将跟踪设置为用户的相应级别。跟踪以标识用户导致的错误条件。
ADMIN – 将跟踪设置为数据库管理员的相应级别。跟踪以标识特定的安装问题。
SUPPORT – 将跟踪设置为客户支持人员的相应级别。 跟踪文件可能会变得很大。
Oracle Corporation 建议在不进行网络问题诊断时关闭跟踪功能

log_file
指定一个监听器将把日志信息写到哪里。这个参数在默认的情况下是ON,并默认为%oracle_home%\network\log\listener.log

log_directory
log_status
current_listener
inbound_connect_timeout
定义监听器在一个会话得到启动时将等待的有效响应时间。默认设置为10秒。

startup_waittime
定义监听器在响应lsnrctl命令行工具中的一条status命令之前将等待多长时间。

save_config_on_stop
指定在一个lsnrctl会话期内所发生的修改退出时是否应该被保存起来。

show*
rawmode
显示关于status和service的较详细信息(当他们设置成on时)值为ON或OFF。

displaymode
把lsnrctl工具的显示模式设置成raw、compact、normal或verbose
服务显示模式为NORMAL

rules
trc_file
指定监听器跟踪信息的位置。默认设置是$ORACLE_HOME\network\trace\listener.trc

current_listener
目前的监听器为 listener2
inbound_connect_timeout
定义监听器在一个会话得到启动时将等待的有效响应时间。默认设置为10秒。

startup_waittime
定义监听器在响应lsnrctl命令行工具中的一条status命令之前将等待多长时间。

snmp_visible
save_config_on_stop
指定在一个lsnrctl会话期内所发生的修改退出时是否应该被保存起来。

lsnrctl部分查询状态详解:

LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle.domain)(PORT=1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR forLinux: Version 10.2.0.1.0 – Production
Start Date 17-MAY-2011 21:03:40
Uptime 0 days 0 hr. 2 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/10.2.1/db/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2.1/db/network/log/listener.log
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1600)))
Services Summary…
Service “POD” has 1 instance(s).
Instance “POD”,status READY,has 1 handler(s) for this service…
Service “POD1” has 1 instance(s).
Instance “POD”,status UNKNOWN,has 1 handler(s) for this service…
Service “PODS” has 1 instance(s).
Instance “POD”,has 2 handler(s) for this service…
Service “pod_XPT” has 1 instance(s).
Instance “POD”,has 1 handler(s) for this service…
Service “repos” has 2 instance(s).
Instance “repos”,has 1 handler(s) for this service…
Instance “repos”,has 1 handler(s) for this service…
Service “repos_XPT” has 1 instance(s).
Instance “repos”,has 1 handler(s) for this service…
The command completed successfully

status详解

Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1600)))

#此处说明该主机地址为ocm1.oracle.domain,开启的监听端口有1521,1522,1600


Services Summary…
Service “POD” has 1 instance(s).
Instance “POD”,has 1 handler(s) for this service…

#此处说明有一个服务名POD的服务,数据库实例名为POD,状态READY说明其目前处于动态注册
Service “POD1” has 1 instance(s).
Instance “POD”,0); font-family: georgia; font-size: 15px; white-space: normal;">#此处说明有一个服务名为POD1的服务,数据库的实例名为POD,状态UNKNOWN说明其目前是静态注册
Service “PODS” has 1 instance(s).
Instance “POD”,has 2 handler(s) for this service…

#此处说明有一个服务名为PODS的服务,数据库实例名为POD,状态READY说明其是动态注册

Service “repos” has 2 instance(s).
Instance “repos”,0); font-family: georgia; font-size: 15px; white-space: normal;">#此处说明有一个服务名为repos的服务,对应数据库实例为repos,UNKNOWN,READY状态说明其目前有一个静态注册和一个动态注册

LSNRCTL> services
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle.domain)(PORT=1521)))
Services Summary…
Service “POD” has 1 instance(s).
Instance “POD”,has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0 state:ready
LOCALSERVER
Service “POD1” has 1 instance(s).
Instance “POD”,has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0
LOCAL SERVER
Service “PODS” has 1 instance(s).
Instance “POD”,has 2 handler(s) for this service…
Handler(s):
“D001” established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER <machine: ocm1.oracle.domain,pid: 28400>
(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=37290))
“D000” established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER <machine: ocm1.oracle.domain,pid: 28398>
(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=37288))
Service “pod_XPT” has 1 instance(s).
Instance “POD”,has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0 state:ready
LOCAL SERVER
Service “repos” has 2 instance(s).
Instance “repos”,has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0
LOCAL SERVER
Instance “repos”,has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0 state:ready
LOCAL SERVER
Service “repos_XPT” has 1 instance(s).
Instance “repos”,has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0 state:ready
LOCAL SERVER
The command completed successfully

service详解

Service “POD” has 1 instance(s).
Instance “POD”,has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0 state:ready
LOCAL SERVER

#名为POD的服务,对应数据库实例为POD,状态READY说明其处于动态注册

DEDICATED” established:0refused:0 state:ready说明是专有连接,连接数为0拒绝数为0,状态:动态
Service “POD1” has 1 instance(s).
Instance “POD”,has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0
LOCAL SERVER

#名为POD1的服务,对应数据库实例为POD,状态UNKNOWN说明其处于静态注册

DEDICATED” established:2 refused:0说明是专有连接,连接数为2拒绝数为0
Service “PODS” has 1 instance(s).
Instance “POD”,pid: 28398>
(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=37288))

#名为PODS的服务,对应数据库实例名为POD的数据库,READY状态说明其为动态注册

“D001” established:0 refused:0 current:0 max:1022 state:ready

“D000” established:0 refused:0 current:0 max:1022 state:ready

这里说明其为share模式,目前,两个dispatcher目前都连接为0,拒绝为0,最大数为1022,状态是动态注册

——————————————————————————————————————————————————————

对应SQL查询

sql> show parameter dispatchers

NAME TYPE VALUE
———————————— ———– ——————————
dispatchers string
max_dispatchers integer
sql> altersystemset dispatchers='(protocol=tcp) (dispatchers=2)’;System altered.sql> show parameter dispatchersNAME TYPE VALUE
———————————— ———– ——————————
dispatchers string (protocol=tcp) (dispatchers=2)
max_dispatchers integersql> select name,network,paddr,status from v$dispatcher;NAME NETWORK PADDR STATUS
—- ——————————————————————————– ——– —————-
D000 (ADDRESS=(PROTOCOL=tcp)(HOST=seagull)(PORT=37288)) 2A220390 WAIT
D001 (ADDRESS=(PROTOCOL=tcp)(HOST=seagull)(PORT=37290)) 2A220948 WAIT

#repos服务对应的实例有2个,但此处都为实例repos,一个为静态UNKNOWN,一个为动态READY,目前连接数都为0,拒绝也为0The command completed successfully

原文链接:https://www.f2er.com/oracle/206355.html

猜你在找的Oracle相关文章