이 섹션의 스크립트를 사용하여 Oracle Fusion Cloud Enterprise Performance Management 환경에 대한 최신 스냅샷 라이브러리를 유지관리하는 셀프 서비스 솔루션을 생성합니다. 최신 스냅샷 라이브러리를 업그레이드하고 유지관리하기 위한 전용 환경이 필요합니다.
Cloud EPM에서는 하나의 월별 주기 동안만 스냅샷 호환성을 지원합니다. 유지관리 스냅샷을 테스트 환경에서 프로덕션 환경으로 마이그레이션하거나 그 반대로 마이그레이션할 수 있습니다. 일부 고객은 감사 요구사항을 충족하기 위해 최신 환경에서 여러 연도의 스냅샷을 복원하고 짧은 시간 안에 애플리케이션에 액세스해야 할 수도 있습니다.
매월 한 번 실행되어 사용가능한 스냅샷을 변환하고 최신 Cloud EPM 패치 레벨과 호환되게 만들도록 이 스크립트를 스케줄링해야 합니다. 스크립트를 매월 세번째 금요일 이후 실행하여 프로덕션 환경 내 모든 이슈가 해결되었는지 확인하는 것이 좋습니다.
주:
이 스크립트를 사용하여 Narrative Reporting, Account Reconciliation, Oracle Fusion Cloud Enterprise Data Management 스냅샷을 업데이트할 수는 없습니다.
스크립트 작동 방법
업그레이드 스크립트는 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) 내에 현재 Cloud EPM 패치 레벨과 호환되도록 변환하려는 월별 스냅샷용 하위 디렉토리를 생성합니다. YY.MM 형식을 사용하여 디렉토리 이름을 지정합니다. 예를 들어 2018년 5월 스냅샷을 저장할 디렉토리의 이름으로 18.05를 지정합니다.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 네트워크 환경에서 authentication at proxy server이 사용으로 설정되어 있지 않으면 proxyserverusername, proxyserverpassword 및 proxyserverdomain 등록정보를 input.properties 파일에서 제거하십시오.
표 3-9 input.properties 매개변수
| 매개변수 | 설명 |
|---|---|
username |
서비스 관리자.의 사용자 이름 |
userpassword |
서비스 관리자의 비밀번호입니다. |
serviceurl |
이 활동에 사용되는 환경의 URL입니다. |
proxyserverusername |
인터넷에 대한 액세스를 제어하는 프록시 서버를 통해 보안 세션을 인증할 사용자 이름입니다. |
proxyserverpassword |
프록시 서버를 통해 사용자를 인증할 비밀번호입니다. |
proxyserverdomain |
프록시 서버에 대해 정의된 도메인의 이름입니다. |
parentsnapshotdirectory |
처리할 스냅샷을 저장하는 디렉토리의 상위 디렉토리로 사용할 디렉토리의 절대 경로입니다. 슬래시(/)를 디렉토리 구분 문자로 사용합니다. |
emailtoaddress |
선택사항으로, 이전 환경 재생성 결과를 보낼 전자메일 주소입니다. 이 값이 지정된 경우에만 결과를 전자메일로 보냅니다.
예: |
주:
비밀번호에 특수 문자가 포함된 경우 특수 문자 처리를 참조하십시오.
upgradeSnapshots.ps1 생성
다음 샘플 스크립트를 사용하여 upgradeSnapshots.ps1을 생성하십시오.
# Script for recreating an old Cloud EPM 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 Cloud EPM Environment results" Body="The results of recreating an old Cloud EPM 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 생성
주:
네트워크가 프록시 서버를 사용하여 인터넷에 액세스하도록 구성되어 있지 않으면 proxyserverusername, proxyserverpassword 및 proxyserverdomain 등록정보를 input.properties 파일에서 제거하십시오.
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-10 input.properties 매개변수
| 매개변수 | 설명 |
|---|---|
username |
서비스 관리자.의 사용자 이름 |
userpassword |
서비스 관리자의 비밀번호입니다. |
serviceurl |
이 활동에 사용되는 환경의 URL입니다. |
proxyserverusername |
인터넷에 대한 액세스를 제어하는 프록시 서버를 통해 보안 세션을 인증할 사용자 이름입니다. |
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 Cloud EPM Environment results" Body="The results of recreating an old Cloud EPM 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