E9.2 JDE WEB servers start using command line/script

jhanna924

jhanna924

Member
Hello,
I am currently working on migrating our JDE from on premises to AWS cloud, we are looking for a solution where we can shut down our JDE instances during none working hour that way we can cut down on cost.
In order to perform that we are required to come up with a solution to automatically start the setup.
We are using JDE 9.2 on Oracle linux, and we were successfully able to start the DB and ENT servers using automation.
My question is, is there a way to automate starting the servers in JDE WebLogic console? Are there any commands we can use to achieve that? image (9).png
 
Weblogic has a lot of scripts to play with, for example these here:
Bash:
/u01/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh
/u01/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/bin/startManagedWebLogic.sh

Or you could put CrashRecoveryEnabled=true into /u01/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/nodemanager/nodemanager.properties and it will start everything that was started when you shut down.
 
Weblogic has a lot of scripts to play with, for example these here:
Bash:
/u01/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh
/u01/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/bin/startManagedWebLogic.sh

Or you could put CrashRecoveryEnabled=true into /u01/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/nodemanager/nodemanager.properties and it will start everything that was started when you shut down.
Yes, using startManagedWebLogic.sh with the server name that we want to start did the trick
Thank you!
 
Here's an alternative to start/stop WLS managed instances using PowerShell and WLS RESTful Management Services.

# '*************************************************************************
# ' Script: WLS_DLV01ProductionStart_v2.ps1
# ' Desc.: PowerShell workflow that starts DLV01 Production WLS servers
# '*************************************************************************

#
# Start Managed Servers
#
# Function to send out email notifications
Function sendNotification {
Param ($Subject, $Body)
Send-MailMessage -To '[email protected]' `
-From '[email protected]' `
-SMTPServer smtp.company.com `
-Subject $Subject `
-Body $Body
}


# Start managed servers on SERVER01
#
$WLSserver = "SERVER01"
$timeStamp = (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Starting managed servers on" $WLSserver "if shutdown."
# Array of managed servers
$servers = @()
# URL to WLS AdminServer RESTful Management Interface
$uriGlobal = ' '
# Build standard request headers
$headersGlobal = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headersGlobal.Add("Authorization", 'Basic ')
$headersGlobal.
Add("Content-Type", 'application/json')
$headersGlobal.
Add("Accept", 'application/json')
$headersGlobal.
Add("X-Requested-By", 'MyClient')
$headersGlobal.
Add("Prefer", 'respond-async')
# Populate array with managed servers
$servers += "J2EE_PD920_9001"
$servers += "J2EE_PD920_9002"
# Main processing
foreach ($server in $servers) {
# Check state of server
$paramsCheck = @{
ContentType = 'application/json'
Method = 'GET'
Headers = $headersGlobal
URI = $uriGlobal + $server + "?fields=state&links=none"
}
try {
$timeStamp
= (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Checking state of server" $server"."
$responseCheck = Invoke-RestMethod @paramsCheck -TimeoutSec 60
# Check response for state
switch -wildcard ($responseCheck) {
"*SHUTDOWN*" {
# Server state is SHUTDOWN. Start server.
$timeStamp = (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Server state is SHUTDOWN. Starting server" $server"."
$paramsAction = @{
Headers = $headersGlobal
Uri = $uriGlobal + $server + "/start"
}
$bodyAction
= "{}"
try {
$responseAction
= Invoke-RestMethod @paramsAction -Method Post -Body $bodyAction -TimeoutSec 300
$timeStamp = (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Server" $server "started."
} catch {
$timeStamp
= (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Automation: Error starting $server on $WLSserver." $_
sendNotification "Automation: Error starting $server on $WLSserver." $_
}
break
}

"*FAILED*" {
# Server state is FAILED. Start server.
$timeStamp = (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Server state is FAILED. Starting server" $server"."
$paramsAction = @{
Headers = $headersGlobal
Uri = $uriGlobal + $server + "/start"
}
$bodyAction
= "{}"
try {
$responseAction
= Invoke-RestMethod @paramsAction -Method Post -Body $bodyAction -TimeoutSec 300
$timeStamp = (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Server" $server "started."
} catch {
$timeStamp
= (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Automation: Error starting $server on $WLSserver." $_
sendNotification "Automation: Error starting $server on $WLSserver." $_
}
break
}

"*RUNNING*" {
$timeStamp
= (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Server state is already RUNNING."
break
}

default {
break
}
}
}
catch {
$timeStamp
= (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Automation: Error checking state of $server on $WLSserver." $_
sendNotification "Automation: Error checking state of $server on $WLSserver." $_
}
}



# '*************************************************************************
# ' Script: WLS_DLV01ProductionStop_v2.ps1
# ' Desc.: PowerShell workflow that stops DLV01 Production WLS servers
# '*************************************************************************

#
# Stop managed instances
#
# Function to send out email notifications
Function sendNotification {
Param ($Subject, $Body)
Send-MailMessage -To '[email protected]' `
-From '[email protected]' `
-SMTPServer smtp.company.com `
-Subject $Subject `
-Body $Body
}


# Stop managed instances on SERVER01
#
$WLSserver = "SERVER01"
$timeStamp = (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Stopping managed servers on" $WLSserver "if running."
# Array of managed servers
$servers = @()
# URL to WLS AdminServer RESTful Management Interface
$uriGlobal = ' '
# Build standard request headers
$headersGlobal = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headersGlobal.Add("Authorization", 'Basic ')
$headersGlobal.
Add("Content-Type", 'application/json')
$headersGlobal.
Add("Accept", 'application/json')
$headersGlobal.
Add("X-Requested-By", 'MyClient')
$headersGlobal.
Add("Prefer", 'respond-async')
# Populate array with managed instances
$servers += "J2EE_PD920_9001"
$servers += "J2EE_PD920_9002"
# Main processing
foreach ($server in $servers) {
# Check state of server
$paramsCheck = @{
ContentType = 'application/json'
Method = 'GET'
Headers = $headersGlobal
URI = $uriGlobal + $server + "?fields=state&links=none"
}
try {
$timeStamp
= (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Checking state of server" $server"."
$responseCheck = Invoke-RestMethod @paramsCheck -TimeoutSec 60
# Check response for state
switch -wildcard ($responseCheck) {
"*RUNNING*" {
# Server state is RUNNING. Stop server.
$timeStamp = (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Server state is RUNNING. Stopping server" $server"."
$paramsAction = @{
Headers = $headersGlobal
Uri = $uriGlobal + $server + "/shutdown?force=true"
}
$bodyAction
= "{timeout: 180, ignoreSessions: true}"
try {
$responseAction
= Invoke-RestMethod @paramsAction -Method Post -Body $bodyAction -TimeoutSec 300
$timeStamp = (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Server" $server "stopped."
} catch {
$timeStamp
= (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Automation: Error stopping $server on $WLSserver." $_
sendNotification "Automation: Error stopping $server on $WLSserver." $_
}
break
}

"*SHUTDOWN*" {
$timeStamp
= (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Server state is already SHUTDOWN."
break
}

default {
break
}
}
}
catch {
$timeStamp
= (Get-Date).ToString("MM-dd-yyyy HH:mm:ss")
Write-Host $timeStamp "Automation: Error checking state of $server on $WLSserver." $_
sendNotification "Automation: Error checking state of $server on $WLSserver." $_
}
}
 
Back
Top