oracle监听

[oracle@aa ~]$ cd /oracle/db/network/admin/
[oracle@aa admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora
[oracle@aa admin]$ mv listener.ora listener.ora.bak
[oracle@aa admin]$ mv tnsnames.ora tnsnames.ora.bak


服务端配置监听,接受人家的连接
[oracle@aa admin]$ vim listener.ora     
# listener.ora Network Configuration File: /oracle/db/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /oracle/db)
      (SID_NAME = ORCL)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = bill)
      (ORACLE_HOME = /oracle/db)
      (SID_NAME = BILL)
    )
  )

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = aa.ly.com)(PORT = 1521))
  )


客户端连接其他服务器,则需要配置

[oracle@aa admin]$ vim tnsnames.ora

# tnsnames.ora Network Configuration File: /oracle/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

o100 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.100)(PORT = 1521))
    )
    (CONNECT_DATA =
       (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

o83 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.83)(PORT = 1521))
    )
    (CONNECT_DATA =
       (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

o180 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.180)(PORT = 1521))
    )
    (CONNECT_DATA =
       (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
teacher =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.213)(PORT = 1521))
    )
    (CONNECT_DATA =
       (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

 


[oracle@aa ~]$ lsnrctl start   服务端启动监听还要启动实例

 

=============================================================
动态监听和静态监听

动态监听就是把本机的实例写入tnsnames.ora。tnsnames.ora还可以当作客户端访问服务端的配置文件。如果写的是本机的实例,就是动态监听本地。如果写的是远端的服务器,就是访问服务端的配置文件。监听的状态如果连接上就是ready,断开连接就是unknow

静态监听就是把本机的实例写入listener.ora.状态一直是unknow.


一个连接要服务端要配置listener.ora,并且开启监听。客户端配置tnsnames.ora好之后,就可以访问了。

看监听的情况对不对,要考虑三个原因。
1.IP地址与主机名是否对应。
2.监听文件是否填写正确。
3.服务端是否开启了监听和实例,以供客户端访问。

 

 

你可能感兴趣的:(oracle,监听)