zoukankan      html  css  js  c++  java
  • orale命令6 rman备份

    RMAN:
    使用ramn进行备份和恢复,rman不依赖系统操作命令,在数据块级别做备份。块级别备份,能只备份变化后的块,实现增量备份。而且不会备份空的块。
    好处:
    1、能实现增量备份
    2、只备份有数据的块,不备份空块和未使用的块
    3、支持压缩算法,进一步压缩数据
    4、帮我们管理备份的元数据

    SQL> create tablespace test datafile '/data/oracle/oradata/orcl/test01.dbf' size 100M; #创建表空间,具体目录,可通过之前查找确定
    Tablespace created.
    SQL>
    SQL> create table test tablespace test as select * from scott.emp; # 创建表 table
    Table created.
    SQL>
    SQL> select table_name from dba_tables
    SQL> analyze table test compute statistics;
    where tablespace_name='TEST'
    SQL> desc dba_tables; # 分析完表后,就能看到有 AVG_ROW_LEN参数,平均行长,就是一行占多少字节;
    SQL> select AVG_ROW_LEN*NUM_ROWs from dba_tables
    where table_name='TEST'; # 用平均行长*总共多少行,来计算table的大小,单位字节。

    SQL> select * from dba_data_files; 能看到表所属数据文件的的文件号

    FILE_NAME FILE_ID TABLESPACE_NAME BYTES BLOCKS
    -------------------------------------------------- ---------- ------------------------------------------------------------ ---------- ----------
    STATUS RELATIVE_FNO AUTOEX MAXBYTES MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS
    ------------------ ------------ ------ ---------- ---------- ------------ ---------- ----------- --------------
    /data/oracle/oradata/orcl/test01.dbf 6 TEST 104857600 12800
    AVAILABLE 6 NO 0 0 0 103809024 12672 ONLINE
    显示TEST的数据文件,文件为6;

    在RMAN下:
    [oracle@localhost ~]$ rman target /
    RMAN> backup datafile 6; #用rman来备份文件号为6,就是TEST。
    Starting backup at 15-NOV-17
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=50 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00006 name=/data/oracle/oradata/orcl/test01.dbf
    channel ORA_DISK_1: starting piece 1 at 15-NOV-17
    channel ORA_DISK_1: finished piece 1 at 15-NOV-17
    piece handle=/data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/o1_mf_nnndf_TAG20171115T222358_f0rmhz7o_.bkp tag=TAG20171115T222358 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 15-NOV-17
    RMAN>
    [oracle@localhost orcl]$ ls -lh |grep test
    -rw-r-----. 1 oracle dba 101M Nov 15 22:23 test01.dbf

    [oracle@localhost orcl]$ cd /data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/ # rman备份文件目录,备份时会显示
    [oracle@localhost 2017_11_15]$ ls -lh |grep o1_mf_nnndf_TAG20171115T222358_f0rmhz7o_.bkp
    -rw-r-----. 1 oracle dba 1.1M Nov 15 22:23 o1_mf_nnndf_TAG20171115T222358_f0rmhz7o_.bkp
    [oracle@localhost 2017_11_15]$

    会发现test01.dbf有101M,而rman备份的文件只有1.1M.


    RMAN> backup as compressed backupset datafile 6; # rman压缩备份,元数据压缩不了,主要是压缩数据。 因此rman除了自动过滤不备份空快外,还支持压缩算法,进一步节省空间。
    Starting backup at 15-NOV-17
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=49 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=00006 name=/data/oracle/oradata/orcl/test01.dbf
    channel ORA_DISK_1: starting piece 1 at 15-NOV-17
    channel ORA_DISK_1: finished piece 1 at 15-NOV-17
    piece handle=/data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/o1_mf_nnndf_TAG20171115T222847_f0rmrzqv_.bkp tag=TAG20171115T222847 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 15-NOV-17

    RMAN>

    RMAN> list backup; # 列出做过哪些备份,备份类型,备份大小,备份到哪里,备份是SCN

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

    BS Key Type LV Size Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1 Full 1.07M DISK 00:00:00 15-NOV-17
    BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20171115T222358
    Piece Name: /data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/o1_mf_nnndf_TAG20171115T222358_f0rmhz7o_.bkp
    List of Datafiles in backup set 1
    File LV Type Ckp SCN Ckp Time Name
    ---- -- ---- ---------- --------- ----
    6 Full 1048680 15-NOV-17 /data/oracle/oradata/orcl/test01.dbf

    BS Key Type LV Size Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    2 Full 1.02M DISK 00:00:00 15-NOV-17
    BP Key: 2 Status: AVAILABLE Compressed: YES Tag: TAG20171115T222847
    Piece Name: /data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/o1_mf_nnndf_TAG20171115T222847_f0rmrzqv_.bkp
    List of Datafiles in backup set 2
    File LV Type Ckp SCN Ckp Time Name
    ---- -- ---- ---------- --------- ----
    6 Full 1048852 15-NOV-17 /data/oracle/oradata/orcl/test01.dbf

    RMAN>
    RMAN> delete backup; # 删除数据
    using channel ORA_DISK_1
    List of Backup Pieces
    BP Key BS Key Pc# Cp# Status Device Type Piece Name
    ------- ------- --- --- ----------- ----------- ----------
    1 1 1 1 AVAILABLE DISK /data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/o1_mf_nnndf_TAG20171115T222358_f0rmhz7o_.bkp
    2 2 1 1 AVAILABLE DISK /data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/o1_mf_nnndf_TAG20171115T222847_f0rmrzqv_.bkp

    Do you really want to delete the above objects (enter YES or NO)? yes
    deleted backup piece
    backup piece handle=/data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/o1_mf_nnndf_TAG20171115T222358_f0rmhz7o_.bkp RECID=1 STAMP=960157439
    deleted backup piece
    backup piece handle=/data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/o1_mf_nnndf_TAG20171115T222847_f0rmrzqv_.bkp RECID=2 STAMP=960157727
    Deleted 2 objects
    RMAN>
    RMAN> backup database; # 普通全备,它会自己找控制文件,数据文件,备份时显示路径信息,
    Starting backup at 15-NOV-17
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00001 name=/data/oracle/oradata/orcl/system01.dbf
    input datafile file number=00002 name=/data/oracle/oradata/orcl/sysaux01.dbf
    input datafile file number=00005 name=/data/oracle/oradata/orcl/example01.dbf
    input datafile file number=00006 name=/data/oracle/oradata/orcl/test01.dbf
    input datafile file number=00003 name=/data/oracle/oradata/orcl/undotbs01.dbf
    input datafile file number=00004 name=/data/oracle/oradata/orcl/users01.dbf
    channel ORA_DISK_1: starting piece 1 at 15-NOV-17
    channel ORA_DISK_1: finished piece 1 at 15-NOV-17
    piece handle=/data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/o1_mf_nnndf_TAG20171115T223737_f0rn9kr1_.bkp tag=TAG20171115T223737 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current control file in backup set
    including current SPFILE in backup set
    channel ORA_DISK_1: starting piece 1 at 15-NOV-17
    channel ORA_DISK_1: finished piece 1 at 15-NOV-17
    piece handle=/data/oracle/flash_recovery_area/ORCL/backupset/2017_11_15/o1_mf_ncsnf_TAG20171115T223737_f0rncn59_.bkp tag=TAG20171115T223737 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 15-NOV-17
    RMAN>

    RMAN> backup as compressed backupset database; #压缩全备

  • 相关阅读:
    Android SDCard操作(文件读写,容量计算)
    weibo4
    weibo5
    android源码结构分析
    后台退出事件
    获取服务器和客户端信息
    vs2008破解升级
    禁止所有蜘蛛
    页面的回发与回传
    显示上一条新闻 下一条新闻
  • 原文地址:https://www.cnblogs.com/lei2017/p/7841406.html
Copyright © 2011-2022 走看看