天天看點

12C cdb/pdb 配置監聽

1.
PDB is not an instance, so using SID in the connection string will not work.
When the database is an Oracle Database 12c container database, the client must specify a service name in order to connect to it. 
Listener status shows TEST as only a service :

監聽服務資訊應該如下“
Listener status shows TEST as only a service :

Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test.oracle.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
Services Summary...
Service "CDB1" has 1 instance(s).
Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "CDB1XDB" has 1 instance(s).
Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service.
Service "TEST" has 1 instance(s).
Instance "cdb1", status READY, has 1 handler(s) for this service...
The command completed successfully 



2.12C 不推薦靜态注冊,建議動态注冊

.動态注冊方法資訊如下:

To resolve this, make sure that you do the following:
1. Backup then edit the listener.ora file to REMOVE the "static" SID_DESC sections for these PDBs
2. Make sure the Database knows where to register by explicitly setting the LOCAL_LISTENER to any of the end points (addresses) that this listener is listening on.
 Within the PDB issue the following statement:      

alter session set container=PDB1;

alter system set listener_networks='(( NAME=listener)(LOCAL_LISTENER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle.com)(PORT=15021)))))' scope=spfile;      
3. Restart the Listener and db.

Always use Dynamic Services for connections. Do not use SID which is very old and obsolete with respect to how connections should be established or serviced.      
-》 靜态注冊方法資訊如下:
•Use of external procedure calls
•Use of Oracle Heterogeneous Services
•Use of Oracle Data Guard
•Remote database startup from a tool other than Oracle Enterprise Manager Cloud Control
•Connections to Oracle databases earlier than Oracle8i release 2 (8.1)

1、配置監聽

首先要明确,所有的PDB都使用1個監聽,配置多個實際上啟動時也隻有第1個有意義。

LISTENER=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =ora12c_A)(PORT = 1521))
  )


接下來使用SID_LIST_LISTENER來進行靜态注冊服務。
SID_LIST_LISTENER=
(SID_LIST=
  (SID_DESC =
  (GLOBAL_DBNAME = ora12c) #該服務是我配置的cdb資訊
  (SID_NAME = ora12c)
  )

  (SID_DESC =
  (GLOBAL_DBNAME = pdborcl)#該服務是我配置的pdb資訊
  (SID_NAME = ora12c)
  )
)

ADR_BASE_LISTENER= /opt/oracle

2、tnsnames.ora配置
觀察發現,在tnsnames中配置pdb跟CDB,即原來11g的配置完全一樣。這裡SERVICE_NAME = pdborcl使用得是PDB的名字,可以在v$pdbs中檢視。

ORA12C=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST =ora12c_A)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ora12c)
    )
  )

pdborcl=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST =ora12c_A)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = pdborcl)
    )
  )


3、為了保險,檢查下sqlnet.ora
NAMES.DIRECTORY_PATH=(TNSNAMES, EZCONNECT)
這一句是為了保證優先使用TNSNAMES解析。
配置完,在PDB啟動的情況下(怎麼啟動這裡不多講了),就可以直接連接配接到PDB了。(Oracle12c是沒有scott使用者的,我自己在PDB下面建立的)。      

炊煙起了;夕陽下了;細雨來了

多調試,互動式程式設計體驗

記錄,獨立思考,對比

感謝轉載作者

修車

國産化

read and connect

匍匐前進,

講故事