Oracle冷備遷移指令碼 檔案系統

2021-09-06 23:27:58 字數 1973 閱讀 6553

oracle冷備遷移指令碼(檔案系統)

兩個指令碼:

配置檔案生成指令碼dbinfo.sh

網路拷貝到目標伺服器的指令碼cpdb16.sh

#!/bin/bash

#usage: create db.config file which includes datafile,tempfile,controlfile and logfile.

#you need reset these environment variables: $oracle_sid $oracle_base $oracle_home $path

#ex: sh dbinfo.sh

#author: alfred zhao

#vertion: 1.0.0

#env

oracle_sid="jyzhao"

#export

export oracle_sid=$oracle_sid

export oracle_base=$oracle_base

export oracle_home=$oracle_home

export path=$path

#create db.config

sqlplus / as sysdba set linesize 200 pagesize 8888

select name from v\$datafile union all

select name from v\$tempfile union all

select name from v\$controlfile union all

select member from v\$logfile;

eofcat /tmp/dbtemp.config | grep / > /tmp/db.config

rm -f /tmp/dbtemp.config

注:需要根據你實際環境配置對應的環境變數。

執行上述指令碼生成配置檔案/tmp/db.config

#!/bin/bash

#usage: copy db files after db shutdown immediate!! ssh login without password is needed.

#you need redefine these variables:$ip $destination

#ex: nohup sh cpdb16.sh &

#author: alfred zhao

#version: 1.0.0

#define variables

ip="192.168.9.149"

destination="/var/run/sr-mount/df66f479-3da0-05cc-210c-00bc9c5a65cc/db16/"

#scp

while read line

do scp $line $ip:$destination

done < /tmp/db.config

注:這裡scp需要配置ssh無密碼登入才可以後台執行。

ssh無密碼登入配置可參考:

# ps -ef | grep cpdb | grep -v grep 

root 31638 1 0 16:39 ? 00:00:00 sh cpdb16.sh

# ps -ef | grep scp | grep -v grep

root 31640 31639 14 16:39 ? 00:01:00 /usr/bin/ssh -x -oforwardagent no -opermitlocalcommand no -oclearallforwardings yes 192.168.9.149 scp -t /var/run/sr-mount/df66f479-3da0-05cc-210c-00bc9c5a65cc/db16/

oracle 冷備和熱備指令碼

指令碼放在 u01 scripts coldscr mikecold.sql 在資料庫執行時可以執行此指令碼來冷備。set feedback off set heading off set verify off set trimspool off set echo off settime offse...

Oracle資料庫冷備遷移

資料庫伺服器 linux6.5 oracle11.2.0.4 單例項 資料庫的例項名 arorcl 目的 從192.168.20.27 資料庫例項遷移到192.168.20.16上 要求系統一樣,資料庫版本一樣 show parameter spfile show parameter control...

ORACLE冷備檔案恢復

1 恢復資料庫服務 oradim delete sid hdqtls 刪除資料庫服務 oradim new sid hdqtls startmode a syspwd future pfile d data pfile init.ora 建立資料庫服務 2 啟動資料庫到mount狀態,修改資料檔案位...