91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle 自動化備份腳本

發布時間:2020-07-08 07:54:10 來源:網絡 閱讀:664 作者:hsbxxl 欄目:關系型數據庫

Oracle 日常RMAN備份腳本,很基礎。但是對于多個需要備份的Oracle數據庫,可以很簡單實施,并利于后期批量狀態的查詢。

  1. 備份腳本,基于linux,windows環境需要適當修改。
    主腳本,會調用2,3步驟的rman.sql&status.sql

    $ more main.sh
    #set env
    #########################Change the below parameter for the different server##################
    export host_ip=172.16.32.115
    export instance_name=liang
    export username=liang
    export password=liang
    export syspsw=oracle
    export backup_home=/home/oracle/bk
    export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
    export PATH=$PATH:$ORACLE_HOME/db_1/bin:/sbin:/usr/sbin
    #####################################################################################
    export curTime=$(date "+%Y%m%d")
    mkdir $backup_home/ftp/$curTime
    echo "-----------------------------RMAN start-----------------------------";date
    #backup start
    cd $backup_home
    $ORACLE_HOME/bin/rman target sys/$syspsw@$host_ip:1521/$instance_name cmdfile='rman.sql'
    echo "------------------------------RMAN End------------------------------";date
    sleep 10
    echo "------------------------------SQL Start------------------------------";date
    $ORACLE_HOME/bin/sqlplus $username/$password@$host_ip:1521/$instance_name @status.sql
    echo "------------------------------END-----------------------------";date
  2. RMAN備份sql腳本

    [oracle@test bk]$ more rman.sql
    run
    {
    ALLOCATE CHANNEL node_c1 DEVICE TYPE DISK MAXPIECESIZE=5G;
    ALLOCATE CHANNEL node_c2 DEVICE TYPE DISK MAXPIECESIZE=5G;
    backup as compressed backupset database format 'C:\ftp\uploadfile\db_%U.bak_%T';
    sql 'alter system switch logfile';
    CROSSCHECK ARCHIVELOG ALL;
    backup as compressed backupset archivelog all format 'C:\ftp\uploadfile\archivelog_%d_%s_%p_%T' not backed up 2 times;
    backup spfile format 'C:\ftp\uploadfile\spfile_%U_%T';
    backup current controlfile format 'C:\ftp\uploadfile\controlfile_%d_%s_%p_%I_%u_%T';
    sql 'alter system switch logfile';
    CROSSCHECK BACKUP;
    CROSSCHECK COPY;
    delete noprompt archivelog all completed before 'sysdate-7';
    release channel node_c1;
    release channel node_c2;
    }
  3. 查詢備份狀態的腳本,并將查詢信息打印到日志,方便查詢。
    $ more status.sql
    ----每日歸檔產生量,可以判斷數據庫是否繁忙
    spool $backup_home/redo_switch.log;
    set echo off
    set feedback off
    set colsep ','
    set pagesize 2000
    set term off
    set heading off
    set line 400
    col Count for 9999
    col GB for 99999
    select
    d.dbid,
    to_char(trunc(completion_time),'yyyy-mm-dd') as "Date"
    ,count(*) as "Count"
    ,substr((sum(blocks*block_size))/1024/1024/1024,0,4) as "GB"
    from v$archived_log,v$database d
    group by trunc(completion_time),d.dbid;
    spool off;
    ---查詢表空間使用率
    spool $backup_home/tablepace_usage.log;
    set echo off
    set feedback off
    set colsep ','
    set pagesize 2000
    set term off
    set heading off
    set line 400
    col startup_time for a20
    col status for a6
    col tablespace_name for a20
    col total_mb for 99999999
    col used_mb for 99999999
    col used_pct for a10
    select
    d.dbid,
    to_char(b.STARTUP_TIME,'yyyy-mm-dd-hh34-mi-ss') as startup_time,
    b.status,
    total.tablespace_name,
    round(total.MB, 2) as Total_MB,
    round(total.MB - free.MB, 2) as Used_MB,
    round((1 - free.MB / total.MB) * 100, 2) || '%' as Used_Pct
    from (select tablespace_name, sum(bytes) / 1024 / 1024 as MB
    from dba_free_space
    group by tablespace_name) free,
    (select tablespace_name, sum(bytes) / 1024 / 1024 as MB
    from dba_data_files
    group by tablespace_name) total, v$instance b, v$database d
    where free.tablespace_name = total.tablespace_name;
    spool off;
    --- 查看近7天備份情況
    spool /home/oracle/bk/log/rman.log;
    set echo off
    set feedback off
    set colsep ','
    set pagesize 2000
    set term off
    set heading off
    set line 202000
    col DBID for 9999999999
    col status for a25
    col type for a12
    col  start_time for a22
    col  Finish_time for a22
    col in_sec for a12
    col out_sec for a12
    col command for a8
    col  INPUT_M for 99999
    col  OUTPUT_M for 99999
    col obj_type for a15
    select d.DBID as DBID,
    s.status as status,
    b.INPUT_TYPE as type,
    to_char(b.START_TIME,'yyyy-mm-dd hh34:mi:ss') as start_time,
    to_char(b.end_time, 'yyyy-mm-dd hh34:mi:ss') as  Finish_time,
    b.INPUT_BYTES_PER_SEC_DISPLAY in_sec,
    b.OUTPUT_BYTES_PER_SEC_DISPLAY out_sec,
    s.OPERATION as command,
    trunc(s.INPUT_BYTES/1024/1024,2) as INPUT_M,
    trunc(s.OUTPUT_BYTES/1024/1024,2) as OUTPUT_M,
    s.OBJECT_TYPE as obj_type
    from v$rman_status s,v$rman_backup_job_details b, v$database d
    where to_char(s.START_TIME, 'yyyy-mm-dd hh34:mi:ss') < to_char(sysdate,'yyyy-mm-dd hh34:mi:ss')
    and to_char(s.END_TIME, 'yyyy-mm-dd hh34:mi:ss') > to_char(sysdate-7,'yyyy-mm-dd hh34:mi:ss')
    and s.COMMAND_ID=b.COMMAND_ID
    order by s.START_TIME desc ;
    spool off;
    exit;
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

洪泽县| 霸州市| 汝南县| 罗甸县| 左云县| 浦县| 招远市| 商南县| 金门县| 亚东县| 会宁县| 徐闻县| 聂荣县| 澄江县| 曲沃县| 五大连池市| 辽阳市| 高雄县| 上饶市| 云南省| 额济纳旗| 金阳县| 南京市| 汕尾市| 湘乡市| 太保市| 麦盖提县| 铜陵市| 成武县| 河源市| 邯郸县| 上思县| 赤水市| 南投县| 垦利县| 顺昌县| 鸡东县| 胶州市| 丰镇市| 夏河县| 额济纳旗|