Monday, February 25, 2013

Exporting Metadata from MDS and Importing Metadata into MDS

Version: Oracle Identity Manager 11g R1
Description: This post demonstrates how to export and import metadata. This is useful for making system configuration changes in OIM as well as pushing up plugins. As an example, I will export the OIM main configuration file from OIM. MDS Schema and import a modified OIM main configuration file into OIM.MDS. The changes made in the OIM main configuration file would disable reloading of adapters and plugin.

References
MDS Utility Guide: http://docs.oracle.com/cd/E17904_01/doc.1111/e14309/utils.htm
Example: http://docs.oracle.com/cd/E17904_01/doc.1111/e14308/tuningforappserver.htm#CHDFHAGI

Set the OIM_ORACLE_HOME Environment Variable
Include the OIM_ORACLE_HOME variable in your bash profile. The value should be the path of your "<IDM_HOME>".
OIM_ORACLE_HOME=/home/oracle/Oracle/Middleware/Oracle_IDM1
export OIM_ORACLE_HOME

Setup the weblogic.properties File
Modify the "weblogic.properties" file which is located in "/home/oracle/Oracle/Middleware/Oracle_IDM1/server/bin". Given below is an example.
# Weblogic Server Name on which OIM application is running 

wls_servername=oim_server1

# If you are importing or exporting any out of box event handlers, value is oim. 
# For rest of the out of box metadata, value is OIMMetadata. 
# If you are importing or exporting any custom data, always use application name as OIMMetadata.

application_name=OIMMetadata

# Directory location from which XML file should be imported.
# Lets say I want to import User.xml and it is in the location /scratc/asmaram/temp/oim/file/User.xml, 
# I should give from location value as /scratc/asmaram/temp/oim. Make sure no other files exist 
# in this folder or in its sub folders. Import utility tries to recursively import all the files under the 
# from location folder. This property is only used by weblogicImportMetadata.sh

metadata_from_loc=/home/oracle/importMetadata

# Directory location to which XML file should be exported to

metadata_to_loc=/home/oracle/exportMetadata

# For example /file/User.xml to export user entity definition. You can specify multiple xml files as comma separated values.
# This property is only used by weblogicExportMetadata.sh and weblogicDeleteMetadata.sh scripts

metadata_files=/db/oim-config.xml

To get the name(s) of the metadata to be specified for "metadata_files", look at the MDS_PATHS table in the MDS Schema. Use the value in PATH_FULLNAME column.

Using the Export Utility
The "weblogicExportMetadata.sh" utility can be found in "/home/oracle/Oracle/Middleware/Oracle_IDM1/server/bin".
Execute the utility. You will be prompt to enter the weblogic administrator username, password, and server url.
 Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Starting export metadata script .... 
Please enter your username :weblogic
Please enter your password :
Please enter your server URL [t3://localhost:7001] :t3://localhost:7001
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'oim_domain'.

Warning: An insecure protocol was used to connect to the 
server. To ensure on-the-wire security, the SSL port or 
Admin port should be used instead.

Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root. 
For more help, use help(domainRuntime)

Disconnected from weblogic server: AdminServer
End of export metadata script ...

Exiting WebLogic Scripting Tool.

Modifying the "oim-config.xml" file
Backup original copy if you ever want to revert the changes made.
  1. In the oim-config.xml file, replace the following:
    <ADPClassLoaderConfig adapterReloadingEnabled="true" loadingStyle="ParentFirst" reloadInterval="15" reloadingEnabled="true">

    With:
    <ADPClassLoaderConfig adapterReloadingEnabled="false" loadingStyle="ParentFirst" reloadInterval="15" reloadingEnabled="false">

  2. Replace the following:
    <storeConfig reloadingEnabled="true" reloadingInterval="20"/>

    With:
    <storeConfig reloadingEnabled="false" reloadingInterval="20"/>

Using the Import Utility
Important: Notice when you exported the "oim-config.xml" from MDS, the "oim-config.xml" got placed into "/home/oracle/exportMetadata/db" ($metadata_to_loc/$metadata_file_name). I think it would be best to preserve the metadata file name when you are importing the "oim-config.xml". So create a "db" directory in your "importMetadata" folder and place the "oim-config.xml" in the db folder. The absolute path should be "/home/oracle/importMetadata/db/oim-config.xml".  The import utility imports all the files located "importMetadata" folder recursively. So make sure there is nothing else in there other than the files you want to import.

The "weblogicImportMetadata.sh" utility can be found in "/home/oracle/Oracle/Middleware/Oracle_IDM1/server/bin".
Execute the utility. You will be prompt to enter the weblogic administrator usernname, password, and server url.
Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Starting import metadata script .... 
Please enter your username :weblogic
Please enter your password :
Please enter your server URL [t3://localhost:7001] :
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'oim_domain'.

Warning: An insecure protocol was used to connect to the 
server. To ensure on-the-wire security, the SSL port or 
Admin port should be used instead.

Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root. 
For more help, use help(domainRuntime)

Disconnected from weblogic server: AdminServer
End of importing metadata script ...

Exiting WebLogic Scripting Tool.

Notes [optional]
You can skip this section. These are my notes.

Bad Import
I imported the “oim-config.xml” with metadata_files variable as “oim-config.xml”.  I lefted out the "db" directory. Notice the PATH_FULLNAME, PATH_VERSION, and PATH_DOCID of the previous records. The previous “oim-config.xml” (PATH_LOW_CN = 233, PATH_HIGH_CN = (null)) is still active.


More Bad Import


Delete “/db/oim-config.xml”
I ran the weblogicDeleteMetadata.sh script on “/db/oim-config.xml”. Notice that the PATH_HIGH_CN of the latest “/db/oim-config”. “236" does not reference to anything. This means the metadata for “/db/oim-config.xml” is no longer active.


Delete “/oim-config”
I ran the weblogicDeleteMetadata.sh script on “/oim-config.xml”


Import “/db/oim-config”


No comments:

Post a Comment