李波Joker 发表于 2016-3-25 12:05:44

12c 练习日记5 pluggable database rman /

$ df -h
Filesystem            SizeUsed Avail Use% Mounted on
/dev/sda3            27G   16G9.6G63% /
/dev/sdb1             7.8G4.1G3.4G56% /oradata
/dev/sda1             388M   17M351M   5% /boot
tmpfs                1006M522M485M52% /dev/shm
$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Mar 23 21:16:32 2016

Copyright (c) 1982, 2014, Oracle and/or its affiliates.All rights reserved.

connected to target database: ORCL12C (DBID=737623805)

RMAN> backup filesperset =5 as compressed backupset database format '/tmp/full_db_%U';

Starting backup at 23-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=43 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 03/23/2016 21:19:07
RMAN-06149: cannot BACKUP DATABASE in NOARCHIVELOG mode

RMAN> exit


Recovery Manager complete.
$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Mar 23 21:19:20 2016

Copyright (c) 1982, 2014, Oracle.All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.

Total System Global Area838860800 bytes
Fixed Size                  2929936 bytes
Variable Size             562039536 bytes
Database Buffers          268435456 bytes
Redo Buffers                5455872 bytes
Database mounted.
SQL> ! mkdir /home/oracle/arch

SQL> alter database archivelog;

Database altered.

SQL>
SQL> alter system set log_archive_dest_1='location=/home/oracle/arch';

System altered.
SQL> startup force;
ORACLE instance started.

Total System Global Area838860800 bytes
Fixed Size                  2929936 bytes
Variable Size             562039536 bytes
Database Buffers          268435456 bytes
Redo Buffers                5455872 bytes
Database mounted.
Database opened.
SQL>
SQL> archive log list;
Database log mode            Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/arch
Oldest online log sequence   14
Next log sequence to archive   16
Current log sequence         16

$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Mar 23 21:22:16 2016

Copyright (c) 1982, 2014, Oracle and/or its affiliates.All rights reserved.

connected to target database: ORCL12C (DBID=737623805)

RMAN> backup filesperset=5 as compressed backupset database format '/home/oracle/backup/full_%d_%U.dbf';

Starting backup at 23-MAR-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/orcl12c/system01.dbf
input datafile file number=00003 name=/oradata/orcl12c/sysaux01.dbf
input datafile file number=00004 name=/oradata/orcl12c/undotbs01.dbf
input datafile file number=00006 name=/oradata/orcl12c/users01.dbf
channel ORA_DISK_1: starting piece 1 at 23-MAR-16
channel ORA_DISK_1: finished piece 1 at 23-MAR-16
piece handle=/home/oracle/backup/full_ORCL12C_03r17sph_1_1.dbf tag=TAG20160323T212505 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:04:38
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00025 name=/oradata/orcl12c/pdb3/sysaux01.dbf
input datafile file number=00024 name=/oradata/orcl12c/pdb3/system01.dbf
input datafile file number=00026 name=/oradata/orcl12c/pdb3/testdb.dbf
channel ORA_DISK_1: starting piece 1 at 23-MAR-16
channel ORA_DISK_1: finished piece 1 at 23-MAR-16
piece handle=/home/oracle/backup/full_ORCL12C_04r17t27_1_1.dbf tag=TAG20160323T212505 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:35
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/oradata/orcl12c/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/oradata/orcl12c/pdbseed/system01.dbf
channel ORA_DISK_1: starting piece 1 at 23-MAR-16
channel ORA_DISK_1: finished piece 1 at 23-MAR-16
piece handle=/home/oracle/backup/full_ORCL12C_05r17t74_1_1.dbf tag=TAG20160323T212505 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:16
Finished backup at 23-MAR-16

Starting Control File and SPFILE Autobackup at 23-MAR-16
piece handle=/oracle/app/oracle/12c/db1/dbs/c-737623805-20160323-00 comment=NONE
Finished Control File and SPFILE Autobackup at 23-MAR-16

RMAN>

RMAN> list backup summary;


List of Backups
===============
Key   TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
1       BFA DISK      23-MAR-16       1       1       YES      TAG20160323T212505
2       BFA DISK      23-MAR-16       1       1       YES      TAG20160323T212505
3       BFA DISK      23-MAR-16       1       1       YES      TAG20160323T212505
4       BFA DISK      23-MAR-16       1       1       NO         TAG20160323T213438

RMAN> report schema;

Report of database schema for database with db_unique_name ORCL12C

List of Permanent Datafiles
===========================
File Size(MB) Tablespace         RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    790      SYSTEM               YES   /oradata/orcl12c/system01.dbf
3    600      SYSAUX               NO      /oradata/orcl12c/sysaux01.dbf
4    80       UNDOTBS1             YES   /oradata/orcl12c/undotbs01.dbf
5    250      PDB$SEED:SYSTEM      NO      /oradata/orcl12c/pdbseed/system01.dbf
6    5      USERS                NO      /oradata/orcl12c/users01.dbf
7    510      PDB$SEED:SYSAUX      NO      /oradata/orcl12c/pdbseed/sysaux01.dbf
24   250      PDB3:SYSTEM          NO      /oradata/orcl12c/pdb3/system01.dbf
25   510      PDB3:SYSAUX          NO      /oradata/orcl12c/pdb3/sysaux01.dbf
26   25       PDB3:TESTDB          NO      /oradata/orcl12c/pdb3/testdb.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace         Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    60       TEMP               32767       /oradata/orcl12c/temp01.dbf
2    20       PDB$SEED:TEMP      32767       /oradata/orcl12c/pdbseed/pdbseed_temp012016-03-22_05-29-14-AM.dbf
3    20       PDB3:TEMP            32767       /oradata/orcl12c/pdb3/pdbseed_temp012016-03-22_05-29-14-AM.dbf

RMAN>

RMAN> exit


Recovery Manager complete.
$ lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 23-MAR-2016 22:01:37

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host01)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
   Linux Error: 111: Connection refused
$
$ cd $ORACLE_HOME/dbs
$ ls
cd network/admin
c-737623805-20160323-00init.ora   orapworcl12c      spfileorcl12c.ora
hc_orcl12c.dat         lkORCL12Csnapcf_orcl12c.f
$ cd network/admin

$ ls
c-737623805-20160323-00init.ora   orapworcl12c      spfileorcl12c.ora
hc_orcl12c.dat         lkORCL12Csnapcf_orcl12c.f
$ cd ..
$ cd network/admin
$ ls
listener.orasamplesshrept.lsttnsnames.ora
$
$
$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /oracle/app/oracle/12c/db1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL12C =
(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = host01)(PORT = 1521))
      (SERVICE_NAME = orcl12c)
    )
)

LISTENER_ORCL12C =
(ADDRESS = (PROTOCOL = TCP)(HOST = host01)(PORT = 1521))


PDB2 =
(DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.60)(PORT = 1521))
    )
      (SERVICE_NAME = pdb2)
    )
)

TEST =
(DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.60)(PORT = 1521))
    )
      (SERVICE_NAME = test)
    )
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.60)(PORT = 1521))
      (SERVICE_NAME = test)
    )
)

)

    )
      (SERVICE_NAME = test)
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.60)(PORT = 1521))
    )
      (SERVICE_NAME = pdb2)
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.60)(PORT = 1521))
    )
    )
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.60)(PORT = 1521))
      (SERVICE_NAME = pdb3)
    )
"tnsnames.ora" 38L, 810C written                              

$ lsnrctl start
tnspo
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 23-MAR-2016 22:03:53

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

Starting /oracle/app/oracle/12c/db1/bin/tnslsnr: please wait...

ing pdb3;
TNSLSNR for Linux: Version 12.1.0.2.0 - Production
System parameter file is /oracle/app/oracle/12c/db1/network/admin/listener.ora
Log messages written to /oracle/app/oracle/diag/tnslsnr/host01/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host01)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host01)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                23-MAR-2016 22:04:06
Uptime                  0 days 0 hr. 0 min. 16 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/app/oracle/12c/db1/network/admin/listener.ora
Listener Log File         /oracle/app/oracle/diag/tnslsnr/host01/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host01)(PORT=1521)))
Services Summary...
Service "orcl12c" has 1 instance(s).
Instance "orcl12c", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
$ tnsping pdb3;

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 23-MAR-2016 22:04:10

Copyright (c) 1997, 2014, Oracle.All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.60)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb3)))
OK (40 msec)
$
$ tnsping pdb3;

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 23-MAR-2016 22:04:15

Copyright (c) 1997, 2014, Oracle.All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.60)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb3)))
OK (0 msec)
$
$ sqlplus sys/oracle@pdb3 as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Mar 23 22:04:40 2016

Copyright (c) 1982, 2014, Oracle.All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show con_name

CON_NAME
------------------------------
PDB3

SQL> alter database open;

Database altered.

SQL> create user pdb3 identified by oracle container=current account unlock;

User created.


SQL> grant dba,pdb_dba,connect,resource to pdb3;

Grant succeeded.

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
$
$
$ sqlplus pdb3/oracle@pdb3

SQL*Plus: Release 12.1.0.2.0 Production on Wed Mar 23 22:07:13 2016

Copyright (c) 1982, 2014, Oracle.All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show user
USER is "PDB3"



SQL>
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
$ sqlplus sys/oracle@pdb3 as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Mar 23 22:07:56 2016

Copyright (c) 1982, 2014, Oracle.All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> grant sysdba to pdb3;

Grant succeeded.


SQL> conn pdb3/oracle@pdb3
Connected.
SQL> select * from user_role_privs;

USERNAME   GRANTED_ROLE                   ADM DEL DEF OS_ COM
---------- ------------------------------ --- --- --- --- ---
PDB3       CONNECT                        NONOYES NONO
PDB3       DBA                            NONOYES NONO
PDB3       PDB_DBA                        NONOYES NONO
PDB3       RESOURCE                     NONOYES NONO

SQL>
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
$ rman target pdb3/oracle@pdb3

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Mar 23 22:11:02 2016

Copyright (c) 1982, 2014, Oracle and/or its affiliates.All rights reserved.

connected to target database: ORCL12C (DBID=737623805)

RMAN>

RMAN> backup filesperset = 5 as compressed backupset database format '/home/oracle/backup/pdb3_%d_%U.dbf';

Starting backup at 23-MAR-16

using target database control file instead of recovery catalog


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00025 name=/oradata/orcl12c/pdb3/sysaux01.dbf
input datafile file number=00024 name=/oradata/orcl12c/pdb3/system01.dbf
input datafile file number=00026 name=/oradata/orcl12c/pdb3/testdb.dbf
channel ORA_DISK_1: starting piece 1 at 23-MAR-16
channel ORA_DISK_1: finished piece 1 at 23-MAR-16
piece handle=/home/oracle/backup/pdb3_ORCL12C_07r17vhf_1_1.dbf tag=TAG20160323T221158 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:55
Finished backup at 23-MAR-16

Starting Control File and SPFILE Autobackup at 23-MAR-16
piece handle=/oracle/app/oracle/12c/db1/dbs/c-737623805-20160323-01 comment=NONE
Finished Control File and SPFILE Autobackup at 23-MAR-16



RMAN> report schema;

Report of database schema for database with db_unique_name ORCL12C

List of Permanent Datafiles
===========================
File Size(MB) Tablespace         RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
24   250      SYSTEM               NO      /oradata/orcl12c/pdb3/system01.dbf
25   510      SYSAUX               NO      /oradata/orcl12c/pdb3/sysaux01.dbf
26   25       TESTDB               NO      /oradata/orcl12c/pdb3/testdb.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace         Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
3    20       TEMP               32767       /oradata/orcl12c/pdb3/pdbseed_temp012016-03-22_05-29-14-AM.dbf

RMAN> exit


Recovery Manager complete.
$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Mar 23 22:15:25 2016

Copyright (c) 1982, 2014, Oracle and/or its affiliates.All rights reserved.

connected to target database: ORCL12C (DBID=737623805)

RMAN> backup filesperset = 5 as compressed backupset pluggable database pdb3 format '/home/oracle/backup/pdb3_%d_%U.dbf';

Starting backup at 23-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=54 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00025 name=/oradata/orcl12c/pdb3/sysaux01.dbf
input datafile file number=00024 name=/oradata/orcl12c/pdb3/system01.dbf
input datafile file number=00026 name=/oradata/orcl12c/pdb3/testdb.dbf
channel ORA_DISK_1: starting piece 1 at 23-MAR-16
channel ORA_DISK_1: finished piece 1 at 23-MAR-16
piece handle=/home/oracle/backup/pdb3_ORCL12C_09r1807b_1_1.dbf tag=TAG20160323T222338 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:06:56
Finished backup at 23-MAR-16

Starting Control File and SPFILE Autobackup at 23-MAR-16
piece handle=/oracle/app/oracle/12c/db1/dbs/c-737623805-20160323-02 comment=NONE
Finished Control File and SPFILE Autobackup at 23-MAR-16

RMAN> exit


Recovery Manager complete.

$ sqlplus pdb3/oracle@pdb3

SQL*Plus: Release 12.1.0.2.0 Production on Wed Mar 23 23:31:34 2016

Copyright (c) 1982, 2014, Oracle.All rights reserved.

Last Successful login time: Wed Mar 23 2016 22:10:20 -04:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show user
USER is "PDB3"
SQL> create table pdb3 as select * from dba_objects;

Table created.

SQL> select count(*) from pdb3;

COUNT(*)
----------
   90923


SQL> alter system switch logfile;
alter system switch logfile
*
ERROR at line 1:
ORA-65040: operation not allowed from within a pluggable database


SQL>
SQL> show user
USER is "PDB3"
SQL> shutdown immteiate
SP2-0717: illegal SHUTDOWN option

SQL> alter pluggable database all close immediate;

Pluggable database altered.

SQL>
SQL> select open_mode,name from v$pdbs;

OPEN_MODENAME
---------- ------------------------------
READ ONLYPDB$SEED
MOUNTED    PDB3

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
$

$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Thu Mar 24 00:20:24 2016

Copyright (c) 1982, 2014, Oracle and/or its affiliates.All rights reserved.

connected to target database: ORCL12C (DBID=737623805)

RMAN> restore pluggable database pdb3;

Starting restore at 24-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00024 to /oradata/orcl12c/pdb3/system01.dbf
channel ORA_DISK_1: restoring datafile 00025 to /oradata/orcl12c/pdb3/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00026 to /oradata/orcl12c/pdb3/testdb.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/pdb3_ORCL12C_09r1807b_1_1.dbf
channel ORA_DISK_1: piece handle=/home/oracle/backup/pdb3_ORCL12C_09r1807b_1_1.dbf tag=TAG20160323T222338
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:47
Finished restore at 24-MAR-16

RMAN> list failure;

Database Role: PRIMARY

no failures found that match specification

RMAN> alter database mount;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 03/24/2016 01:11:00
ORA-01100: database already mounted



RMAN> list failure pluggable database;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "pluggable": expecting one of: "all, closed, critical, detail, exclude, high, low, unknown, integer, ;"
RMAN-01007: at line 1 column 14 file: standard input



Recovery Manager complete.
$ rman target pdb3/oracle@pdb3

Recovery Manager: Release 12.1.0.2.0 - Production on Thu Mar 24 01:12:10 2016

Copyright (c) 1982, 2014, Oracle and/or its affiliates.All rights reserved.

connected to target database: ORCL12C (DBID=737623805, not open)

RMAN> list failure;

using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 03/24/2016 01:12:56
RMAN-07536: command not allowed when connected to a Pluggable Database

RMAN> recover database;

Starting recover at 24-MAR-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=62 device type=DISK

starting media recovery
media recovery complete, elapsed time: 00:00:04

Finished recover at 24-MAR-16

RMAN> alter database open;

Statement processed

RMAN>

RMAN> exit


Recovery Manager complete.
$ sqlplus pdb3/oracle@pdb3

SQL*Plus: Release 12.1.0.2.0 Production on Thu Mar 24 01:14:12 2016

Copyright (c) 1982, 2014, Oracle.All rights reserved.

Last Successful login time: Wed Mar 23 2016 23:31:35 -04:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> select count(*) from pdb3;

COUNT(*)
----------
   90923

SQL>
SQL>
SQL> select file#,name from v$datafile;

   FILE#
----------
NAME
--------------------------------------------------------------------------------
         4
/oradata/orcl12c/undotbs01.dbf

      24
/oradata/orcl12c/pdb3/system01.dbf

      25
/oradata/orcl12c/pdb3/sysaux01.dbf


   FILE#
----------
NAME
--------------------------------------------------------------------------------
      26
/oradata/orcl12c/pdb3/testdb.dbf


SQL> col name for a30


SQL> select tablespace_name from dba_data_files;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
TESTDB

SQL>
SQL>
SQL> alter table pdb3 move tablespace testdb;

Table altered.


SQL> alter database datafile 26 offline;

Database altered.

SQL>
SQL>
SQL> ! rm /oradata/orcl12c/pdb3/testdb.dbf;

SQL>
SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
$ rman target pdb3/oracle@pdb3

Recovery Manager: Release 12.1.0.2.0 - Production on Thu Mar 24 01:21:50 2016

Copyright (c) 1982, 2014, Oracle and/or its affiliates.All rights reserved.

connected to target database: ORCL12C (DBID=737623805)

RMAN> restore datafile 26;

Starting restore at 24-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=70 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00026 to /oradata/orcl12c/pdb3/testdb.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/pdb3_ORCL12C_09r1807b_1_1.dbf
channel ORA_DISK_1: piece handle=/home/oracle/backup/pdb3_ORCL12C_09r1807b_1_1.dbf tag=TAG20160323T222338
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 24-MAR-16

RMAN>

RMAN> list backup summary;


List of Backups
===============
Key   TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
2       BFA DISK      23-MAR-16       1       1       YES      TAG20160323T212505
5       BFA DISK      23-MAR-16       1       1       YES      TAG20160323T221158
6       BFA DISK      23-MAR-16       1       1       NO         TAG20160323T221455
7       BFA DISK      23-MAR-16       1       1       YES      TAG20160323T222338

RMAN> list backup of datafile 26;


List of Backup Sets
===================


BS KeyType LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    147.73M    DISK      00:02:31   23-MAR-16      
      BP Key: 2   Status: AVAILABLECompressed: YESTag: TAG20160323T212505
      Piece Name: /home/oracle/backup/full_ORCL12C_04r17t27_1_1.dbf
List of Datafiles in backup set 2
File LV Type Ckp SCN    Ckp TimeName
---- -- ---- ---------- --------- ----
26      Full 1961954    23-MAR-16 /oradata/orcl12c/pdb3/testdb.dbf

BS KeyType LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5       Full    147.75M    DISK      00:02:55   23-MAR-16      
      BP Key: 5   Status: AVAILABLECompressed: YESTag: TAG20160323T221158
      Piece Name: /home/oracle/backup/pdb3_ORCL12C_07r17vhf_1_1.dbf
List of Datafiles in backup set 5
File LV Type Ckp SCN    Ckp TimeName
---- -- ---- ---------- --------- ----
26      Full 1968689    23-MAR-16 /oradata/orcl12c/pdb3/testdb.dbf

BS KeyType LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7       Full    147.73M    DISK      00:06:48   23-MAR-16      
      BP Key: 7   Status: AVAILABLECompressed: YESTag: TAG20160323T222338
      Piece Name: /home/oracle/backup/pdb3_ORCL12C_09r1807b_1_1.dbf
List of Datafiles in backup set 7
File LV Type Ckp SCN    Ckp TimeName
---- -- ---- ---------- --------- ----
26      Full 1971364    23-MAR-16 /oradata/orcl12c/pdb3/testdb.dbf

RMAN> alter database datafile 26 online;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 03/24/2016 01:25:57
ORA-01113: file 26 needs media recovery
ORA-01110: data file 26: '/oradata/orcl12c/pdb3/testdb.dbf'


RMAN> list failure;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 03/24/2016 01:26:17
RMAN-07536: command not allowed when connected to a Pluggable Database

RMAN> recover datafile 26;

Starting recover at 24-MAR-16
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:04

Finished recover at 24-MAR-16

RMAN>

RMAN>

RMAN> alter database datafile 26 online;

Statement processed

RMAN> exit


Recovery Manager complete.
$ sqlplus pdb3/oracle@pdb3

SQL*Plus: Release 12.1.0.2.0 Production on Thu Mar 24 01:27:37 2016

Copyright (c) 1982, 2014, Oracle.All rights reserved.

Last Successful login time: Thu Mar 24 2016 01:14:12 -04:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show user
USER is "PDB3"
SQL> show con_name

CON_NAME
------------------------------
PDB3
SQL> desc user_objects;

SQL> select tablespace_name from user_tables where table_name='PDB3';

TABLESPACE_NAME
------------------------------
TESTDB


SQL> alter database datafile 26 offline;

Database altered.

SQL> ! rm /oradata/orcl12c/pdb3/testdb.dbf

SQL>
SQL>
SQL> ls rm /oradata/orcl12c/pdb3/testdb.dbf
SP2-0734: unknown command beginning "ls rm /ora..." - rest of line ignored.
SQL> ! ls /oradata/orcl12c/pdb3/testdb.dbf   
ls: /oradata/orcl12c/pdb3/testdb.dbf: No such file or directory

SQL>
SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Thu Mar 24 01:31:37 2016

Copyright (c) 1982, 2014, Oracle and/or its affiliates.All rights reserved.

connected to target database: ORCL12C (DBID=737623805)


RMAN> restore database datafile 26;

Starting restore at 24-MAR-16
using channel ORA_DISK_1

skipping datafile 5; already restored to file /oradata/orcl12c/pdbseed/system01.dbf
skipping datafile 7; already restored to file /oradata/orcl12c/pdbseed/sysaux01.dbf
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /oradata/orcl12c/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oradata/orcl12c/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oradata/orcl12c/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /oradata/orcl12c/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/full_ORCL12C_03r17sph_1_1.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 03/24/2016 01:32:17
ORA-19870: error while restoring backup piece /home/oracle/backup/full_ORCL12C_03r17sph_1_1.dbf
ORA-19573: cannot obtain exclusive enqueue for datafile 1

RMAN> restore datadile 26;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "allforeign, archivelog, backupset, channel, check, controlfile, database, database root, datafile, device, dump, force, foreign, from, from service, high, pluggable, preview, primary, section, skip readonly, spfile, standby, tablespace, to restore point, until restore point, until, using, validate, ("
RMAN-01008: the bad identifier was: datadile
RMAN-01007: at line 1 column 9 file: standard input

RMAN> restore datafile 26;

Starting restore at 24-MAR-16
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00026 to /oradata/orcl12c/pdb3/testdb.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/pdb3_ORCL12C_09r1807b_1_1.dbf
channel ORA_DISK_1: piece handle=/home/oracle/backup/pdb3_ORCL12C_09r1807b_1_1.dbf tag=TAG20160323T222338
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 24-MAR-16

RMAN>

RMAN> recover datafile 26;

Starting recover at 24-MAR-16
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:03

Finished recover at 24-MAR-16

RMAN> alter database datafile 26 online;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 03/24/2016 01:33:49
ORA-01516: nonexistent log file, data file, or temporary file "26"

RMAN>

RMAN> alter pluggable database pdb3 datafile 26 online;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 03/24/2016 01:34:12
ORA-65046: operation not allowed from outside a pluggable database

RMAN> exit


Recovery Manager complete.
$ sqlplus pdb3/oracle@pdb3
alter database datafile
SQL*Plus: Release 12.1.0.2.0 Production on Thu Mar 24 01:36:19 2016

Copyright (c) 1982, 2014, Oracle.All rights reserved.

26 online;



select count(*) from pdb3;
Last Successful login time: Thu Mar 24 2016 01:27:38 -04:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL>
Database altered.

SQL> SQL> SQL> SQL>
COUNT(*)
----------
   90923
页: [1]
查看完整版本: 12c 练习日记5 pluggable database rman /