如何在18c中为快照轮播克隆PDB

时间:2018-10-24 09:09:11

标签: oracle multi-tenant snapshot dataguard oracle18c

朋友!

我有一个带有Data Guard配置的Oracle Database 18c:

 import java.io.DataInputStream; 
 import java.io.FileInputStream; 
 import java.io.IOException; 
 import java.io.InputStreamReader; 
 import java.util.Scanner; 
 import java.util.StringTokenizer; 

public class Main 
{ 
static class Reader 
{ 
    final private int BUFFER_SIZE = 1 << 16; 
    private DataInputStream din; 
    private byte[] buffer; 
    private int bufferPointer, bytesRead; 

    public Reader() 
    { 
        din = new DataInputStream(System.in); 
        buffer = new byte[BUFFER_SIZE]; 
        bufferPointer = bytesRead = 0; 
    } 

    public Reader(String file_name) throws IOException 
    { 
        din = new DataInputStream(new FileInputStream(file_name)); 
        buffer = new byte[BUFFER_SIZE]; 
        bufferPointer = bytesRead = 0; 
    } 

    public String readLine() throws IOException 
    { 
        byte[] buf = new byte[64]; // line length 
        int cnt = 0, c; 
        while ((c = read()) != -1) 
        { 
            if (c == '\n') 
                break; 
            buf[cnt++] = (byte) c; 
        } 
        return new String(buf, 0, cnt); 
    } 

    public int nextInt() throws IOException 
    { 
        int ret = 0; 
        byte c = read(); 
        while (c <= ' ') 
            c = read(); 
        boolean neg = (c == '-'); 
        if (neg) 
            c = read(); 
        do
        { 
            ret = ret * 10 + c - '0'; 
        } while ((c = read()) >= '0' && c <= '9'); 

        if (neg) 
            return -ret; 
        return ret; 
    } 

    public long nextLong() throws IOException 
    { 
        long ret = 0; 
        byte c = read(); 
        while (c <= ' ') 
            c = read(); 
        boolean neg = (c == '-'); 
        if (neg) 
            c = read(); 
        do { 
            ret = ret * 10 + c - '0'; 
        } 
        while ((c = read()) >= '0' && c <= '9'); 
        if (neg) 
            return -ret; 
        return ret; 
    } 

    public double nextDouble() throws IOException 
    { 
        double ret = 0, div = 1; 
        byte c = read(); 
        while (c <= ' ') 
            c = read(); 
        boolean neg = (c == '-'); 
        if (neg) 
            c = read(); 

        do { 
            ret = ret * 10 + c - '0'; 
        } 
        while ((c = read()) >= '0' && c <= '9'); 

        if (c == '.') 
        { 
            while ((c = read()) >= '0' && c <= '9') 
            { 
                ret += (c - '0') / (div *= 10); 
            } 
        } 

        if (neg) 
            return -ret; 
        return ret; 
    } 

    private void fillBuffer() throws IOException 
    { 
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
        if (bytesRead == -1) 
            buffer[0] = -1; 
    } 

    private byte read() throws IOException 
    { 
        if (bufferPointer == bytesRead) 
            fillBuffer(); 
        return buffer[bufferPointer++]; 
    } 

    public void close() throws IOException 
    { 
        if (din == null) 
            return; 
        din.close(); 
    } 
} 

public static void main(String[] args) throws IOException 
{ 
    Reader s=new Reader(); 
    int n = s.nextInt(); 
    int k = s.nextInt(); 
    int count=0; 
    while (n-- > 0) 
    { 
        int x = s.nextInt(); 
        if (x%k == 0) 
        count++; 
    } 
    System.out.println(count); 
} 
} 

这是具有一个PDB的CDB。 我的操作系统是RedHat 7。

当我尝试从我的PDB创建快照数据库时,出现以下错误:

DGMGRL> show configuration;

Configuration - CDB_DG

  Protection Mode: MaxPerformance
  Members:
  cdb1p - Primary database
  cdb2p - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 55 seconds ago)

SQL> select banner from v$version;

BANNER
---------------------------------------------------------------------------
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production

SQL> SELECT PROPERTY_NAME, PROPERTY_VALUE FROM DATABASE_PROPERTIES WHERE  PROPERTY_NAME = 'LOCAL_UNDO_ENABLED';

PROPERTY_NAME             PROPERTY_V
------------------------- ----------
LOCAL_UNDO_ENABLED        TRUE

我了解了有关参数CLONEDB(= TRUE)和有关SQL> alter pluggable database snapshot PDBSNAP; alter pluggable database snapshot PDBSNAP * ERROR at line 1: ORA-00604: error occurred at recursive SQL level 1 ORA-65169: error encountered while attempting to copy file +ASM_CDB_DATA/CDB1P/7533D1D42D885BD1E053465A130A97EE/DATAFILE/undotbs1.271.986139369 ORA-17517: Database cloning using storage snapshot failed on file 8:+ASM_CDB_DATA/CDB1P/7533D1D42D885BD1E053465A130A97EE/DATAFILE/undotbs1.271.986139369 的权限的信息 在/ etc / group文件中。

不幸的是,它对我没有帮助。 朋友,也许有人解决了这个问题?

也许是关于快照克隆限制的,但是我不确定:

asmadmin:x:1308:grid,oracle

2 个答案:

答案 0 :(得分:0)

第1行出现错误: ORA-00604:递归SQL级别1发生错误 ORA-65169:尝试复制文件时遇到错误 + DATA / ORCL_IAD1T9 / 87BD77B686294076E0530200000A3FB4 / DATAFILE / undotbs1.282.1006941 741 ORA-17517:使用文件存储快照克隆数据库失败 8:+ DATA / ORCL_IAD1T9 / 87BD77B686294076E0530200000A3FB4 / DATAFILE / undotbs1.282.10069 41741


针对上述问题,我找到了解决方案。

仅当ACFS或DNFS等存储上的pdb时,才可以创建帮助我进行pdb快照克隆的

i解决方案。但我不应该在ASM存储上。仅当AFS存储顶部有ACFS时,它才有效。

一旦创建了ACFS,将db_create_file_dest更改为新的ACFS挂载点,然后执行文件Alternate可插入数据库快照命令以获取快照。

有关更多信息,请遵循以下公共网址

https://docs.oracle.com/en/database/oracle/oracle-database/18/multi/cloning-a-pdb.html#GUID-E4EAE488-5371-4B8A-A839-2ADFA7507705

https://www.cyberciti.biz/faq/creating-soft-link-or-symbolic-link/

谢谢。

答案 1 :(得分:0)

user11051512给出的答案也对我有用。我会尝试澄清一下,因为这样写起来有些困难:

快照仅在某些文件系统(例如ACFS)上起作用,而不能直接在ASM中起作用。因此,要在基于ASM的设置中使用快照功能,您需要创建一个ACFS文件系统,数据库文件将在其中驻留。 ACFS文件系统使用ASM作为后备存储。

  1. 在asm中创建卷(使用asmcmd):volcreate -G data -s 50G volume1
  2. 设置挂载点:mkdir /acfs
  3. 在asm设备上创建一个acfs文件系统:mkfs.acfs /dev/asm/volume-whatver
  4. 安装设备:mount.acfs /dev/asm/volume-whatver /acfs
  5. 任命一名主管并将其交给您的oracle /数据库用户:mkdir /acfs/data && chown..
  6. 在CDB中(您需要使用“ -useOMF false”创建它:alter system set db_create_file_dest='/acfs/data';
  7. 创建可插入的数据库:create pluggable database master admin user master identified by master;
  8. 查看数据文件:select name from v$datafile;
  9. 更改新的pdb以进行读写操作,以便对其进行注册。然后再次将其关闭,并以只读方式打开。
  10. 现在终于可以创建快照副本了:
SQL> create pluggable database test1 from master snapshot copy;

Pluggable database created.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 MASTER                         READ ONLY  NO
         4 TEST1                          MOUNTED
SQL>