LDR LOCAL_LISTENER

  • Init parameter LOCAL_LISTENER points to a tnsnames.ora file entry.
    In our example, the TNS alias is:  LSNR_TNS
    Show parameter LOCAL_LISTENER shows the setting:  LISTENER
    The local tnsnames.ora file contains this entry.

LSNR_TNS =
(ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1522))

  • The server's IP address was changed to a new IP.  The local listener has been restarted on this new ip.
    So we also need to change our tnsnames entry for LISTENER so that the HOST field reflects the change:

LSNR_TNS=
(ADDRESS = (PROTOCOL = TCP)(HOST =)(PORT = 1522))

  • lsnrctl status shows that service name 'ora12' can not be registered to listener

LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 12.1.0.2.0 - Production
Start Date 10-OCT-2017 11:50:34
Uptime 0 days 1 hr. 6 min. 35 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File C:\app\product\12.1.0\dbhome_1\network\admin\listener.ora
Listener Log File C:\app\diag\tnslsnr\\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

CHANGES

 The IP address was changed on this server.  The listener has been been restarted so that it's running on the new IP address.

CAUSE

The content of init parameter local_listener was read from tnsnames.ora only when the database started.  It was stored in v$listener_network(X$KMMNV).

Changes in tnsnames.ora would not be reflected to v$listener_network automatically. 

So PMON still uses the old value in v$listener_network for dynamic service registration.

SQL> select type, value from v$listener_network where TYPE='LOCAL LISTENER';

TYPE
----------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
LOCAL LISTENER
(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522))

SOLUTION

To reflect the changes in tnsnames.ora, you need to set init parameter local_listener again with the same alias.

SQL> alter system set local_listener = 'LSNR_TNS' scope=both sid='INSTANCE_NAME';

System altered.

SQL> select type, value from v$listener_network where TYPE='LOCAL LISTENER';

TYPE
----------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
LOCAL LISTENER
(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522))

Alternatively, use the explicit address:

SQL>alter system set local_listener = "(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522))" scope=both sid='';

This time PMON could register the service name to listener.

alter system regiester;  用这个命令是不是不用重启

LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 12.1.0.2.0 - Production
Start Date 10-OCT-2017 11:50:34
Uptime 0 days 1 hr. 43 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File C:\app\product\12.1.0\dbhome_1\network\admin\listener.ora
Listener Log File C:\app\diag\tnslsnr\\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=)(PORT=5500))(Security=(my_wallet_directory=C:\APP\xdb_wal
let))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "" has 1 instance(s).                                              <----------  service name was registered
Instance "", status READY, has 1 handler(s) for this service...

Service "pdb" has 1 instance(s).
Instance "", status READY, has 1 handler(s) for this service...
The command completed successfully

You can also restart the instance as the changes in tnsnames.ora could be read into v$listener_network when instance starts.

-------------------------2-----------------

Generally there is no requirement to set LOCAL_LISTENER for a RAC One Node database  because whenever an instance is started, the CRS agent will automatically set the LOCAL_LISTENER parameter to the node VIP and the default Listener configured in the OCR.

In case anyone wants to explicitly set LOCAL_LISTENER for a RAC One Node database in the pfile or spfile, care needs to be taken to ensure the correct VIP is used when the RAC One Node database fails over or is relocated to a different node. Here is an example.

----这情况的原因是SCAN IP上启动了多个port   1522  1523 1524 但是这个特定的CDB只想启动一个1523 ,不想1521 1524 可以访问。  这种情况是不是只能VIP访问DB呢,scan ip访问DB会不会返回1521 或者 1524 给用户导致service name 不存在?

SOLUTION

Configuration

srvctl config database -d racone
Database unique name: racone
Database name: racone
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/racone/spfileracone.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: racone
Database instances:
Disk Groups: DATA
Mount point paths:
Services: raconesrv
Type: RACOneNode
Online relocation timeout: 30
Instance name prefix: racone
Candidate servers: rachost1,rachost2
Database is administrator managed
 

srvctl status database -d racone
Instance racone_1 is running on node rachost1
Online relocation: INACTIVE

The TNS alias for the LOCAL_LISTENER parameter needs to be added to the file $RDBMS_HOME/network/admin/tnsnames.ora on all cluster nodes to which the RAC One Node database can be relocated to. For example:

In tnsnames.ora (rachost1)

RACONE_LOCAL = (ADDRESS = (PROTOCOL = TCP)(HOST = rachost1-vip)(PORT = 1521))

In tnsnames.ora (rachost2)

RACONE_LOCAL = (ADDRESS = (PROTOCOL = TCP)(HOST = rachost2-vip)(PORT = 1521))

Please note that the same TNS alias name needs to used on all nodes but the value for the HOST parameter needs to be set to the node specific VIP name.

Adding the LOCAL_LISTENER entry to the spfile:

SQL> alter system set local_listener=RACONE_LOCAL scope=BOTH sid='*';

不要tnsnames.ora 直接写两个IP 也可以

SQL>alter system set local_listener = "(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522)),(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522))" scope=both sid='';

System altered.

SQL> show parameter listener

NAME                                      TYPE             VALUE
------------------------------------ ----------- ------------------------------
listener_networks                    string
local_listener                       string      RACONE_LOCAL
remote_listener                      string      rac-scan:1521

你可能感兴趣的:(数据库)