Oracle一些比较常用的命令(持续更新)-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

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

方法一:登录时会显示版本号
[oracle@ogg1 ~]$ sqlplus / as sysdba       #有时直接输入 #sqlplus
SQL*Plus: Release 11.2.0.3.0 Production on 骀涓 7?20 17:51:14 2015
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
方法二:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production


用sysdba身份登录 比如 conn /as  sysdba 匿名管理员登陆
  
查看SID
1.用sysdba身份登录 比如 conn /as  sysdba
2.select instance_name from v$instance;
 
查看用户名
select * from dba_users; --查看数据库里面所有用户,前提是你是有dba权限的帐号,如sys,system
select * from all_users;  --查看你能管理的所有用户!
select * from user_users; --查看当前用户信息 !

-------------------------------------------------------------------------------------------
[oracle@redhat4 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 06-OCT-2015 21:10:05
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                06-OCT-2015 19:45:16
Uptime                    0 days 1 hr. 24 min. 49 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/redhat4/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat4.7)(PORT=1521)))
Services Summary...
Service "ora11g" has 1 instance(s).
  Instance "ora11g", status READY, has 1 handler(s) for this service...
Service "ora11gXDB" has 1 instance(s).
  Instance "ora11g", status READY, has 1 handler(s) for this service...
Service "orcl.7" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.7" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@redhat4 ~]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 06-OCT-2015 21:10:14
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[oracle@redhat4 ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 06-OCT-2015 21:10:26
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/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_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/redhat4/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat4.7)(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                06-OCT-2015 21:10:26
Uptime                    0 days 0 hr. 0 min. 0 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/redhat4/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat4.7)(PORT=1521)))
The listener supports no services
The command completed successfully

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

创新互联建站是专业的江门网站建设公司,江门接单;提供网站设计制作、成都网站设计,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行江门网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

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

lsnrctl命令常用参数详解:

lsnrctl
start
启动指定的监听器

stop
关闭指定的监听器

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

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

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 for Linux: 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”, status READY, has 2 handler(s) for this service…
Service “pod_XPT” has 1 instance(s).
Instance “POD”, status READY, has 1 handler(s) for this service…
Service “repos” has 2 instance(s).
Instance “repos”, status UNKNOWN, has 1 handler(s) for this service…
Instance “repos”, status READY, has 1 handler(s) for this service…
Service “repos_XPT” has 1 instance(s).
Instance “repos”, status READY, 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”, status READY, has 1 handler(s) for this service…

#此处说明有一个服务名POD的服务,数据库实例名为POD,状态READY说明其目前处于动态注册
Service “POD1” has 1 instance(s).
Instance “POD”, status UNKNOWN, has 1 handler(s) for this service…

#此处说明有一个服务名为POD1的服务,数据库的实例名为POD,状态UNKNOWN说明其目前是静态注册
Service “PODS” has 1 instance(s).
Instance “POD”, status READY, has 2 handler(s) for this service…

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

 

Service “repos” has 2 instance(s).
Instance “repos”, status UNKNOWN, has 1 handler(s) for this service…
Instance “repos”, status READY, has 1 handler(s) for this service…
The command completed successfully

#此处说明有一个服务名为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”, status READY, has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0 state:ready
LOCAL SERVER
Service “POD1” has 1 instance(s).
Instance “POD”, status UNKNOWN, has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0
LOCAL SERVER
Service “PODS” has 1 instance(s).
Instance “POD”, status READY, has 2 handler(s) for this service…
Handler(s):
“D001” established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=37290))
“D000” established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=37288))
Service “pod_XPT” has 1 instance(s).
Instance “POD”, status READY, 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”, status UNKNOWN, has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0
LOCAL SERVER
Instance “repos”, status READY, 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”, status READY, 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”, status READY, has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0 state:ready
LOCAL SERVER

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

DEDICATED” established:0 refused:0 state:ready说明是专有连接,连接数为0拒绝数为0,状态:动态
Service “POD1” has 1 instance(s).
Instance “POD”, status UNKNOWN, 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”, status READY, has 2 handler(s) for this service…
Handler(s):
“D001” established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=37290))
“D000” established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER
(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> alter system set 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

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

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

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


新闻名称:Oracle一些比较常用的命令(持续更新)
URL链接:http://kswsj.cn/article/gjdiop.html

其他资讯