ITPub博客

首页 > 数据库 > Oracle > ORACLE中查询客户端和服务器主机和IP信息

ORACLE中查询客户端和服务器主机和IP信息

原创 Oracle 作者:bluesshadow 时间:2016-09-20 16:10:24 0 删除 编辑
查看数据库版本
SQL> col host_name for a30
select instance_name,host_name,version,status,logins,database_status from v$instance;

INSTANCE_NAME    HOST_NAME                      VERSION           STATUS       LOGINS     DATABASE_STATUS
---------------- ------------------------------ ----------------- ------------ ---------- -----------------
racdb1           node1                          11.2.0.4.0        OPEN         ALLOWED    ACTIVE



在数据库服务器上查看客户端主机信息:
--查看单机:
set linesize 300
col machine for a24
col username for a24
select sid,serial#,username,machine,program from v$session where username not in('SYS','SYSTEM','SYSMAN');
       SID    SERIAL# USERNAME                       MACHINE                        PROGRAM
---------- ---------- ------------------------------ ------------------------------ ------------------------------------------------
        24       7455 DBSNMP                         node1                          JDBC Thin Client
        28      13593 DBSNMP                         em12c                          OMS
       151      23631 DBSNMP                         node1                          JDBC Thin Client
       152      36521 TUSER                          node1                          sqlplus@node1 (TNS V1-V3)

--查看集群:       
set linesize 300
col machine for a24
col username for a24       
select inst_id,sid,serial#,username,machine,program from gv$session where username not in('SYS','SYSTEM','SYSMAN');       
  INST_ID        SID    SERIAL# USERNAME                 MACHINE                  PROGRAM
---------- ---------- ---------- ------------------------ ------------------------ ------------------------------------------------
         1         24       7455 DBSNMP                   node1                    JDBC Thin Client
         1         28      13593 DBSNMP                   em12c                    OMS
         1        151      23631 DBSNMP                   node1                    JDBC Thin Client
         1        152      36521 TUSER                    node1                    sqlplus@node1 (TNS V1-V3)
         1        154      62831 TUSER                    node1                    oracle@node1 (PZ99)
         2         31      20161 DBSNMP                   node2                    JDBC Thin Client
         2        148      13685 TUSER                    node1                    oracle@node2 (PZ99)
         2        151      20871 DBSNMP                   node2                    JDBC Thin Client
         
在客户端查看数据库服务器主机信息:
UTL_INADDR.GET_HOST_NAME                --通过IP获取主机名  
UTL_INADDR.GET_HOST_ADDRESS            --通过主机获取IP               

--客户端查询所连接到的服务器的IP:
SQL> select utl_inaddr.get_host_address from dual;

GET_HOST_ADDRESS
--------------------------------------------------------------------------------
192.168.10.21

通过主机名查询IP信息:
SQL> select utl_inaddr.get_host_address() from dual;

UTL_INADDR.GET_HOST_ADDRESS()
--------------------------------------------------------------------------------
192.168.10.21

SQL> select utl_inaddr.get_host_address('node1') from dual;

UTL_INADDR.GET_HOST_ADDRESS('NODE1')
--------------------------------------------------------------------------------
192.168.10.21

SQL> select utl_inaddr.get_host_address('node2') from dual;

UTL_INADDR.GET_HOST_ADDRESS('NODE2')
--------------------------------------------------------------------------------
192.168.10.22

SQL> select utl_inaddr.get_host_address('em12c') from dual;

UTL_INADDR.GET_HOST_ADDRESS('EM12C')
--------------------------------------------------------------------------------
192.168.10.28

--通过IP查询主机信息:
SQL> select utl_inaddr.get_host_name('192.168.10.28') from dual;

UTL_INADDR.GET_HOST_NAME('192.168.10.28')
--------------------------------------------------------------------------------
em12c

SQL> select utl_inaddr.get_host_name('192.168.10.22') from dual;

UTL_INADDR.GET_HOST_NAME('192.168.10.22')
--------------------------------------------------------------------------------
node2

SQL> select utl_inaddr.get_host_name('192.168.10.21') from dual;

UTL_INADDR.GET_HOST_NAME('192.168.10.21')
--------------------------------------------------------------------------------
node1

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24668589/viewspace-2125214/,如需转载,请注明出处,否则将追究法律责任。

下一篇: RHEL6 NFS配置
请登录后发表评论 登录
全部评论

注册时间:2010-09-27

  • 博文量
    34
  • 访问量
    139564