ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle Net Service配置学习

Oracle Net Service配置学习

原创 Linux操作系统 作者:DandSuki 时间:2012-05-07 10:39:59 0 删除 编辑
 
在ORACLE Listener的动态和静态注册的时候有一点迷惑,查阅了一些资料后实验如下:
 
 
什么是动态注册?
用动态注册的时候,service 不需要列举在在listener.ora配置文件之中(在listner.ora的配置文件中这个listener不需要指明SID_LIST,-》这个是用来列举oracle service的)
动态注册是PMON进程来完成的,他将DB的信息提供给listener;
 
静态注册的话,则需要在SID_LIST模块中指明所需要注册的instance; 
 
 
默认的动态注册;
 
1: 清空了Listener.ora配置文件 
 
2: ./lsnrctl status
 
Listener Parameter File   /app/oracle/oracle/product/10.2.0/db_2/network/admin/listener.ora
Listener Log File         /app/oracle/oracle/product/10.2.0/db_2/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=GPPMCM04.asiapacific.hpqcorp.net)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "TEST2XDB.asiapacific.hpqcorp.net" has 1 instance(s).
  Instance "TEST2", status READY, has 1 handler(s) for this service...
Service "gppmcm04.asiapacific.hpqcorp.net" has 1 instance(s).
  Instance "TEST2", status READY, has 1 handler(s) for this service...
Service "gppmcm04_XPT.asiapacific.hpqcorp.net" has 1 instance(s).
  Instance "TEST2", status READY, has 1 handler(s) for this service...
The command completed successfully
从listener的status以及 service命令可以看到 ,默认的listener(TCP/IP with Local Home ,port 1521) 被PMON process自动的注册, 同时临听器的服务名和实例名是inti.ora文件中的参数service_names和instance_name,如果service_name没在init.ora文件中显示设置的话,service_name的默认值Global_DBName (db_name+'."+db_domain)
show parameters service_names;
show parameters instance_name;
 
这些自动注册的临听器状态是ready , 数据库实例是通过Local_Listener的参数去联系注册listenener的;Local_Listener的默认值 是 :
(ADDRESS = (PROTOCOL=TCP)(HOST=hostname)(PORT=1521)) where hostname is the network name of the local host.
所以在上述的例子中我们看到的是自动注册的service在默认的listener (TCP, LocalHost 1521端口);
在客户端用localnaming的方式配置tnsnames.ora文件,测试成功;
 
 
TEST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = gppmcm04.asiapacific.hpqcorp.net)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = gppmcm04.asiapacific.hpqcorp.net)
    )
  )
通过以上的实例表明,Listener可以在没有使用listener.ora的配置信息情况下启动并且处理客户端的请求;
 
 
 
如果要自动注册的临听器不是默认临听器,则需要在intia.ora的文件中改变LOCAL_LISTENER 的参数  ;

LOCAL_LISTENER specifies a network name that resolves to an address or address list of Oracle Net local listeners

 
Listener.ora 文件如下 (注意没有加SID_List_listener)
 
Note: 以前不太理解为什么动态注册非默认listener的时候,还是要在这定义listener,应为静态注册只是不需要加SID_LIST_LIStenername ,listener默认的是LISTENER,用LSNRCTL START命令启动的就是这个默认的LISTENER;
 
如果在listener.ora中配置了多个listener,如LISTENER1,要启动LISTENER1的话,就是明确的start listener1; 
 
 
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = GPPMCM04)(PORT = 1522))
  )
 
Listener启动后发现service没有注册,因为在这个时刻数据库仍然在联系1521端口上的listener; 
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=GPPMCM04.asiapacific.hpqcorp.net)(PORT=1522)))
The listener supports no services
The command completed successfully
要使instance注册到这个1522的listener上,我们要改变LOCAL_LISTENER的参数;
 
有两种方式:
 
1:直接改变LOCAL_LISTENER 指向非默认listener的location; 
 
alter system set local_listener='(ADDRESS = (PROTOCOL=TCP)(HOST=GPPMCM04.asiapacific.hpqcorp.net)(PORT=1522)))' scope=BOTH;
 
然后让PMON注册service
 
alter system register;
 
再检查一次listner,就可以看到注册成功!!
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=GPPMCM04.asiapacific.hpqcorp.net)(PORT=1522)))
Services Summary...
Service "TEST2XDB.asiapacific.hpqcorp.net" has 1 instance(s).
  Instance "TEST2", status READY, has 1 handler(s) for this service...
    Handler(s):
      "D000" established:0 refused:0 current:0 max:1022 state:ready
         DISPATCHER
         (ADDRESS=(PROTOCOL=tcp)(HOST=GPPMCM04.asiapacific.hpqcorp.net)(PORT=49400))
Service "gppmcm04.asiapacific.hpqcorp.net" has 1 instance(s).
  Instance "TEST2", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "gppmcm04_XPT.asiapacific.hpqcorp.net" has 1 instance(s).
  Instance "TEST2", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
The command completed successfully
  
2: 使用服务器的tnsnames文件,在tnsnames里面创建标识,然后local_listener指向此标识 ,在这种情况下实例就像一个客户端一样
 
TNSNAMES.ORA--和客户端的localnaming方式下的tnsnames不同,此处是不需要connect_data的, 因为这儿的只是locate listener; 
 
TOTO =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = GPPMCM04.asiapacific.hpqcorp.net)(PORT = 1522))
    )
 
  )
将Local_listener指向TOTO
 
alter system set local_listener='TOTO';
 
注册
 
alter system register;
 
 
再次检查
 
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=GPPMCM04.asiapacific.hpqcorp.net)(PORT=1522)))
Services Summary...
Service "TEST2XDB.asiapacific.hpqcorp.net" has 1 instance(s).
  Instance "TEST2", status READY, has 1 handler(s) for this service...
Service "gppmcm04.asiapacific.hpqcorp.net" has 1 instance(s).
  Instance "TEST2", status READY, has 1 handler(s) for this service...
Service "gppmcm04_XPT.asiapacific.hpqcorp.net" has 1 instance(s).
  Instance "TEST2", status READY, has 1 handler(s) for this service...
The command completed successfully
 
 
  附:
 
Service_names
 
service_name 是连接数据库里用的别名,在静态注册时
 
在使用动态注册时,sevice_name来源于init.ora参数文件,如:
 
设置service_names如下:
 
service_names                        string      Daisy
Note: 如果DB_Domain里设置了值 的话,service_names会被ORACLE自动的加上Db_domain的值 , 如果DB_DOMAIN没有设置的话,service_names不会变
 
service_name默认值是global database name(db_name+db_domain), 
 
检查listener可以看到:
service "Daisy.asiapacific.hpqcorp.net" has 1 instance(s).
 
Service "gppmcm04.asiapacific.hpqcorp.net" has 1 instance(s). (gppmcm01这一个service name不清楚 是不是因为这是一个默认的service name ?)
在此处,虽然我设置的SERVICE_names是Daisy,但是因为Db_domain的值是:
------------------------------------ ----------- ------------------------------
db_domain                            string      asiapacific.hpqcorp.net
所以ORACLE自动的将些DOMAIN加到了“Daisy"后成为 Daisy.asiapacific.hpqcorp.net
 
 
使用静态注册的时候;
 
SID_LIST 描述里有一个Global_DBNAME的选项(注意此处的不是我们上述提到的global database name , global database name是固定):
 
如配置以下的listener1:
LISTENER1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = GPPMCM04)(PORT = 1521))
  )
SID_LIST_LISTENER1 =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = Daisy2)
      (ORACLE_HOME = /app/oracle/oracle/product/10.2.0/db_2)
      (SID_NAME = TEST2)
    )
  )
service name就是来源自此静态注册中的Global_DBNAME;
 
 
 
Reference Link:
 
http://edstevensdba.wordpress.com/2011/07/30/exploring-the-local_listener-parameter/ 
 
 
 
 
 
 
 
 
 
 
 

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

下一篇: 在路上
请登录后发表评论 登录
全部评论

注册时间:2012-04-26

  • 博文量
    5
  • 访问量
    3244