3.通過現有的PDB建立一個新的PDB

來源:互聯網
上載者:User

標籤:des   style   http   color   os   io   strong   資料   

實驗說明:建立PDB除了可以通過種子PDB建立外,現在測試通過一個現有的使用者PDB複製建立新的PDB資料庫實驗步驟:1.建立測試資料SQL> alter session set container=emp;
Session altered.

SQL> conn dsg/[email protected]
Connected.
SQL> create table test (id number(8));
Table created.

SQL> begin
  2  for i in 1..100 loop
  3  insert into test values(i);
  4  end loop;
  5  commit;
  6  end;
  7  /
PL/SQL procedure successfully completed.

SQL> select count(*) from test;
  COUNT(*)
----------
       1002.通過現有PDB建立新的PDB  EMPTESTSQL> conn / as sysdba
Connected.
SQL> create pluggable database emptest from emp;
create pluggable database emptest from emp
*
ERROR at line 1:
ORA-65081: database or pluggable database is not open in read only mode
----來源資料庫必須在read only狀態

SQL> alter pluggable database emp close;

Pluggable database altered.

SQL> alter pluggable database emp open read only;
Pluggable database altered.

SQL> create pluggable database emptest from emp;
Pluggable database created.3.在tnsnames.ora中添加下面的資訊,這樣就可以通過服務名串連資料庫了
EMPTEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = EMPTEST)
    )
  )
 新的PDB建立成功,查看alert日誌:
create pluggable database emptest from emp
Sun Jan 19 22:26:48 2014
****************************************************************
Pluggable Database EMPTEST with pdb id - 4 is created as UNUSABLE.
If any errors are encountered before the pdb is marked as NEW,
then the pdb must be dropped
****************************************************************
Deleting old file#7 from file$
Deleting old file#8 from file$
Deleting old file#9 from file$
Adding new file#12 to file$(old file#7)
Adding new file#13 to file$(old file#8)
Adding new file#14 to file$(old file#9)
Successfully created internal service emptest at open
ALTER SYSTEM: Flushing buffer cache inst=0 container=4 local
****************************************************************
Post plug operations are now complete.
Pluggable database EMPTEST with pdb id - 4 is now marked as NEW.
****************************************************************
Completed: create pluggable database emptest from emp
新的PDB建立後資料庫會自動監聽
[[email protected] datafile]$ lsnrctl status

LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 19-JAN-2014 22:31:31

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                         LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date               14-JAN-2014 10:29:20
Uptime                    5 days 12 hr. 2 min. 11 sec
Trace Level             off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost.localdomain)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/ora12c/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "emp" has 1 instance(s).
  Instance "ora12c", status READY, has 1 handler(s) for this service...
Service "emptest" has 1 instance(s).
  Instance "ora12c", status READY, has 1 handler(s) for this service...

Service "ora12c" has 1 instance(s).
  Instance "ora12c", status READY, has 1 handler(s) for this service...
Service "ora12cXDB" has 1 instance(s).
  Instance "ora12c", status READY, has 1 handler(s) for this service...
The command completed successfully
 說明:PDB的一些更改操作不能在CDB層級更改,必須切換到PDB下,下面以修改GLOBAL_NAME為例:SQL> select service_id,name,pdb from v$services;

SERVICE_ID NAME                                                             PDB---------- ---------------------------------------------------------------- ------------------------------         0 emptest                                                          EMPTEST         6 emp                                                                 EMP         3 ora12cXDB                                                     CDB$ROOT         4 ora12c                                                             CDB$ROOT         1 SYS$BACKGROUND                                      CDB$ROOT         2 SYS$USERS                                                     CDB$ROOTSQL> alter pluggable database emptest rename global_name to emp_test;
alter pluggable database emptest rename global_name to emp_test
                                                       *
ERROR at line 1:
ORA-65046: operation not allowed from outside a pluggable database

SQL> alter pluggable database emptest close;
alter pluggable database emptest close
*
ERROR at line 1:
ORA-65020: pluggable database EMPTEST already closed

下面以RESTRICTED 模式開啟資料庫
SQL> alter pluggable database emptest open restricted;
Pluggable database altered.

SQL> conn sys/[email protected] as sysdba
Connected.
SQL> alter pluggable database emptest rename global_name to emp_test;
Pluggable database altered.

SQL> select service_id,name,pdb from v$services;

SERVICE_ID NAME                                                             PDB
---------- ---------------------------------------------------------------- ------------------------------
         1 emp_test                                                         EMP_TEST

SQL> conn / as sysdba
Connected.
SQL> select service_id,name,pdb from v$services;

SERVICE_ID NAME                                                             PDB
---------- ---------------------------------------------------------------- ------------------------------
         1 emp_test                                                         EMP_TEST
         6 emp                                                                   EMP
         3 ora12cXDB                                                        CDB$ROOT
         4 ora12c                                                                 CDB$ROOT
         1 SYS$BACKGROUND                                          CDB$ROOT
         2 SYS$USERS                                                        CDB$ROOT

6 rows selected.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.