Wednesday, August 21, 2013

Remove data in Oracle MDS

The two main database schemas in the Oracle SOA Suite database repository are: <PREFIX>_SOAINFRA and <PREFIX>_MDS. Composite instance and runtime information are stored in the SOAINFRA schema. Commonly used metadata like WSDLs, XSDs, rules, fault policies, etc. as well as composite deployments are stored within the MDS schema. 

With every deployment / import of the metadata artifacts a new document version will be created in the MDS. This means that re-importing an updated WSDL-file into the MDS does not delete the previous version of the document. Furthermore we sometimes need to remove unnecessary and unwanted files from the repository. If this is not considered you might end in problems like below:



ORA-01654: unable to extend index DEV_MDS.MDS_PATHS_U2 by 128 in tablespace DEV_MDS
ORA-06512: at "DEV_MDS.MDS_INTERNAL_COMMON", line 865
ORA-06512: at "DEV_MDS.MDS_INTERNAL_COMMON", line 1021
ORA-06512: at "DEV_MDS.MDS_INTERNAL_COMMON", line 1121
ORA-06512: at "DEV_MDS.MDS_INTERNAL_COMMON", line 1216
ORA-06512: at "DEV_MDS.MDS_INTERNAL_COMMON", line 1872
ORA-06512: at line 1

 

In order to avoid production problems because of a full MDS tablespace you should clean up the schema from time to time. This post explains the options that Oracle SOA Suite provides to remove contents from MDS.

OPTION 1: Remove directories and files from MDS using WLST

1) Start WLST from SOA_HOME/common/bin/wlst.sh.

Example:
 
[oracle@soabpm-vm ~]$ cd /oracle/fmwhome/Oracle_SOA1/common/bin 
[oracle@soabpm-vm bin]$ ./wlst.sh 
wls:/offline>
 

2) Execute the following command: sca_removeSharedData('http://<soahost>:<soaport>', 'directory', 'user', 'password')

Example (delete folder 'interfaces' and all its subdirectories and files):

wls:/offline> sca_removeSharedData(‘http://localhost:8001’, ‘interfaces’, ‘weblogic’, ‘welcome1’)

 

Note: With the command above you can just remove directories and files which are stored under "apps".

OPTION 2: Remove directories and files from MDS using ANT

Oracle provides some ANT scripts which can be used to integrate the "remove" command into your central build & deploy proccess. Just search for the "removeSharedData" command in ant-sca-deploy.xml. On the server this file is located under SOA_HOME/bin. You can also find the file in your JDeveloper install folder under MIDDLEWARE_HOME/jdeveloper/bin.

1) Execute the command: ant -f ant-sca-deploy.xml removeSharedData -DserverURL=server.url -DfolderName=folder.name -Drealm=realm -Duser=user -Dpassword=password -DfailOnError=true/false

Example (delete folder 'interfaces' and all its subdirectories and files):
 
ant -f ant-sca-deploy.xml removeSharedData -DserverURL=http://localhost:8001 -DfolderName=interfaces"
 

Note: With the command above you can just remove directories and files which are stored under "apps". See the Oracle Fusion Middleware Developer's Guide for Oracle SOA Suite for a detailed description of the parameters.

OPTION 3: Remove files from MDS using WLST

1) Start WLST from SOA_HOME/common/bin/wlst.sh

Example:

[oracle@soabpm-vm ~]$ cd /oracle/fmwhome/Oracle_SOA1/common/bin
[oracle@soabpm-vm bin]$ ./wlst.sh
wls:/offline>

 

2) Connect to the SOA server: connect('user', 'password', 't3://<soahost>:<soaport>')

Example: 

wls:/offline> connect('weblogic', 'welcome1', 't3://localhost:8001') 
 

3) Execute the command: deleteMetadata(application=’application-name', server=’soaserver-name’, docs=’absolutePath’)

Example (delete all files in '/apps/interfaces' as well as the files in its subdirectories): 
 
wls:/...> deleteMetadata(application='soa-infra',server='soa_server1',docs='/apps/interfaces/**') 
 

Note: With the command above all files in directory 'apps/interfaces' will be deleted. Please note the double asterisk (**) at the end of the this parameter. The asterisk (*) represents all documents under the current directory. The double asterisk (**) represents all documents under the current directory and also recursively includes all documents in subdirectories. Furthermore see the Oracle Fusion Middleware WebLogic Scripting Tool Command Reference for a detailed description of the valid arguments.

OPTION 4: Remove files from MDS using MBean Browser

You can call the command "deleteMetadata" also from the Enterprise Manager / MBean Browser.

1) Login to EM (http://host:port/em)
2) Expand SOA
3) Right-click on soa-infra
4) Select Administration -> MDS Configuration
5) Click Runtime MBean Browser
6) Click Operations tab
7) Click deleteMetadata operation
8) Provide parameters:
      docs - list of entries to remove (fully qualified path, eg: /apps/interfaces/**)
      restrictCustTo - default
      excludeAllCust - false
      excludeBaseDocs - false
      excludeExtendedMetadata - false
      cancelOnException - true
9) Click Invoke

Note: See the Oracle Fusion Middleware WebLogic Scripting Tool Command Reference for a detailed description of the parameters.

OPTION 5: Purge Metadata Version History using Fusion Middleware Control

For database-based MDS, you can purge the metadata version history using the Fusion Middleware Control (Enterprise Manager). This operation purges the version history of unlabeled documents from the application's repository partition. The tip version (the latest version) is not purged, even if it is unlabeled.

1) Login to EM (http://host:port/em)
2) Expand SOA
3) Right-click on soa-infra
4) Select Administration -> MDS Configuration
5) Scroll to the “Purge” section: enter a value in the Purge all unlabeled past versions older than field and click on the Purge button
6) In the Confirmation dialog box, click Close

Note: For more details see the Oracle Fusion Middleware Administrators Guide. Section 14.3.11.2 also explains how to purge metadata version history using WLST.

How to view the MDS content

After you removed files and/or directories from the MDS you might want to have a look at the actual content. The easiest way to do this is to create a MDS connection in JDeveloper. For more details see the Oracle Fusion Middleware Developer's Guide for Oracle SOA Suite section "43.4.2.1 Create a SOA-MDS Connection".

Some additional information about the MDS


No comments:

Post a Comment