【監聽】兩庫互配靜態監聽

不一樣的天空w發表於2016-10-18

配置兩個庫互相訪問的靜態監聽

描述:

A庫:192.168.10.3 ORACLE_SID=PROD

B庫:192.168.10.2 ORACLE_SID=ORA11GR2

 

一:A庫操作配置B庫的靜態監聽:

——配置靜態監聽:

[oracle@bing ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/

[oracle@bing admin]$ ls

listener.ora  samples  shrept.lst  tnsnames.ora

[oracle@bing admin]$ vi listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = bing)(PORT = 1521))

    )

  )

 

ADR_BASE_LISTENER = /u01/app/oracle

 

 

SID_LIST_LISTENER=

   (SID_LIST=

     (SID_DESC=

       (GLOBAL_DBNAME=ORA11GR2)

       (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)

       (SID_NAME=ORA11GR2)

     )

    )

[oracle@bing admin]$

 

——重新停啟監聽是為了註冊剛剛建立的靜態監聽:

[oracle@bing admin]$ lsnrctl stop

 

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-OCT-2016 18:37:33

 

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

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bing)(PORT=1521)))

The command completed successfully

 [oracle@bing admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-OCT-2016 18:37:55

 

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

 

Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 11.2.0.4.0 - Production

System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Log messages written to /u01/app/oracle/diag/tnslsnr/bing/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bing)(PORT=1521)))

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bing)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date                18-OCT-2016 18:37:55

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/bing/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bing)(PORT=1521)))

Services Summary...

Service "ORA11GR2" has 1 instance(s).

  Instance "ORA11GR2", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

 

——過會再看監聽狀態,因為動態監聽註冊慢

 [oracle@bing admin]$ lsnrctl status

 

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-OCT-2016 18:39:54

 

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

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bing)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date                18-OCT-2016 18:37:55

Uptime                    0 days 0 hr. 1 min. 58 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/bing/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bing)(PORT=1521)))

Services Summary...

Service "ORA11GR2" has 1 instance(s).

  Instance "ORA11GR2", status UNKNOWN, has 1 handler(s) for this service...

Service "PROD" has 1 instance(s).

  Instance "PROD", status READY, has 1 handler(s) for this service...

Service "PRODXDB" has 1 instance(s).

  Instance "PROD", status READY, has 1 handler(s) for this service...

The command completed successfully

[oracle@bing admin]$

注:A庫本身我沒有配靜態監聽;

 

——配置A庫對B庫的靜態監聽的別名及告訴AB庫的地址,埠tcpservice_name[oracle@bing admin]$ vi tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

12 =

  (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.3)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = PROD)

    )

  )

 

22=

  (DESCRIPTION=

     (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.2)(PORT=1521))

    (CONNECT_DATA=

     (SERVER=DEDICATED)

     (SERVICE_NAME=ORA11GR2)

    )

  )

~

"tnsnames.ora" 23L, 496C written                                                                                  

[oracle@bing admin]$

 

——測試A庫對B庫的靜態監聽是否暢通:

[oracle@bing admin]$ tnsping 22

 

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 18-OCT-2016 15:08:29

 

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

 

Used parameter files:

 

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.2)(PORT=1521)) (CONNECT_DATA= (SERVER=DEDICATED) (SERVICE_NAME=ORA11GR2)))

OK (10 msec)

[oracle@bing admin]$

 

——從A庫進入B庫:

oracle@bing admin]$ sqlplus sys/oracle@22 as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Tue Oct 18 15:09:32 2016

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> show parameter name

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cell_offloadgroup_name               string

db_file_name_convert                 string

db_name                              string      ORA11GR2

db_unique_name                       string      ORA11GR2

global_names                         boolean     FALSE

instance_name                        string      ORA11GR2

lock_name_space                      string

log_file_name_convert                string

processor_group_name                 string

service_names                        string      ORA11GR2

 

二:B庫操作配置A庫的靜態監聽:

[oracle@wang ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/

[oracle@wang admin]$ ls

listener.ora  samples  shrept.lst  tnsnames.ora

 

——配置靜態監聽:(B庫本身有靜態監聽)

[oracle@wang admin]$ vi listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = wang)(PORT = 1521)))

  )

 

sid_list_listener=

  (sid_list=

    (sid_desc=

      (global_dbname=ORA11GR2)

      (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)

      (sid_name=ORA11GR2))

    (SID_DESC=

       (GLOBAL_DBNAME=PROD)

       (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)

       (SID_NAME=PORD))

    )

~

"listener.ora" 27L, 624C written

[oracle@wang admin]$

 

——重新停啟監聽是為了註冊剛剛建立的靜態監聽:

[oracle@wang admin]$ lsnrctl stop

 

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-OCT-2016 18:29:59

 

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

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=wang)(PORT=1521)))

The command completed successfully

[oracle@wang admin]$ lsnrctl start

 

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-OCT-2016 18:30:11

 

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

 

Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 11.2.0.4.0 - Production

System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Log messages written to /u01/app/oracle/diag/tnslsnr/wang/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wang)(PORT=1521)))

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=wang)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date                18-OCT-2016 18:30:11

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/wang/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wang)(PORT=1521)))

Services Summary...

Service "ORA11GR2" has 1 instance(s).

  Instance "ORA11GR2", status UNKNOWN, has 1 handler(s) for this service...

Service "PROD" has 1 instance(s).

  Instance "PORD", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

 

——過會再看監聽狀態,因為動態監聽註冊慢

[oracle@wang admin]$ lsnrctl status

 

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-OCT-2016 18:38:12

 

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

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=wang)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date                18-OCT-2016 18:30:11

Uptime                    0 days 0 hr. 8 min. 1 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/wang/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wang)(PORT=1521)))

Services Summary...

Service "ORA11GR2" has 2 instance(s).

  Instance "ORA11GR2", status UNKNOWN, has 1 handler(s) for this service...

  Instance "ORA11GR2", status READY, has 1 handler(s) for this service...

Service "ORA11GR2XDB" has 1 instance(s).

  Instance "ORA11GR2", status READY, has 1 handler(s) for this service...

Service "PROD" has 1 instance(s).

  Instance "PORD", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

[oracle@wang admin]$

 

——配置B庫對A庫的靜態監聽的別名及告訴BA庫的地址,埠,tcpservice_name[oracle@wang admin]$ vi tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

ORA11GR2 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = wang)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = ORA11GR2)

    )

  )

 

21=

  (DESCRIPTION=

    (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.3)(PORT=1521))

    (CONNECT_DATA=

      (SERVER=DEDICATED)

      (SERVICE_NAME=PROD)

    )

  )

~

"tnsnames.ora" 21L, 491C written                                                                                  

[oracle@wang admin]$

 

——測試B庫對A庫的靜態監聽是否暢通:

[oracle@wang admin]$ tnsping 21

 

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 18-OCT-2016 15:18:17

 

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

 

Used parameter files:

 

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.3)(PORT=1521)) (CONNECT_DATA= (SERVER=DEDICATED) (SERVICE_NAME=PROD)))

OK (20 msec)

 

——從B庫進入A庫:

[oracle@wang admin]$ sqlplus sys/oracle@21 as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Tue Oct 18 15:19:18 2016

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SYS@21>show parameter name

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cell_offloadgroup_name               string

db_file_name_convert                 string

db_name                              string      PROD

db_unique_name                       string      PROD

global_names                         boolean     FALSE

instance_name                        string      PROD

lock_name_space                      string

log_file_name_convert                string

processor_group_name                 string

service_names                        string      PROD

 

完成!!!!!!!!!!!!!!!!!!!!


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31397003/viewspace-2126659/,如需轉載,請註明出處,否則將追究法律責任。

相關文章