Oracle 将一台机器上的数据库注册到另一台机器的监听上(一)

2014-11-24 12:33:02 · 作者: · 浏览: 2
本文简单介绍一下把一台机器上的 数据库实例注册到另外一台机器上的步骤,比如把机器A的数据库实例注册到机器B.

1,在机器A注册到机器B之前查看一下机器B的listener的status,如下:

C:\Documents and Settings\Administrator>lsnrctl status

LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 16-JAN-2012 17:10:39

Copyright (c) 1991, 2005, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=147.151.240.89)(PORT=1521)))
STATUS of the LISTENER
------------------------
Services Summary...
Service "ORCL" has 2 instance(s).
Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl_XPT" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
现在还没有机器A的注册信息.
2,在机器A的tnsnames.ora中加入:

LISTENE_R =
(ADDRESS = (PROTOCOL = TCP)(HOST =147.151.240.89)(PORT = 1521))

3,修改机器A的remote_listener为第一步配置的LISTENE_R

SQL> alter system set remote_listener=LISTENE_R;
System altered.
4,查看机器B的listener的status如下:

C:\Documents and Settings\Administrator>lsnrctl status

LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 16-JAN-2012 17:27:35

Copyright (c) 1991, 2005, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=147.151.240.89)(PORT=1521)))
STATUS of the LISTENER
------------------------

Services Summary...
Service "ORCL" has 3 instance(s).
Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
Instance "orcl", status READY, has 1 handler(s) for this service...
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "ORCLTEST" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orclXDB" has 2 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl_XPT" has 2 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
可以看到机器A的数据库实例注册到机器B的监听上,机器A的db_name和service_name会注册到机器B的监听.

下面是在机器A上查看的信息:

SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- --------------
db_name string orcl
SQL> show parameter service_names;
NAME TYPE VALUE
------------------------------------ ----------- --------------
service_names string ORCLTEST

5,在机器B的tnsnames.ora里加上:

TESTDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcltest)
)
)

orcltest是从机器A注册到机器B的服务.

在机器B上通过sqlplus连接到机器A的数据库实例

C:\Documents and Settings\Administrator>sqlplus yorker