šŸ” Automated Oracle Enterprise Manager (OEM) Cloning with Ansible

Cloning an Oracle Enterprise Manager (OEM) environment is a complex and sensitive process. However, it is very useful, especially when migrating from staging to production, preparing a DR environment, or replicating for testing any patches or changes before they make their way to production.

The manual clone is a multi-step process. It involves preparation at the source OMS layer. It also includes repository database clone, and actual OMS clone. Additionally, it requires cleaning up transient files, handling configuration files, and much more.

Any misstep can leave the target or in worst case the source OEM in an inconsistent state. To overcome this issue, I created this Ansible code to perform a silent clone of OEM 13.5 from one Linux server to another.

The entire code is publicly available on my Github repo.

What all does the repository have?

The repository provides a fully automated procedure to clone Oracle Enterprise Manager (OEM) Cloud Control OMS to a new Linux server. Except for cloning the repository database and assumes that the database clone has been performed successfully. I plan to add a role for db_duplicate in a future release.

Supported OEM Versions:

  • Oracle Enterprise Manager 13.5

High-Level Steps Performed:

Source OMS:

  • Check prerequisite
  • Copy EMKey to repository
  • Prepare OMS binaries on source
  • Prepare agent software on source

OMS Repository clone:

  • Clone OEM repository database (manual step). OEM13.5 supports both CDB and non-CDB repository database. There can be several approaches to clone the database. Therefore, I left this piece, for now, to be performed based on your preference. This step must be executed before proceeding with the next steps.

Target OMS

  • Install Required Packages on Target OEM server
  • Install Agent on Target OEM server
  • Paste OMS binary from Source to Target OEM server
  • Clone OMS software
  • Configure OEM plugins
  • Start OMS service
  • Post-configuration tasks
  • Secure EM Key in source OMS

Prerequisites:

  • Python 3 and Ansible 2.10+
  • Oracle user and VM access on source and target servers
  • Manual clone of the repository DB via RMAN
  • All binaries: agent ZIP, OMS clone JAR, software library tar file should be prepared and copied beforehand

Variables:

Update the below variables, located in the file vars/main.yml

source:
  oem_version: 13.5
  oracle_home: /u01/app/oracle/product/19.3.0/dbhome_1
  oms_home: /u01/app/middleware/mware13_5
  agent_base: /refresh1/agent135
  os_user: oracle
  os_group: oinstall
  db_name: oemdb
  repo_conn_str: "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost)(PORT=1521))(CONNECT_DATA=(SID=oemdb)))"
  em_domain_name: GCDomain
  msport: 7202
  agent_port: 3872
  upload_port: 4903
  agent_reg_password: mysecretpassword
  sys_password: my_sys_password
  sysman_password: my_sysman_password
  agent_soft_lib_path: /u01/app/middleware/software_lib

target:
  oem_version: 13.5
  oracle_home: /u01/app/oracle/product/19.3.0/dbhome_1
  oms_home: /u01/app/middleware/mware13_5
  agent_base: /u01/app/middleware/agent
  os_user: oracle
  os_group: oinstall
  oms_host_name: newoms.example.com
  db_name: oemdb
  repo_conn_str: "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost)(PORT=1521))(CONNECT_DATA=(SID=oemdb)))"
  em_domain_name: GCNewDomain #Must be different from source
  msport: 7202
  admin_server_https_port: 
  agent_port: 3872
  upload_http_port: 
  upload_https_port: 
  agent_reg_password: mysecretpassword #Should be same as source OMS
  sys_password: my_sys_password #Should be same as source OMS
  sysman_password: my_sysman_password #Should be same as source OMS 
  as_user_password:  #Weblogic password - Can be same or different than source OMS
  node_manager_password:  #Weblogic password - Can be same or different than source OMS
  oms_config_files_path: #Path to OMS Instance Home

oms_clone_dir: /oembackup/oms_clone
platform: "Linux x86-64"
agent_export_dest: /oembackup/oms_clone/agent_export
agent_software_lib: /oembackup/oms_clone/agent_software_lib

Executing The Clone

OMS clone is divided into two parts:

  • The prepare phase, that is executed on the source OMS server
  • The clone phase, that is executed on the target OMS server, and finally an additional role executed on the source OMS server

Running the clone_oms_prepare.yml

ansible-playbook -i your_inventory_loc/hosts.yml clone_oms_prepare.yml -f 5 -e 'source_server=<Source_OEM_Server>'

Running the clone_oms.yml

ansible-playbook -i your_inventory_loc/hosts.yml clone_oms.yml -f 5 -e 'source_server=<Source_OEM_Server> target_server=<Target_OEM_Server>'

Gotchas!

The extraction on agent software will fail if there are missing plugins. To resolve this issue, you want to follow the below procedure.

# Check if there are any missing plugins
$ <source.oms_home>/bin/emcli verify_updates
# Download the missing plugin from MOS.
# Force apply the missing plugins.
$ <source.oms_home>/bin/emcli import_update -omslocal -file="<absolute path of the downloaded plugin .zip>" -force
Processing update: Agent Software - Agent Software (13......)
Successfully uploaded the update to Enterprise Manager. Use the Self Update Console to manage this update.
$ <source.oms_home>/bin/emcli sync
Synchronized successfully
# Re-attempt agent download (Full code already included)

The OMS startup can fail at times. This can happen if there are any lock files that get copied over from source to target OMS. It can also occur if the job_queue_processes is not set. I have already included this cleanup in the code before attempting a startup of the target OMS. However, every environment is different. In case the startup hangs, check for any lock files or port issues that prevent the OMS from starting up.

Hope this helps!


Discover more from IT-Noesis

Subscribe to get the latest posts sent to your email.

Leave a comment