首页 技术 正文
技术 2022年11月18日
0 收藏 519 点赞 4,702 浏览 1835 个字

Oracle冷备迁移脚本(文件系统)

两个脚本:

  1. 配置文件生成脚本dbinfo.sh
  2. 网络拷贝到目标服务器的脚本cpdb16.sh

1. 配置文件生成脚本

#!/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"
ORACLE_BASE="/u01/app/oracle"
ORACLE_HOME="/u01/app/oracle/product/11.2.0/db_1"
PATH="/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin:/u01/app/oracle/product/11.2.0/db_1/bin:."#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 <<EOF > /tmp/dbtemp.config
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

2. 网络拷贝到目标服务器的脚本

#!/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无密码登录配置可参考:http://www.cnblogs.com/jyzhao/p/3781072.html

关注进程信息掌控迁移进度

“`
# 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 31639 31638 0 16:39 ? 00:00:03 scp /opt/app/oracle/trail/system01.dbf 192.168.9.149 /var/run/sr-mount/df66f479-3da0-05cc-210c-00bc9c5a65cc/db16/
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/
“`

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,953
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,477
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,290
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,107
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,739
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,773