#!/bin/sh
backupdatedb()
{
ssh $remoteIp "mkdir /opt/oracle/exp_dp/;chown oracle:oinstall /opt/oracle/exp_dp -R" 2>/dev/null
ssh $remoteIp "
su - oracle -c \"
sqlplus -s /\"\" as sysdba <<ef
create directory exp_dp as '/opt/oracle/exp_dp';
grant read,write on directory exp_dp to user;
ef
\"
"
ssh $remoteIp "
su - oracle -c \"
expdp user/user@user schemas=user directory=exp_dp dumpfile=expdp_cqgdjk.dmp logfile=expdp_cqgda.log
\"
"
return 0
}
remoteIp=`grep DB file |awk -F ' ' '{print $2}'|tr -d ' '`
echo "get remoteId is $remoteIp" > db.log
echo "begin to backupdate db" >> db.log
backupdatedb
echo "backup db success and bgein to update db" >> db.log
scp update.sql $remoteIp:/home/oracle/
ssh $remoteIp "chown oracle:oinstall /home/oracle/update.sql"
ssh $remoteIp "
su - oracle -c \"
sqlplus -s user/\"user\" <<ef
@update.sql
ef
\"
"
shell脚本远程升级数据库
最新推荐文章于 2024-04-19 18:28:53 发布