這篇文章給大家分享的是有關(guān)Oracle 18c新特性-PDB快照輪播的示例分析的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。
創(chuàng)新互聯(lián)是一家專業(yè)提供云浮企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站建設(shè)、做網(wǎng)站、H5網(wǎng)站設(shè)計(jì)、小程序制作等業(yè)務(wù)。10年已為云浮眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進(jìn)行中。Oracle 18c推出的一個(gè)新功能就是PDB快照輪播,最多可以創(chuàng)建8個(gè)pdb的快照,而這8個(gè)構(gòu)成的一組快照就被稱作快照輪播。當(dāng)達(dá)到第8個(gè)快照限制時(shí),新的快照就會(huì)覆蓋最舊的快照,就像redo log一樣。PDB的快照主要作用是當(dāng)出現(xiàn)了問題可以閃回到快照的時(shí)間點(diǎn),另一個(gè)功能是基于快照來查詢歷史數(shù)據(jù)。
SQL> SELECT r.CON_ID, p.PDB_NAME, PROPERTY_NAME, PROPERTY_VALUE AS value, DESCRIPTION FROM CDB_PROPERTIES r, CDB_PDBS p WHERE r.CON_ID = p.CON_ID AND PROPERTY_NAME LIKE 'MAX_PDB%' AND description like 'maximum%' ORDER BY PROPERTY_NAME; CON_ID PDB_NAME PROPERTY_NAME VALUE DESCRIPTION ---------- -------------------- -------------------- -------------------- ---------------------------------------------------------------------- 3 ORCLPDB1 MAX_PDB_SNAPSHOTS maximum number of snapshots for a given PDB
默認(rèn)情況下是手動(dòng)創(chuàng)建快照,我們可以把它改成自動(dòng)創(chuàng)建。
SQL> select snapshot_mode,snapshot_interval/60 from dba_pdbs; SNAPSH SNAPSHOT_INTERVAL/60 ------ -------------------- MANUAL SQL> alter pluggable database snapshot mode every 4 hours; Pluggable database altered. SQL> select snapshot_mode,snapshot_interval/60 from dba_pdbs; SNAPSH SNAPSHOT_INTERVAL/60 ------ -------------------- AUTO 4
要返回手動(dòng)模式,輸入mode manual即可。
SQL> alter pluggable database snapshot mode manual; Pluggable database altered. SQL> alter pluggable database snapshot; Pluggable database altered.
手動(dòng)創(chuàng)建快照,可以自己指定名字,也可以使用系統(tǒng)自動(dòng)生成的名字。通過查看DBA_PDB_SNAPSHOTS視圖,可以找到快照存放的路徑及創(chuàng)建快照的SCN號(hào)。
SQL> SELECT CON_ID, CON_NAME, SNAPSHOT_NAME, SNAPSHOT_SCN AS snap_scn, FULL_SNAPSHOT_PATH FROM DBA_PDB_SNAPSHOTS ORDER BY SNAP_SCN; CON_ID CON_NAME SNAPSHOT_NAME SNAP_SCN FULL_SNAPSHOT_PATH ---------- -------------------- ------------------------- ---------- --------------------------------------------------------------------------- 3 ORCLPDB1 SNAP_2953839490_989014667 2821702 /opt/oracle/oradata/ORCLCDB/ORCLPDB1/snap_2953839490_2821702.pdb 3 ORCLPDB1 PDB_SNAP 2823303 /opt/oracle/oradata/ORCLCDB/ORCLPDB1/snap_2953839490_2823303.pdb 3 ORCLPDB1 SNAP_2953839490_989015970 2823679 /opt/oracle/oradata/ORCLCDB/ORCLPDB1/snap_2953839490_2823679.pdb [oracle@oracle-18c-vagrant ORCLPDB1]$ ls -lsh total 1.3G 4.0K drwxr-x---. 8 oracle oinstall 4.0K Oct 8 22:39 ORCLCDB 171M -rw-r--r--. 1 oracle oinstall 171M Oct 8 22:18 snap_2953839490_2821702.pdb 171M -rw-r--r--. 1 oracle oinstall 171M Oct 8 22:38 snap_2953839490_2823303.pdb 171M -rw-r--r--. 1 oracle oinstall 171M Oct 8 22:40 snap_2953839490_2823679.pdb 371M -rw-r-----. 1 oracle oinstall 371M Oct 8 22:39 sysaux01.dbf 271M -rw-r-----. 1 oracle oinstall 271M Oct 8 22:39 system01.dbf 56K -rw-r-----. 1 oracle oinstall 63M Oct 1 23:21 temp01.dbf 101M -rw-r-----. 1 oracle oinstall 101M Oct 8 22:39 undotbs01.dbf 5.1M -rw-r-----. 1 oracle oinstall 5.1M Oct 8 22:39 users01.dbf
如果要?jiǎng)h除快照,則有兩種方法,第一種就是使用alter pluggable database刪除,第二種是修改max_pdb_snapshots參數(shù),當(dāng)max_pdb_snapshots參數(shù)設(shè)置成0時(shí),將刪除全部快照。
SQL> alter pluggable database drop snapshot SNAP_2953839490_989015970; Pluggable database altered. SQL> SELECT CON_ID, CON_NAME, SNAPSHOT_NAME, SNAPSHOT_SCN AS snap_scn, SNAPSHOT_TIME, FULL_SNAPSHOT_PATH FROM DBA_PDB_SNAPSHOTS ORDER BY SNAP_SCN; CON_ID CON_NAME SNAPSHOT_NAME SNAP_SCN SNAPSHOT_TIME FULL_SNAPSHOT_PATH ---------- -------------------- ------------------------- ---------- ------------- --------------------------------------------------------------------------- 3 ORCLPDB1 SNAP_2953839490_989014667 2821702 1539008272 /opt/oracle/oradata/ORCLCDB/ORCLPDB1/snap_2953839490_2821702.pdb 3 ORCLPDB1 PDB_SNAP 2823303 1539009503 /opt/oracle/oradata/ORCLCDB/ORCLPDB1/snap_2953839490_2823303.pdb SQL> alter pluggable database set max_pdb_snapshots=0; Pluggable database altered. SQL> SELECT CON_ID, CON_NAME, SNAPSHOT_NAME, SNAPSHOT_SCN AS snap_scn, SNAPSHOT_TIME, FULL_SNAPSHOT_PATH FROM DBA_PDB_SNAPSHOTS ORDER BY SNAP_SCN; no rows selected
演示了上述功能之后,還有一個(gè)功能,就是我們可以根據(jù)快照創(chuàng)建pdb。
SQL> alter pluggable database set max_pdb_snapshots=8; Pluggable database altered SQL> alter pluggable database snapshot pdb_snap; Pluggable database altered. SQL> SELECT CON_ID, CON_NAME, SNAPSHOT_NAME, SNAPSHOT_SCN AS snap_scn, SNAPSHOT_TIME, FULL_SNAPSHOT_PATH FROM DBA_PDB_SNAPSHOTS ORDER BY SNAP_SCN; CON_ID CON_NAME SNAPSHOT_NAME SNAP_SCN SNAPSHOT_TIME FULL_SNAPSHOT_PATH ---------- -------------------- ------------------------- ---------- ------------- --------------------------------------------------------------------------- 3 ORCLPDB1 PDB_SNAP 2825283 1539010328 /opt/oracle/oradata/ORCLCDB/ORCLPDB1/snap_2953839490_2825283.pdb SQL> ! [oracle@oracle-18c-vagrant ~]$ mkdir -p /opt/oracle/oradata/ORCLCDB/ORCLPDB2 SQL> create pluggable database ORCLPDB2 from ORCLPDB1 using snapshot PDB_SNAP create_file_dest='/opt/oracle/oradata/ORCLCDB/ORCLPDB2'; create pluggable database ORCLPDB2 from ORCLPDB1 using snapshot PDB_SNAP create_file_dest='/opt/oracle/oradata/ORCLCDB/ORCLPDB2' * ERROR at line 1: ORA-65040: operation not allowed from within a pluggable database SQL> alter session set container=CDB$ROOT; Session altered. SQL> create pluggable database ORCLPDB2 from ORCLPDB1 using snapshot PDB_SNAP create_file_dest='/opt/oracle/oradata/ORCLCDB/ORCLPDB2'; Pluggable database created. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 ORCLPDB1 READ WRITE NO 5 ORCLPDB2 MOUNTED SQL> alter pluggable database ORCLPDB2 open; Pluggable database altered.
這樣我們就根據(jù)快照創(chuàng)建了一個(gè)新的PDB,假設(shè)當(dāng)前PDB出現(xiàn)了數(shù)據(jù)覆蓋,我們就可以使用這個(gè)歷史快照的PDB來恢復(fù)數(shù)據(jù)。
當(dāng)然還有一個(gè)很好用的功能就是我們?cè)趧?chuàng)建pdb的過程中把他設(shè)置成15分鐘產(chǎn)生一個(gè)快照。當(dāng)然配置這個(gè)功能有一個(gè)先決條件:CDB必須處于本地undo模式.
SQL> create pluggable database ORCLPDB3 from ORCLPDB1 file_name_convert=('ORCLPDB1','ORCLPDB3') snapshot mode every 5 minutes; Pluggable database created.
可以看到每隔5分鐘自動(dòng)創(chuàng)建一個(gè)快照
[oracle@oracle-18c-vagrant ORCLPDB3]$ ls -lrt snap* -rw-r--r--. 1 oracle oinstall 179134736 Oct 8 23:13 snap_2091710291_2830531.pdb -rw-r--r--. 1 oracle oinstall 179167158 Oct 8 23:18 snap_2091710291_2832545.pdb -rw-r--r--. 1 oracle oinstall 179285979 Oct 8 23:23 snap_2091710291_2833104.pdb -rw-r--r--. 1 oracle oinstall 179284365 Oct 8 23:28 snap_2091710291_2833687.pdb -rw-r--r--. 1 oracle oinstall 179302205 Oct 8 23:33 snap_2091710291_2834965.pdb -rw-r--r--. 1 oracle oinstall 179315484 Oct 8 23:38 snap_2091710291_2836695.pdb -rw-r--r--. 1 oracle oinstall 115724288 Oct 8 23:43 snap_2091710291_2837222.pdb
我們可以做個(gè)實(shí)驗(yàn)測(cè)試一下。在生成快照之前創(chuàng)建一個(gè)表插入點(diǎn)數(shù)據(jù),這里上一次快照是23:43分。
SQL> alter session set container=ORCLPDB3; Session altered. SQL> create table a1 as select * from dba_objects; Table created. SQL> select count(1) from a1; COUNT(1) ---------- 72897 [oracle@oracle-18c-vagrant ORCLPDB3]$ ls -lrt snap* -rw-r--r--. 1 oracle oinstall 179134736 Oct 8 23:13 snap_2091710291_2830531.pdb -rw-r--r--. 1 oracle oinstall 179167158 Oct 8 23:18 snap_2091710291_2832545.pdb -rw-r--r--. 1 oracle oinstall 179285979 Oct 8 23:23 snap_2091710291_2833104.pdb -rw-r--r--. 1 oracle oinstall 179284365 Oct 8 23:28 snap_2091710291_2833687.pdb -rw-r--r--. 1 oracle oinstall 179302205 Oct 8 23:33 snap_2091710291_2834965.pdb -rw-r--r--. 1 oracle oinstall 179315484 Oct 8 23:38 snap_2091710291_2836695.pdb -rw-r--r--. 1 oracle oinstall 179353508 Oct 8 23:43 snap_2091710291_2837222.pdb -rw-r--r--. 1 oracle oinstall 5767168 Oct 8 23:48 snap_2091710291_2839217.pdb SQL> SELECT CON_ID, CON_NAME, SNAPSHOT_NAME, SNAPSHOT_SCN AS snap_scn, SNAPSHOT_TIME, FULL_SNAPSHOT_PATH FROM DBA_PDB_SNAPSHOTS ORDER BY SNAP_SCN; CON_ID CON_NAME SNAPSHOT_NAME SNAP_SCN SNAPSHOT_TIME FULL_SNAPSHOT_PATH ---------- -------------------- ------------------------- ---------- ------------- --------------------------------------------------------------------------- 7 ORCLPDB3 SNAP_2091710291_989017984 2830531 1539011592 /opt/oracle/oradata/ORCLCDB/ORCLPDB3/snap_2091710291_2830531.pdb 7 ORCLPDB3 SNAP_2091710291_989018284 2832545 1539011887 /opt/oracle/oradata/ORCLCDB/ORCLPDB3/snap_2091710291_2832545.pdb 7 ORCLPDB3 SNAP_2091710291_989018584 2833104 1539012188 /opt/oracle/oradata/ORCLCDB/ORCLPDB3/snap_2091710291_2833104.pdb 7 ORCLPDB3 SNAP_2091710291_989018884 2833687 1539012489 /opt/oracle/oradata/ORCLCDB/ORCLPDB3/snap_2091710291_2833687.pdb 7 ORCLPDB3 SNAP_2091710291_989019184 2834965 1539012787 /opt/oracle/oradata/ORCLCDB/ORCLPDB3/snap_2091710291_2834965.pdb 7 ORCLPDB3 SNAP_2091710291_989019484 2836695 1539013087 /opt/oracle/oradata/ORCLCDB/ORCLPDB3/snap_2091710291_2836695.pdb 7 ORCLPDB3 SNAP_2091710291_989019784 2837222 1539013386 /opt/oracle/oradata/ORCLCDB/ORCLPDB3/snap_2091710291_2837222.pdb 7 ORCLPDB3 SNAP_2091710291_989020084 2839217 1539013686 /opt/oracle/oradata/ORCLCDB/ORCLPDB3/snap_2091710291_2839217.pdb
23點(diǎn)48分產(chǎn)生了新的快照,此時(shí)我們使用新的快照做一個(gè)克隆,登陸到ORCLPDB4數(shù)據(jù)庫(kù)后,我們會(huì)發(fā)現(xiàn)是有數(shù)據(jù)的。
SQL> alter session set container=CDB$ROOT; Session altered. SQL> create pluggable database ORCLPDB4 from ORCLPDB3 using snapshot SNAP_2091710291_989020084 create_file_dest='/opt/oracle/oradata/ORCLCDB/ORCLPDB4'; Pluggable database created SQL> alter pluggable database ORCLPDB4 open; Pluggable database altered. SQL> alter session set container=ORCLPDB4; Session altered. SQL> select count(1) from a1; COUNT(1) ---------- 72897
這個(gè)功能對(duì)于測(cè)試人員非常有用,例如移動(dòng)電信現(xiàn)在有BCV環(huán)境,專門用于經(jīng)分抽數(shù)及測(cè)試,而這個(gè)BCV環(huán)境是底層同步的一個(gè)克隆。使用18c數(shù)據(jù)庫(kù),我們就可以直接創(chuàng)建快照,然后使用快照克隆一個(gè)新數(shù)據(jù)庫(kù)形成BCV環(huán)境給經(jīng)分抽數(shù)及測(cè)試使用了。
感謝各位的閱讀!關(guān)于“Oracle 18c新特性-PDB快照輪播的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
網(wǎng)站標(biāo)題:Oracle18c新特性-PDB快照輪播的示例分析-創(chuàng)新互聯(lián)
文章分享:http://www.rwnh.cn/article16/ccjogg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、外貿(mào)建站、網(wǎng)站設(shè)計(jì)、App開發(fā)、用戶體驗(yàn)、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容