• oracle—数据泵及常用参数



    -- 1.创建目录dump
    create or replace directory dump as '/home/oracle/dump';

    -- 2.授权:
    Grant read,write on directory dump to dissuser;

    -- 3.导出
    expdp userid=hbyz/hbyz_20161212 schemas=hbyz directory=dump dumpfile=HB135_RT.dmp logfile=hbyz135_RT.log parfile='/home/oracle/dump/pra.txt' cluster=N;
    注:
    -- cluster=N; RAC多节点时使用;并且有时候需要去掉 @oracle_sid
    -- compression=ALL
    -- dumpfile=HBYZ135_FULL_%U.dmp logfile=HBYZ135_FULL_%U.dmp parallel=8;
    -- parfile='/home/oracle/dump/pra.txt' : --pra文件:
    include=table:"in(select table_name from tabs where
    table_name in(
    'VE_VEHICLE','SYS_ORGANIZE'
    ))"


    -- 4.导入
    impdp userid=tmisuser/tmispass@tmis remap_schema=hbyz:tmisuser directory=dump dumpfile=HB135_RT.dmp table_exists_action=replace logfile=impdp_RT.log;

    注:
    --table_exists_action选项:
    {skip 是如果已存在表,则跳过并处理下一个对象;
    append是为表增加数据;
    truncate是截断表,然后为其增加新数据;
    replace是删除已存在表,重新建表并追加数据}

    -- TRANSFORM=DISABLE_ARCHIVE_LOGGING:Y
    减少impdp导入时 TABLE/INDEX产生的redo,注意这仅仅是减少不是禁绝。
    不管是非归档还是归档情况下使用DISABLE_ARCHIVE_LOGGING都会减小导入时间,减少归档量,
    但是需要注意如果数据库是force logging情况下,DISABLE_ARCHIVE_LOGGING参数会无效。

    --添加自动备份

    [root@gnss-3 gnss]# chown oracle:dba -R /backup/
    [oracle@gnss-3 gnss]$ sqlplus / as sysdba
    SQL> alter session set container=gnss;
    SQL> create or replace directory dumpback_gnss as '/backup/gnss/';           
    SQL> Grant read,write on directory dumpback_gnss to gnssuser;
    
    [oracle@gnss-3 gnss]$ vim backupexpdp_gnss.sh
    
    #!/bin/bash
    
    echo "*****setting the env*****"
    export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
    export ORACLE_OWNER=orclcdb
    export ORACLE_SID=gnss
    export ORACLE_BASE=/home/oracle/app
    export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
    
    echo  "*****start deleting data *****"
    find /backup/gnss/ -mtime +5 -type f | xargs rm -rf
    
    for username in gnssuser
    do
    export DATE=`date +%Y%m%d%H%M`
    echo "*****start exporting ${username}'s object*****"
    /home/oracle/app/product/12.2.0/db_1/bin/expdp gnssuser/gnsspass@gnss directory=dumpback_gnss dumpfile=gnss\_$DATE.dmp SCHEMAS=${username} logfile=expdp_gnss_$DATE.log compression=all
    #echo "*****start compressing ${username}'s object*****"
    #gzip /backup/gnss/gnss_$DATE_*.dmp
    done
    
    
    --添加执行权限
    [oracle@gnss-3 gnss]$ chmod u+x backupexpdp_gnss.sh
    
    --添加定时任务,每天8点执行:
    [oracle@gnss-3 gnss]$ crontab -e
    
    [oracle@gnss-3 gnss]$ crontab -l
    0 8 * * * /backup/gnss/backupexpdp_gnss.sh
  • 相关阅读:
    Lc112_路径总和
    多线程(4)
    Lc257_二叉树的所有路径
    Lc226_翻转二叉树
    Lc145_二叉树的后序遍历
    Lc144_二叉树的前序遍历
    Lc102_二叉树的层序遍历
    Lc101_对称二叉树
    Lc100_相同的树
    Lc94_二叉树的中序遍历
  • 原文地址:https://www.cnblogs.com/ZHUJIBlogs/p/8250785.html
Copyright © 2020-2023  润新知