使用本节中的脚本可创建自助服务解决方案以维护 Oracle Enterprise Performance Management Cloud 环境的最新快照库。您需要有一个环境,专门用来升级和维护最新快照库。
EPM 云仅支持在一个每月周期内快照具有兼容性;您可将维护快照从测试环境迁移到生产环境,也可以执行相反的迁移。但是,某些客户的审核要求可能需要在最新环境中还原多年的快照并在短期内访问应用程序。
应将此脚本计划为每月运行一次,以转换可用快照,并使其与最新的 EPM 云修补程序级别兼容。Oracle 建议您在当月第三个星期五之后运行该脚本,以确保生产环境中的所有问题均已解决。
注:
您不能使用此脚本更新 Narrative Reporting、Account Reconciliation 和 Oracle Enterprise Data Management Cloud 快照。
脚本的工作原理
对于客户存储的每个快照,升级脚本都会使用 EPM Automate 完成以下任务:input.properties
文件中的信息登录到环境中recreate
命令刷新环境Artifact Snapshot
(维护快照)下载到一个文件夹中。如果通过从 snapshots/18.05
上传快照重新创建了 18.05 环境,Artifact Snapshot
将下载到 snapshots/18.06
中。重新运行该脚本
input.properties
文件,并使用环境信息进行相应的更新。将该文件保存到一个本地目录。在本次讨论中,此目录名为 parentsnapshotdirectory
。此文件的内容因操作系统的不同而异。
请确保您对此目录具有写权限。对于 Windows,您可能需要使用以管理员身份运行选项启动 PowerShell,以便能够运行脚本。
upgradeSnapshots.ps1
(Windows PowerShell) 或 upgradeSnapshots.sh
(Linux/UNIX) 脚本,并将其保存到 input.properties
所在的 parentsnapshotdirectory
中。parentsnapshotdirectory
中创建一个子目录,例如 snapshots
。snapshots
) 中创建一个子目录,用它来存储您希望进行转换以与当前 EPM 云修补程序级别相兼容的每月快照。使用 YY.MM
格式命名该目录;例如,目录 18.05
用于存储 2018 年 5 月的快照。snapshots/18.05
。./upgradeSnapshots.sh
。upgradeSnapshots.ps1
。Windows
通过复制本节中的脚本,创建 input.properties
和 upgradeSnapshots.ps1
脚本。
创建 input.properties
username=exampleAdmin userpassword=examplePassword serviceurl=exapleURL proxyserverusername=proxyServerUserName proxyserverpassword=proxyPassword proxyserverdomain=proxyDoamin parentsnapshotdirectory=C:/some_directory/snapshots emailtoaddress=exampleAdmin@oracle.com
更新 input.properties
注:
如果您未在 Windows 网络环境中启用通过代理服务器进行身份验证
,请从 input.properties
文件中删除属性 proxyserverusername
、proxyserverpassword
和 proxyserverdomain
。
表 3-8 input.properties 参数
参数 | 说明 |
---|---|
username |
服务管理员的用户名。 |
userpassword |
服务管理员的密码。 |
serviceurl |
用于执行此活动的环境的 URL。 |
proxyserverusername |
使用具有 Internet 访问控制权的代理服务器对安全会话进行身份验证的用户名。 |
proxyserverpassword |
用于在代理服务器中对用户进行身份验证的密码。 |
proxyserverdomain |
为代理服务器定义的域的名称。 |
parentsnapshotdirectory |
用于存储待处理快照的目录的父目录的绝对路径。请使用正斜杠 (/) 作为目录分隔符。 |
emailtoaddress |
(可选)要将重新创建旧环境的结果发送到的电子邮件地址。仅当指定此值时,才会通过电子邮件发送结果。
示例: |
注:
如果密码中包含特殊字符,请参阅“处理特殊字符”。
创建 upgradeSnapshots.ps1
使用此示例脚本创建 upgradeSnapshots.ps1
# Script for recreating an old EPM Cloud environment # read in key/value pairs from input.properties file $inputproperties=ConvertFrom-StringData(Get-Content ./input.properties -raw) # Global variables $parentsnapshotdirectory="$($inputproperties.parentsnapshotdirectory)" $username="$($inputproperties.username)" $userpassword="$($inputproperties.userpassword)" $serviceurl="$($inputproperties.serviceurl)" $proxyserverusername="$($inputproperties.proxyserverusername)" $proxyserverpassword="$($inputproperties.proxyserverpassword)" $proxyserverdomain="$($inputproperties.proxyserverdomain)" $emailtoaddress="$($inputproperties.emailtoaddress)" $operationmessage="EPM Automate operation:" $operationfailuremessage="EPM Automate operation failed:" $operationsuccessmessage="EPM Automate operation completed successfully:" $epmautomatescript="epmautomate.bat" $workingdir="$pwd" $logdir="$workingdir/logs/" $logfile="$logdir/epmautomate-upgradesnapshots.log" function LogMessage { $message=$args[0] $_mydate=$(get-date -f dd_MM_yy_HH_mm_ss) echo "[$_mydate] $message" >> $logfile } function LogAndEchoMessage { $message=$args[0] $_mydate=$(get-date -f dd_MM_yy_HH_mm_ss) echo "[$_mydate] $message" | Tee-Object -Append -FilePath $logfile } function LogOutput { $_mydate=$(get-date -f dd_MM_yy_HH_mm_ss) $op=$args[0] $opoutput=$args[1] $returncode=$args[2] #If error if ($returncode -ne 0) { $failmessage="[$_mydate] $operationfailuremessage $op" LogMessage $failmessage LogMessage $opoutput LogMessage "return code: $returncode" } else { $successmessage="[$_mydate] $operationsuccessmessage $op" LogMessage $successmessage LogMessage $opoutput LogMessage "return code: $returncode" } } function ExecuteCommand { $op=$args[0] $epmautomatecall="$epmautomatescript $op" $date=$(get-date -f dd_MM_yy_HH_mm_ss) LogMessage "$operationmessage $epmautomatecall" $operationoutput=iex "& $epmautomatecall" >> $logfile 2>&1 LogOutput $op $operationoutput $LastExitCode } function ProcessCommand { $command=$args[0] $date=$(get-date -f dd_MM_yy_HH_mm_ss) if (!([string]::IsNullOrWhitespace($command))) { if (!($command.StartsWith("#"))) { ExecuteCommand $command } } } function Init { $logdirexists=Test-Path $logdir if (!($logdirexists)) { mkdir $logdir 2>&1 | out-null } # removing existing epmautomate debug logs rm ./*.log $logfileexists=Test-Path $logfile # remove existing log file if ($logfileexists) { rm $logfile } } function GetNextDate { $latestyearmonth=$args[0] LogMessage "latest year.month: $latestyearmonth" $latestyear,$latestmonth=$latestyearmonth.split('\.') LogMessage "latest year: $latestyear" LogMessage "latest month: $latestmonth" $intlatestyear=[int]$latestyear $intlatestmonth=[int]$latestmonth if ($intlatestmonth -eq 12) { $intnextmonth=1 $intnextyear=$intlatestyear+1 } else { $intnextmonth=$intlatestmonth+1 $intnextyear=$intlatestyear } $nextyear="{0:D2}" -f $intnextyear $nextmonth="{0:D2}" -f $intnextmonth echo "$nextyear.$nextmonth" } function ProcessSnapshot { $snapshotfile=$args[0] LogMessage "snapshotfile: $snapshotfile" $nextdate=$args[1] LogMessage "nextdate: $nextdate" $snapshotfilename=$snapshotfile.split('/')[-1] LogMessage "snapshotfilename: $snapshotfilename" $snapshotname=$snapshotfilename.split('.')[0] LogMessage "snapshotname: $snapshotname" ProcessCommand "login $username $userpassword $serviceurl $proxyserverusername $proxyserverpassword $proxyserverdomain" ProcessCommand "recreate -f" ProcessCommand "uploadfile $snapshotfile" ProcessCommand "importsnapshot $snapshotname" ProcessCommand "runDailyMaintenance skipNext=true -f" ProcessCommand "downloadfile 'Artifact Snapshot'" ProcessCommand "deletefile $snapshotname" ProcessCommand "logout" $nextdatedirexists=Test-Path $parentsnapshotdirectory/$nextdate if (!($nextdatedirexists)) { mkdir $parentsnapshotdirectory/$nextdate 2>&1 | out-null } LogMessage "Renaming 'Artifact Snapshot.zip' to $snapshotname.zip and moving to $parentsnapshotdirectory/$nextdate" mv $workingdir/'Artifact Snapshot.zip' $workingdir/$snapshotname.zip >> $logfile 2>&1 mv $workingdir/$snapshotname.zip $parentsnapshotdirectory/$nextdate >> $logfile 2>&1 } function callSendMail { $logfile=$logfile -replace "\\", "/" $elements=$logfile.split('/') $logfilename=$elements[-1] if (${emailtoaddress} -match "@") { epmautomate.bat login ${username} ${userpassword} ${serviceurl} epmautomate.bat uploadFile "$logfile" epmautomate.bat sendMail $emailtoaddress "Recreating An Old EPM Cloud Environment results" Body="The results of recreating an old EPM Cloud Environment are attached." Attachments=$logfilename epmautomate.bat deleteFile "$logfilename" epmautomate.bat logout } } #----- main body of processing date Init LogAndEchoMessage "Starting upgrade snapshots processing" $snapshotdirs=@(Get-ChildItem -Directory "$parentsnapshotdirectory" -name) LogMessage "snapshot directories: $snapshotdirs" $latestreleasedate=$snapshotdirs[-1] LogMessage "latest release date: $latestreleasedate" $latestreleasesnapshotdir="$parentsnapshotdirectory/$latestreleasedate" LogMessage "latest release snapshot dir: $latestreleasesnapshotdir" $nextdate=$(GetNextDate "$latestreleasedate") $snapshotfiles=@(Get-ChildItem -File "$latestreleasesnapshotdir") if ($snapshotfiles.length -eq 0) { LogAndEchoMessage "No snapshot files found in directory $latestreleasesnapshotdir. Exiting script." exit } foreach ($snapshotfile in $snapshotfiles) { LogAndEchoMessage "Processing snapshotfile: $snapshotfile" ProcessSnapshot $latestreleasesnapshotdir/$snapshotfile $nextdate } LogAndEchoMessage "Upgrade snapshots processing completed" date callSendMail
Linux/UNIX
通过复制以下脚本来创建 upgradeSnapshots.sh
和 input.properties
。
为 Linux/UNIX 创建 input.properties
注:
如果您的网络未配置为使用代理服务器来访问 Internet,请从文件 input.properties
中删除 proxyserverusername
、proxyserverpassword
和 proxyserverdomain
属性。
username=exampleAdmin userpassword=examplePassword serviceurl=exapleURL proxyserverusername= proxyserverpassword= proxyserverdomain= jdkdir=/home/user1/jdk160_35 epmautomatescript=/home/exampleAdmin/epmautomate/bin/epmautomate.sh parentsnapshotdirectory=/home/exampleAdmin/some_directory/snapshots emailtoaddress=exampleAdmin@oracle.com
更新 input.properties
表 3-9 input.properties 参数
参数 | 说明 |
---|---|
username |
服务管理员的用户名。 |
userpassword |
服务管理员的密码。 |
serviceurl |
用于执行此活动的环境的 URL。 |
proxyserverusername |
使用具有 Internet 访问控制权的代理服务器对安全会话进行身份验证的用户名。 |
proxyserverpassword |
用于在代理服务器中对用户进行身份验证的密码。 |
proxyserverdomain |
为代理服务器定义的域的名称。 |
jdkdir |
JAVA_HOME 位置。 |
epmautomatescript |
EPM Automate 可执行文件 (epmautomate.sh ) 的绝对路径。 |
parentsnapshotdirectory |
用于存储待处理快照的目录的父目录的绝对路径。 |
emailtoaddress |
(可选)要将重新创建旧环境的结果发送到的电子邮件地址。 |
注:
如果密码中包含特殊字符,请参阅“处理特殊字符”。
创建 upgradeSnapshots.sh
使用此示例脚本创建 upgradeSnapshots.sh
#!/bin/sh . ./input.properties workingdir=$(pwd) logdir="${workingdir}/logs" logfile=epmautomate-upgradesnapshots.log operationmessage="EPM Automate operation:" operationfailuremessage="EPM Automate operation failed:" operationsuccessmessage="EPM Automate operation completed successfully:" logdebugmessages=true if [ ! -d ${jdkdir} ] then echo "Could not locate JDK/JRE. Please set value for "jdkdir" property in input.properties file to a valid JDK/JRE location." exit fi if [ ! -f ${epmautomatescript} ] then echo "Could not locate EPM Automate script. Please set value for "epmautomatescript" property in the input.properties file." exit fi export JAVA_HOME=${jdkdir} debugmessage() { # logdebugmessages is defined (or not) in testbase input.properties if [ "${logdebugmessages}" = "true" ] then logmessage "$1" fi } logmessage() { local message=$1 local _mydate=$(date) echo "[$_mydate] ${message}" >> "$logdir/$logfile" } echoandlogmessage() { local message=$1 local _mydate=$(date) echo "[$_mydate] ${message}" | tee -a ${logdir}/${logfile} } logoutput() { date=`date` op="$1" opoutput="$2" returncode="$3" #If error #if grep -q "EPMAT-" <<< "$2" if [ $returncode -ne 0 ] then failmessage="[${date}] ${operationfailuremessage} ${op}" logmessage "${failmessage}" logmessage "${opoutput}" logmessage "return code: ${returncode}" else successmessage="${operationsuccessmessage} ${op}" logmessage "${successmessage}" logmessage "${opoutput}" logmessage "return code: ${returncode}" fi } getLatestReleaseSnapshotDir() { local snapshotdirs=$(find ${parentsnapshotdirectory} -type d | sort) debugmessage "snapshot directories: ${snapshotdirs}" local latestreleasesnapshotdir=$(echo ${snapshotdirs##*$\n} | rev | cut -d' ' -f1 | rev) debugmessage "latest release snapshot dir: ${latestreleasesnapshotdir}" echo "${latestreleasesnapshotdir}" } getNextDate() { local thisyearmonth=$1 local thisyear=$(echo ${thisyearmonth} | cut -d'.' -f1) local thismonth=$(echo ${thisyearmonth} | cut -d'.' -f2) intthismonth=$(bc <<< ${thismonth}) intthisyear=$(bc <<< ${thisyear}) if [ ${intthismonth} -eq 12 ] then local intnextmonth=1 local intnextyear=$((intthisyear+1)) else local intnextmonth=$((intthismonth+1)) local intnextyear=${intthisyear} fi nextmonth=$(printf "%02d\n" ${intnextmonth}) nextyear=$(printf "%02d\n" ${intnextyear}) debugmessage "next date: ${nextyear}.${nextmonth}" echo "${nextyear}.${nextmonth}" } init() { if [ ! -d "$logdir" ] then mkdir $logdir fi # removing existing epmautomate debug logs if ls ./*.log >/dev/null 2>&1 then rm ./*.log fi # remove existing log files if [ -f "${logdir}/${logfile}" ] then rm ${logdir}/${logfile} fi } processCommand() { op="$1" date=`date` logmessage "$operationmessage $op" operationoutput=`eval "$epmautomatescript $op"` logoutput "$op" "$operationoutput" "$?" } processSnapshot() { local snapshotfile="$1" local nextdate="$2" local snapshotname=$(echo "${snapshotfile}" | rev | cut -d'/' -f1 | rev | cut -d'.' -f1) processCommand "login ${username} ${userpassword} ${serviceurl} ${proxyserverusername} ${proxyserverpassword}" processCommand "recreate -f" processCommand "uploadfile ${snapshotfile}" processCommand "importsnapshot \"${snapshotname}\"" processCommand "runDailyMaintenance skipNext=true -f" processCommand "downloadfile \"Artifact Snapshot\"" processCommand "deletefile \"${snapshotname}\"" processCommand "logout" if [ ! -d ${parentsnapshotdirectory}/${nextdate} ] then mkdir ${parentsnapshotdirectory}/${nextdate} fi runDailyMaintenance -f logmessage "Renaming \"Artifact Snapshot.zip\" to ${snapshotname}.zip and moving to ${parentsnapshotdirectory}/${nextdate}" mv "${workingdir}/Artifact Snapshot.zip" "${workingdir}/${snapshotname}.zip" >> "$logdir/$logfile" 2>&1 mv "${workingdir}/${snapshotname}.zip" ${parentsnapshotdirectory}/${nextdate} >> "$logdir/$logfile" 2>&1 } callSendMail() { if [[ "${emailtoaddress}" == *"@"* ]] then ${epmautomatescript} login ${username} ${userpassword} ${serviceurl} ${epmautomatescript} uploadFile "$logdir/$logfile" ${epmautomatescript} sendMail $emailtoaddress "Recreating An Old EPM Cloud Environment results" Body="The results of recreating an old EPM Cloud Environment are attached" Attachments=$logfile ${epmautomatescript} deleteFile "$logfile" ${epmautomatescript} logout fi } #----- main body of processing date echoandlogmessage "Starting upgrade snapshots processing" init latestreleasesnapshotdir=$(getLatestReleaseSnapshotDir) latestreleasedate=$(echo "${latestreleasesnapshotdir}" | rev | cut -d'/' -f1 | rev) debugmessage "latest release date: ${latestreleasedate}" nextdate=$(getNextDate ${latestreleasedate}) snapshotfiles=$(find ${latestreleasesnapshotdir} -type f -name \*.zip | tr "\n" "|") if [ ${#snapshotfiles} -eq 0 ] then echoandlogmessage "No snapshot files found in directory ${latestreleasesnapshotdir}" fi IFS="|" for snapshotfile in $snapshotfiles do echoandlogmessage "Processing snapshotfile: ${snapshotfile}" processSnapshot ${snapshotfile} ${nextdate} done unset IFS echoandlogmessage "Upgrade snapshots processing completed." callSendMail