oracle动态注册和静态注册的区别:动态监听不需要在listener.ora文件中记录关于数据的任何信息,只需要将监听器的配置信息写入到该文件。例如:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS=(PROTOCOL = IPC) (KEY=EXTPRO1))
(ADDRESS=(PROTOCOL = TCP)(HOST = 192.168.2.29)(PORT = 1521))
)
)
客户端的tnsnames.ora配置信息,需要加入每个service_name,其他的任何东西不需要改动,例如
YUCESHI1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.29)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test1)
)
)
YUCESHI2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.29)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test2)
)
)
YUCESH3 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.29)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test3)
)
)
动态监听步骤:
服务器端配置如下:
- 设置service_names:
alter system set service_names=test1,test2,test3;
2. 编写listener.ora文件:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS=(PROTOCOL = IPC) (KEY=EXTPRO1))
(ADDRESS=(PROTOCOL = TCP)(HOST = 192.168.2.29)(PORT = 1521))
)
)
3.重新启动oracle实例,这样做才能使service_names生效。(前提是oracle处于open状态下才执行)
conn /as sysdba;
shutdown immediate;
startup;
客户端配置:
1.编辑tnsnames.ora,保存后立即生效。
YUCESHI1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.29)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test1)
)
)
YUCESHI2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.29)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test2)
)
)
YUCESH3 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.29)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test3)
)
)
以上动态注册配置完毕。以上改为静态注册步骤。
1.只需要在服务器端修改listener.ora配置文件。并且多几个SID_DESC就行了。
配置如下:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS=(PROTOCOL = IPC) (KEY=EXTPRO1))
(ADDRESS=(PROTOCOL = TCP)(HOST = 192.168.2.29)(PORT = 1521))
)
)
##上面是监听器配置部分,下面是数据库配置部分
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME = /opt/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl )
)
(SID_DESC =
(GLOBAL_DBNAME = test2)
(ORACLE_HOME = /opt/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl )
)
(SID_DESC =
(GLOBAL_DBNAME = test3)
(ORACLE_HOME = /opt/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl )
)
)
2.重新启动监听:
su - oracle
lsnrctl stop
lsnrctl start
配置完成