In this scenario, our objective is to automatically restore a Compute Instance from one Availability Domain (AD) to another within the same region. Specifically, we are transitioning from Frankfurt AD3 to AD1.
While Full Stack Disaster Recovery facilitates the reassignment of the same Private IP, if there is a requirement to also reallocate a Reserved Public IP, utilization of the provided script becomes essential. It is imperative that this script is present locally on each compute instance, irrespective of whether it operates on a Linux or Windows environment.
This script will update the Vnic parameters from the Compute Instance, to do so it will authenticate to OCI using Instance Principals.
You must create the following resources:
- Create a Dynamic Group called OCI_Scripting and add the OCID of your instance to the group, using :
ANY {instance.id = 'OCID_of_your_Compute_Instance'}
- Create a compartment level policy, giving your dynamic group permission to manage all-resources in this compartment:
allow dynamic-group OCI_Scripting to manage all-resources in compartment YOUR_COMPARTMENT_NAME
curl https://raw.githubusercontent.com/Olygo/OCI_DR-Reserved_PIP/main/script.py -o /home/opc/script.py
The plugin runs as the ocarun user.
From Invoke custom scripts using the run command with OCI FSDRS apply :
- "Task 3. Configure and validate run command in the source VM"
vi ./101-oracle-cloud-agent-run-command
Allow the ocarun user to run all commands as sudo by adding the following line
ocarun ALL=(ALL) NOPASSWD:ALL
Validate if the syntax in the configuration file is correct.
visudo -cf ./101-oracle-cloud-agent-run-command
Add the configuration file to /etc/sudoers.d.
sudo cp ./101-oracle-cloud-agent-run-command /etc/sudoers.d/
Update permisions
sudo chmod 440 /etc/sudoers.d/101-oracle-cloud-agent-run-command
Restart Cloud agent manually
sudo systemctl restart oracle-cloud-agent
Parameters for execution:
Argument - | Parameter | Description |
---|---|---|
-pip | ocid1.publicip.oc1.eu-frankfurt-1.xxx | add the ocid of your Reserved Public Ip |
I want to replicate an instance (Linux or Windows) running in Frankfurt Availability Domain #3,
Instance has 1 block volume attached
Instance has 1 Reserved Public IP (pip) assigned
Before creating a Disaster Recovery group you must create a volume group
This volume group will protect volumes in Availability Domain #3
CONSOLE > STORAGE > VOLUME GROUPS > CREATE VOLUME GROUP
Add the boot & block volumes of your instance
Enable the replication to Frankfurt Availability Domain #1
Create your Primary DRP Group, without role and members
CONSOLE > MIGRATION & DISASTER RECOVERY > DR PROTECTION GROUPS > CREATE DR PROTECTION GROUP
Create your Standby DRP Group, without role and members
Add a COMPUTE member to your PRIMARY DRP Group
Select the instance to protect
Select MOVING INSTANCE because we want to reuse the same IPs
Add a VNIC MAPPING in order to specify the Private IP to assign
Select the Volume Group created previously
Select ASSOCIATE from your PRIMARY DRP group
Move Terminate Instance BEFORE Launch Instance
Move Terminate Instance BEFORE Launch Instance
This task can be added after the last Plan Group
SCRIPT PARAMETER :
sudo /usr/bin/python3.6 /home/opc/script.py -pip ocid1.publicip.oc1.eu-frankfurt-1.amaaaaaaXXXXXXXXXXXXXXX
Compute instance in AD3 is terminated
Compute instance is created in AD1 using an Ephemeral Public IP
Please test properly on test resources, before using it on production resources to prevent unwanted outages or unwanted bills.