Skip to content

Commit ea813ce

Browse files
committed
FSDR hyperion scripts
1 parent e221a6f commit ea813ce

File tree

14 files changed

+420
-0
lines changed

14 files changed

+420
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
Copyright (c) 2024 Oracle and/or its affiliates.
3+
4+
The Universal Permissive License (UPL), Version 1.0
5+
6+
Subject to the condition set forth below, permission is hereby granted to any
7+
person obtaining a copy of this software, associated documentation and/or data
8+
(collectively the "Software"), free of charge and under any and all copyright
9+
rights in the Software, and any and all patent rights owned or freely
10+
licensable by each licensor hereunder covering either (i) the unmodified
11+
Software as contributed to or provided by such licensor, or (ii) the Larger
12+
Works (as defined below), to deal in both
13+
14+
(a) the Software, and
15+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
one is included with the Software (each a "Larger Work" to which the Software
17+
is contributed by such licensors),
18+
19+
without restriction, including without limitation the rights to copy, create
20+
derivative works of, display, perform, and distribute the Software and make,
21+
use, sell, offer for sale, import, export, have made, and have sold the
22+
Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
either these or other terms.
24+
25+
This license is subject to the following condition:
26+
The above copyright notice and either this complete permission notice or at
27+
a minimum a reference to the UPL must be included in all copies or
28+
substantial portions of the Software.
29+
30+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36+
SOFTWARE.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Oracle Hyperion EPM System Full Stack Disaster Recovery scripts
2+
3+
This GitHub repository provides custom scripts that serve as a starting point for creating your own scripts to use with OCI Full Stack Disaster Recovery for Hyperion applications.
4+
5+
Included scripts:
6+
- start_services.ps1/sh - script to start all EPM System services, including WLS and OHS, on Windows (PowerShell) or Linux (Bash) compute
7+
- stop_services.ps1/sh - script to start all EPM System services, including WLS and OHS, on Windows (PowerShell) or Linux (Bash) compute
8+
- host_switch_failover.ps1/sh - script to update host file after switch to the standby region. Windows (PowerShell) or Linux (Bash).
9+
- host_switch_failback.ps1/sh - script to update host file after switch from standby region back to the primary region. Windows (PowerShell) or Linux (Bash).
10+
11+
Reviewed: 6.6.2024
12+
13+
# When to use this asset?
14+
15+
Use these scripts to customize your Full Stack Disaster Recovery plans and automate switchovers and failovers between OCI regions for EPM System applications.
16+
17+
# How to use this asset?
18+
19+
Use these scripts in FSDR user defined plan groups [link](https://docs.oracle.com/en-us/iaas/disaster-recovery/doc/add-user-defined-plan-groups.html)
20+
21+
# Useful Links
22+
23+
OCI Full Stack Disaster Recovery documentation can be found [here](https://docs.oracle.com/en-us/iaas/disaster-recovery/index.html) .
24+
25+
# License
26+
27+
Copyright (c) 2024 Oracle and/or its affiliates.
28+
29+
Licensed under the Universal Permissive License (UPL), Version 1.0.
30+
31+
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
Copyright (c) 2024 Oracle and/or its affiliates.
3+
4+
The Universal Permissive License (UPL), Version 1.0
5+
6+
Subject to the condition set forth below, permission is hereby granted to any
7+
person obtaining a copy of this software, associated documentation and/or data
8+
(collectively the "Software"), free of charge and under any and all copyright
9+
rights in the Software, and any and all patent rights owned or freely
10+
licensable by each licensor hereunder covering either (i) the unmodified
11+
Software as contributed to or provided by such licensor, or (ii) the Larger
12+
Works (as defined below), to deal in both
13+
14+
(a) the Software, and
15+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
one is included with the Software (each a "Larger Work" to which the Software
17+
is contributed by such licensors),
18+
19+
without restriction, including without limitation the rights to copy, create
20+
derivative works of, display, perform, and distribute the Software and make,
21+
use, sell, offer for sale, import, export, have made, and have sold the
22+
Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
either these or other terms.
24+
25+
This license is subject to the following condition:
26+
The above copyright notice and either this complete permission notice or at
27+
a minimum a reference to the UPL must be included in all copies or
28+
substantial portions of the Software.
29+
30+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36+
SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ps1
2+
3+
# For usage instructions see host_switch_readme.txt
4+
5+
$hostsFile = "C:\Windows\System32\drivers\etc\hosts"
6+
$primaryHostsFile = "C:\scripts\primary_hosts.txt"
7+
$standbyHostsFile = "C:\scripts\standby_hosts.txt"
8+
9+
# Mode: "failover" or "failback"
10+
$mode = "failback"
11+
12+
# Get the current date and time for the backup filename
13+
$currentDate = Get-Date -Format "yyyyMMdd_HHmmss"
14+
$backupFile = $hostsFile + ".bak_" + $currentDate
15+
16+
if ($mode -eq "failover") {
17+
# Create an archive backup of the current hosts file
18+
Copy-Item $hostsFile $backupFile -Force
19+
20+
# Overwrite hosts file with standby version
21+
Copy-Item $standbyHostsFile $hostsFile -Force
22+
23+
} elseif ($mode -eq "failback") {
24+
# Overwrite hosts file with primary version
25+
Copy-Item $primaryHostsFile $hostsFile -Force
26+
27+
} else {
28+
Write-Error "Invalid mode! Please specify either 'failover' or 'failback'."
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# For usage instructions see host_switch_readme.txt
4+
5+
hosts_file="/etc/hosts"
6+
primary_hosts_file="/path/to/primary_hosts.txt"
7+
8+
# Overwrite hosts file with primary version
9+
sudo cp $primary_hosts_file $hosts_file
10+
11+
echo "Failback to primary complete."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ps1
2+
3+
# For usage instructions see host_switch_readme.txt
4+
5+
$hostsFile = "C:\Windows\System32\drivers\etc\hosts"
6+
$primaryHostsFile = "C:\scripts\primary_hosts.txt"
7+
$standbyHostsFile = "C:\scripts\standby_hosts.txt"
8+
9+
# Mode: "failover" or "failback"
10+
$mode = "failover"
11+
12+
# Get the current date and time for the backup filename
13+
$currentDate = Get-Date -Format "yyyyMMdd_HHmmss"
14+
$backupFile = $hostsFile + ".bak_" + $currentDate
15+
16+
if ($mode -eq "failover") {
17+
# Create an archive backup of the current hosts file
18+
Copy-Item $hostsFile $backupFile -Force
19+
20+
# Overwrite hosts file with standby version
21+
Copy-Item $standbyHostsFile $hostsFile -Force
22+
23+
} elseif ($mode -eq "failback") {
24+
# Overwrite hosts file with primary version
25+
Copy-Item $primaryHostsFile $hostsFile -Force
26+
27+
} else {
28+
Write-Error "Invalid mode! Please specify either 'failover' or 'failback'."
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# For usage instructions see host_switch_readme.txt
4+
5+
hosts_file="/etc/hosts"
6+
backup_file="${hosts_file}.bak" # Change if needed
7+
standby_hosts_file="/path/to/standby_hosts.txt"
8+
9+
# Get the current date and time for the optional backup filename
10+
current_date=$(date +"%Y%m%d_%H%M%S")
11+
12+
# Create an archive backup of the current hosts file (optional)
13+
sudo cp $hosts_file "${backup_file}_${current_date}"
14+
15+
# Overwrite hosts file with standby version
16+
sudo cp $standby_hosts_file $hosts_file
17+
18+
echo "Failover to standby complete."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# README for Host Switch Scripts
2+
3+
During a failover to a standby region, applications often rely on hostnames to access critical resources. These hostnames usually resolve to IP addresses within the primary region. By switching the hosts file to a version containing the corresponding IP addresses for the standby region, applications can continue to function seamlessly without needing code modifications. This ensures minimal disruption and a smoother transition during a failover event. The host_switch scripts automate this process and can be integrated into Full Stack Disaster Recovery plans.
4+
5+
## Instructions
6+
7+
### Prerequisites
8+
9+
- Ensure the PowerShell execution policy allows script execution (set to at least RemoteSigned or similar if the script is not signed).
10+
- The script needs to be run with sufficient privileges to modify the hosts files.
11+
- Make sure you are able to run commands on OCI compute nodes: https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/runningcommands.htm
12+
13+
### Files
14+
15+
- `host_switch_failover.ps1`: PowerShell script to switch the hosts file after failover to the standby region.
16+
- `host_switch_failback.ps1`: PowerShell script to restore the original hosts file after failback to the primary region.
17+
- `primary_hosts.txt`: Contains the original host file for the primary region.
18+
- `standby_hosts.txt`: Maps standby region IP addresses to primary region hostnames.
19+
20+
### Overall Process
21+
22+
#### Preparation
23+
24+
1. Create `primary_hosts.txt` and `standby_hosts.txt` files with the appropriate IP address and hostname mappings for their corresponding regions.
25+
2. Place all files (`host_switch_failover.ps1`, `host_switch_failback.ps1`, `primary_hosts.txt`, `standby_hosts.txt`) in an accessible location on both the primary and standby systems.
26+
27+
#### Failover to Standby
28+
29+
1. On the standby system, execute the script `host_switch_failover.ps1`:
30+
31+
C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe c:\scripts\host_switch_failover.ps1
32+
33+
Or, if using a shell script:
34+
35+
/path/to/host_switch_failover.sh
36+
37+
2. This will replace the hosts file with the standby mappings.
38+
39+
#### Failback to Primary
40+
41+
1. On the original primary system, execute the script `host_switch_failback.ps1`:
42+
43+
C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe c:\scripts\host_switch_failback.ps1
44+
45+
Or, if using a shell script:
46+
47+
/path/to/host_switch_failback.sh
48+
49+
2. This will restore the hosts file to the original primary mappings.
50+
51+
### Important Notes
52+
53+
- **File Paths**: Adjust file paths in the instructions and the script if your files are located in a different directory.
54+
- **Backup**: The script creates an archive backup of the hosts file with a date and time appended to the filename (e.g., `hosts.bak_20240308_163012`) before any modifications are made.
55+
- **Permissions**: Ensure the user or process executing the script has permissions to modify the hosts file in `C:\Windows\System32\drivers\etc`. You may need to run the script with administrative privileges.
56+
- **Automation**: Consider integrating this script into your broader disaster recovery orchestration processes for automated execution, if applicable.
57+
58+
### Additional Tips
59+
60+
- **Test Thoroughly**: Test the script in a non-production environment to ensure it works as expected before using it in your production switchover process.
61+
- **Script Protection**: Store the script and host files in a secure location with appropriate access controls to prevent unauthorized modifications.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 1993-2009 Microsoft Corp.
2+
#
3+
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
4+
#
5+
# This file contains the mappings of IP addresses to host names. Each
6+
# entry should be kept on an individual line. The IP address should
7+
# be placed in the first column followed by the corresponding host name.
8+
# The IP address and the host name should be separated by at least one
9+
# space.
10+
#
11+
# Additionally, comments (such as these) may be inserted on individual
12+
# lines or following the machine name denoted by a '#' symbol.
13+
#
14+
# For example:
15+
#
16+
# 102.54.94.97 rhino.acme.com # source server
17+
# 38.25.63.10 x.acme.com # x client host
18+
19+
# This file should contain content of the original host file from the primary OCI region
20+
21+
# localhost name resolution is handled within DNS itself.
22+
# 127.0.0.1 localhost
23+
# ::1 localhost
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 1993-2009 Microsoft Corp.
2+
#
3+
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
4+
#
5+
# This file contains the mappings of IP addresses to host names. Each
6+
# entry should be kept on an individual line. The IP address should
7+
# be placed in the first column followed by the corresponding host name.
8+
# The IP address and the host name should be separated by at least one
9+
# space.
10+
#
11+
# Additionally, comments (such as these) may be inserted on individual
12+
# lines or following the machine name denoted by a '#' symbol.
13+
#
14+
# For example:
15+
#
16+
# 102.54.94.97 rhino.acme.com # source server
17+
# 38.25.63.10 x.acme.com # x client host
18+
19+
# localhost name resolution is handled within DNS itself.
20+
# Map here all EPM system compute nodes as well as DB compute node standby region IP adresses to primary region hostnames.
21+
127.0.0.1 localhost epm11215 epm11215.example.com
22+
10.0.0.5 epmsystem epmsystem.example.com
23+
10.0.0.6 db.example.com

0 commit comments

Comments
 (0)