演示一下12c中关于pdb的listener register,unregister问题
[oracle@db-42 ~]$ lsnrctl status listener1 LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 09-AUG-2013 14:53:56 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db-42)(PORT=1523))) STATUS of the LISTENER ------------------------ Alias listener1 Version TNSLSNR for Linux: Version 12.1.0.1.0 - Production Start Date 08-AUG-2013 21:04:57 Uptime 0 days 17 hr. 48 min. 58 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /data/app2/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File /data/app2/oracle/diag/tnslsnr/db-42/listener1/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db-42)(PORT=1523))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1523))) Services Summary... Service "testcdb" has 1 instance(s). Instance "testcdb", status READY, has 1 handler(s) for this service... Service "testcdbXDB" has 1 instance(s). Instance "testcdb", status READY, has 1 handler(s) for this service... The command completed successfully
——注册pdb到listener1
[oracle@db-42 ~]$ ora si SQL*Plus: Release 12.1.0.1.0 Production on Fri Aug 9 14:54:20 2013 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> desc v$pdbs; Name Null? Type ----------------------------------------- -------- ---------------------------- CON_ID NUMBER DBID NUMBER CON_UID NUMBER GUID RAW(16) NAME VARCHAR2(30) OPEN_MODE VARCHAR2(10) RESTRICTED VARCHAR2(3) OPEN_TIME TIMESTAMP(3) CREATE_SCN NUMBER TOTAL_SIZE NUMBER SQL> select con_id,name from v$pdbs; CON_ID NAME ---------- ------------------------------ 2 PDB$SEED 3 CON_CDB_NEW SQL> alter session set container=CON_CDB_NEW; Session altered. SQL> exec dbms_service.start_service('CON_CDB_NEW'); PL/SQL procedure successfully completed. SQL> !lsnrctl status listener1 LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 09-AUG-2013 14:55:35 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db-42)(PORT=1523))) STATUS of the LISTENER ------------------------ Alias listener1 Version TNSLSNR for Linux: Version 12.1.0.1.0 - Production Start Date 08-AUG-2013 21:04:57 Uptime 0 days 17 hr. 50 min. 37 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /data/app2/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File /data/app2/oracle/diag/tnslsnr/db-42/listener1/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db-42)(PORT=1523))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1523))) Services Summary... Service "con_cdb_new" has 1 instance(s). ------------------> new pdb service register in listener Instance "testcdb", status READY, has 1 handler(s) for this service... Service "testcdb" has 1 instance(s). Instance "testcdb", status READY, has 1 handler(s) for this service... Service "testcdbXDB" has 1 instance(s). Instance "testcdb", status READY, has 1 handler(s) for this service... The command completed successfully
——- unregister pdb service
SQL> exec dbms_service.stop_service('CON_CDB_NEW'); PL/SQL procedure successfully completed. SQL> !lsnrctl status listener1; LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 09-AUG-2013 14:59:05 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db-42)(PORT=1523))) STATUS of the LISTENER ------------------------ Alias listener1 Version TNSLSNR for Linux: Version 12.1.0.1.0 - Production Start Date 08-AUG-2013 21:04:57 Uptime 0 days 17 hr. 54 min. 8 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /data/app2/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File /data/app2/oracle/diag/tnslsnr/db-42/listener1/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db-42)(PORT=1523))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1523))) Services Summary... Service "testcdb" has 1 instance(s). Instance "testcdb", status READY, has 1 handler(s) for this service... Service "testcdbXDB" has 1 instance(s). Instance "testcdb", status READY, has 1 handler(s) for this service... The command completed successfully SQL> ! sqlplus 'sys/oracle@TESTCDB as sysdba' SQL*Plus: Release 12.1.0.1.0 Production on Fri Aug 9 15:00:04 2013 Copyright (c) 1982, 2013, Oracle. All rights reserved. ERROR: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
同理在12c之前包括12c中可以管理多个service_name
[oracle@db-42 ~]$ source ~/.bash_profile_11 [oracle@db-42 ~]$ ora si SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 9 15:01:13 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> !lsnrctl status LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 09-AUG-2013 15:01:19 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 09-AUG-2013 14:29:46 Uptime 0 days 0 hr. 31 min. 33 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /data/app1/oracle/diag/tnslsnr/db-42/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db-42)(PORT=1521))) Services Summary... Service "liuyang" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... Service "testdb" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... Service "testdbXDB" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... The command completed successfully SQL> show parameter service_names; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ service_names string testdb, liuyang SQL> exec dbms_service.stop_service('liuyang'); PL/SQL procedure successfully completed. SQL> !lsnrctl status LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 09-AUG-2013 15:01:47 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 09-AUG-2013 14:29:46 Uptime 0 days 0 hr. 32 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /data/app1/oracle/diag/tnslsnr/db-42/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db-42)(PORT=1521))) Services Summary... Service "testdb" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... Service "testdbXDB" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... The command completed successfully SQL> exec dbms_service.start_service('liuyang'); PL/SQL procedure successfully completed. SQL> !lsnrctl status LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 09-AUG-2013 15:02:12 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 09-AUG-2013 14:29:46 Uptime 0 days 0 hr. 32 min. 26 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /data/app1/oracle/diag/tnslsnr/db-42/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db-42)(PORT=1521))) Services Summary... Service "liuyang" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... Service "testdb" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... Service "testdbXDB" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... The command completed successfully SQL> exec dbms_service.stop_service('testdb'); PL/SQL procedure successfully completed. SQL> !lsnrctl status LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 09-AUG-2013 15:02:41 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 09-AUG-2013 14:29:46 Uptime 0 days 0 hr. 32 min. 54 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /data/app1/oracle/diag/tnslsnr/db-42/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db-42)(PORT=1521))) Services Summary... Service "liuyang" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... Service "testdb" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... Service "testdbXDB" has 1 instance(s). Instance "testdb", status READY, has 1 handler(s) for this service... The command completed successfully
注意无法直接停止testdb service,只能对service ‘liuyang’进行操作。