[DBA Daily Notes] ORA-00054 Resource busy when dropping table

Here are a few things you can do

  • Kill session from GUI

Go to toad and log on as system administrator. You could also do this sql developer.

 

Now you would have an overview of the sessions that might involve in locking the tables you would like to drop. So you could simply identify the sessions and kill the corresponding sessions where table locks are withheld.

 

  • Check v$session and kill session from command.

However sometimes, even we kill the existing sessions, the error would still not go away. I run my drop table script in toad that you could get the details of which table is being locked and the type of the lock. And then go to locks tab to identify the Sid number. You would see a similar window as below.  

 

For example, on the above screen, my PEGASYS_OBLIGATI table is locked with Lock Type DML. It is because I was doing the data refresh and then it was interrupted in the middle. But Sid 24 didn’t show in any of the sessions in the session window. I could not kill the session to get rid of the locks. Instead I run the following sql statement to find the serial number in order to kill the dead session that holds the lock for my table of object.

 

> select * from v$session where blocking_session is not null;

 

After running the sql statement, I find the serial number with the corresponding  sid.

 

> alter system kill session ‘42,789’;

 

Now we are all set. Lock is released and drop could be proceeding.

 

If you want  to know more about v$session, check the link below:

 

http://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_2088.htm

 

SSO Integration with J2EE application deployed on 11g WebLogic Server(Part 2)

In the previous post, we went through the structure of the integration and the procedure of installing oracle web tier. Now we are going to review the configuration of SSO Integration with J2EE application.

PREQUISITES:

       I assume you have deployed your J2EE applicaiton onto webLogic server and it could be reached by the link:

       (Suppose your J2EE application is deployed on to Admin Server, by default the port number is 7001.)

       http://<host_name&gt;:7001/<Your_J2EEAPP_Name>

       Note: Port number would be vary if you deploy J2EE application on to managed server. For more information about this, you should check the following posts:

        Deploy application to Managed Server on 11g WebLogic Server (Part 1)

        Deploy application to Managed Server on 11g WebLogic Server (Part 2)

SOLUTION:

     The following solution is basically a summary from oracle document: (If you would like a more detailed explanation of what and why)

     http://docs.oracle.com/cd/E25054_01/core.1111/e10043/osso_d_10g.htm

     For how to install oracle web tier, check previous post:

     SSO Integration with J2EE application deployed on 11g WebLogic Server(Part 1)

     STEPS:

        J2EE Application Code Change

          The idea is to enable the fuctionality of enabling OID users login into your J2EE application directly.

        Set up mod_osso

          Find the mod_wl_ohs.conf. This file should reside under the following directory:

          <Fusion_Middleware_Home>/Oracle_WT1/instances/instance1/config/OHS/ohs1

          The following code snippet comes from mod_wl_ohs.conf file.

     

          Modify the line marked in red. Uncomment the line starting with “MatchExpression…” to below 

 
       

Restart ohs1 after editing:

cd /Oracle_WT1/opmn/bin

opmnctl stopall

opmnctl startall

       Registering Oracle HTTP Server mod_osso with OSSO Server 10.1.4      

The mod_osso module is an Oracle HTTP Server module that provides authentication to OracleAS applications. This module resides on the Oracle HTTP Server that enables applications protected by OracleAS Single Sign-On to accept HTTP headers in lieu of a user name and password once the user has logged into the OracleAS Single Sign-On server. The values for these headers are stored in a mod_osso cookie. The mod_osso module enables single sign-on for Oracle HTTP Server by examining incoming requests and determining whether the requested resource is protected. If it is, then it retrieves the Oracle HTTP Server cookie. Under certain circumstances, you must register Oracle HTTP Server mod_osso using the 10.1.4 Oracle Identity Manager single sign-on registration tool .

To register mod_osso:

   Go to the following 10.1.4 Oracle Identity Manager directory path: (This could be your OSSO server)

              <ORACLE_HOME>/sso/bin/ssoreg

  Run ssoreg with the following parameters and values for your environment:

             ./ssoreg.sh -oracle_home_path $ORACLE_HOME -config_mod_osso TRUE -site_name <host_name>:7777 -remote_midtier -config_file $ORACLE_HOME/osso.conf -mod_osso_url http://<host_name>:7777

      (Note: the osso.conf would be generated under specified directory: $ORACLE_HOME/osso.conf)

  Ftp osso.conf file from the directory above to the application server where web tier is installed.

              Put osso.conf under directory: (Note: create directory osso if it does not exist)

       <Fusion_Middleware_Home>/Oracle_WT1/instances/instance1/config/OHS/ohs1/osso

 Copy mod_osso.conf from disabled directory to the moduleconf directory for editing.

              From directory:

       <Fusion_Middleware_Home>/Oracle_WT1/instances/instance1/config/OHS/ohs1/disabled/mod_osso.conf

             To directory:

       <Fusion_Middleware_Home>/Oracle_WT1/instances/instance1/config/OHS/ohs1/moduleconf

      The orignial mod_osso.conf file should look like :

      

      Modify the red line and add the corresponding code into this file. It should look like :

      

Note: Httpd.conf for Oracle http server 11g is not in need for further modification, for it has already included the following:

          

Restart ohs1 after editing:

cd /Oracle_WT1/opmn/bin

opmnctl stopall

opmnctl startall

         To be Continued with:

                SSO Integration with J2EE application deployed on 11g WebLogic Server(Part 3)

SSO Integration with J2EE application deployed on 11g WebLogic Server(Part 1)

Previously, we talked about how to deploy our J2EE web application on to oracle 11g weblogic server. With the upcoming need of SSO integration, our goal becomes to enable SSO functionality on weblogic server and secure our application access by going through portal page and then getting user authentication through LDAP server with the OID repository.

I have successfully implemented the solution on SSO integration within Oracle 10g Applicaiton Server(OAS). The idea is quite simliar since we are still using 10g portal page. However, oracle 11g enterprise edition has replaced the OAS with weblogic server which introduces quite a few changes for the SSO integration on weblogic server. I would break into a few posts on elaborating this idea. If you are not familar with SSO(Single Sign On) with oracle 10g OAS, please refer to the following link to get a basic understanding of what and why: (The following link shows a basic work-though of 10g SSO. Our new approach would inherit a lot of similar ideas from the old approach.It would be easier to understand this current post if you have the history knowledge)

http://www.slideshare.net/kurtvm/extending-oracle-sso-presentation

Now I assume if you have already knew a few concepts of mod_osso, OID registration,httpd.conf file. Then let us firstly start with reviewing application architecture with the SSO integration. 

The architure of the whole process looks like below.

WEB TIER INSTALLATION

Now our application is deployed on weblogic server. So right now besides the installation of Business Intelligence SUITE, we also need to install Oracle Web Tier.

PREREQUISITES:

  •       Oracle Buisiness intelligence 11g is installed
  •       OR Oracle Web Logic Server is installed

Note: If you have only installed oracle web logic server, be sure to enable JRF manually as below. Oracle Web Tier installation requires Oracle WSM Policy Manager and JRF(Java Required Files) and they do not display by default in the Oracle Fusion  Middleware Configuration Wizard. You must enable the display of these products. To accomplish this, pass the following JVM property to the config.sh script:

-DTemplateCatalog.enable.selectable.all=true

To pass this property to the script, set the CONFIG_JVM_ARGS environment variable to -DTemplateCatalog.enable.selectable.all=true. The script takes this property when you start the Oracle Fusion Middleware Configuration Wizard using./config.sh .

cd /wlserver_10.3/common/bin

 ./config.sh -DTemplateCatalog.enable.selectable.all=true

INSTALLATION PROCEDURE:

Download oracle web tier package and unzip the file. You should find Disk1 within the unziped file folder. Go under Disk1 and run ./runInstaller

Click and Next and then skip the software updates and then continue to check the prerequisite(Keep the default options)

Oracle web tier would be installed under fushion middleware home. So you should make sure you enter the correct FM home.

Uncheck the box to proceed.

It is not neccessary to install web cache if you don’t need to do performance tuning. That is optional.

Enter your domain settings as below:

It will dynamically load the instance home and you just proceed.

Skip the below step if you didn’t install web cache.

Choose Auto Port Configuration.

Check if everything looks right and then install the software.

Wait until it gets successfully finished.

Once web tier has been installed. You could check the status on em to see if it keeps up and running.

 To be continued to :

SSO Integration with J2EE application deployed on 11g WebLogic Server(Part 2)

Change Context Root for xmlpserver on 11g BI Publisher

I have been researching on how to change the context root for xmlpserver on 11g BI Publisher. Since our application could not use xmlpserver as the context root extension, I would love to come up an approach with the deployment of the same application but with a new context root. This topic is an open question. I have worked out one solution explained in the current article. But I still have not figured out the best approach for the question. Let me know if anyone has any idea for the questions I asked in the article.

As far as I have touched this topic, I tried changing the context root on the fly by modifying the xmlpserver deployment configuration as below:

Login to Application console, and click on the Deployments. You should be able see a list of deployments on the weblogic server. Find the one with name bipublisher, expand the deployment, there is a web application named xmlpserver. Click on that, it will navigate to the settings page of xmlpserver showed in the picture below: (Click on Configuration Tab and navigate to the bottom)

 

This Context Root is editable and was previously set to be xmlpserver. So I changed it to newContextRoot and save the configuration. However the settings didn’t get picked up during the server restart and it was not working.

I would expect to access http://domain-name:9704/newContextRoot  instead of http://domain-name:9704/xmlpserver

  Anyone knows why this straightforward approach is not functioning as expected?

My working approach:

Here is what I do for the rest of the steps. I will firstly undeploy the current bipublisher application in enterprise manager and then duplicate a copy of existing xmlpserver.ear with the new name btmreport.ear. Later I modified a few files in btmreport.ear and deploy btmreport.ear with the same name bipublisher under the same target. (This involves a few tricks I found out during the trials and errors. I would explain them in the corresponding steps)

 Step 1. Undeploy the current bipublisher application.

 Access enterprise manger as below. By default you could access the link: http://Domain-Name:7001/em

Now on the navigation panel find bipublisher and click on Undeploy as below.

Continue the undeployment.

If you run into the same error with me as below, it means the configuration of bifoundation has been locked and you need to go to applicaiton console to release the configuration.

How to release the configuration? Simple! Go to application console. By default you access the link: http://Domain-Name:7001/console

Once login, you should be able to see that there are changes that need to be taken actions in order to unlock the configure on bifoundation domain. I have been trying out other deployments on console. So I just wanted to undo the changes to release the configuration.

After this change,  I could proceed on undeploying the application back to enterprise manager.

Now we would need to duplicate a copy from xmlpserver.ear with the name btmreport.ear. And modify two files within the ear file.

xmlpserver.ear location: <BI_middleware_home>/Oracle_BI1/bifoundation/jee/xmlpserver.ear

Now duplicate another ear under the same location: <BI_middleware_home>/Oracle_BI1/bifoundation/jee/btmreport.ear

There are two files to be modified in btmreport.ear:

   (MODIFY 1)btmreport.ear\META-INF\application.xml

 Change From Change To
<display-name>xmlpserver</display-name>  <display-name>btmreport</display-name> 
<context-root>xmlpserver</context-root> <context-root>btmreport</context-root>

  (MODIFY 2)btmreport.ear\xmlpserver.war\WEB-INF\weblogic.xml

 Change From Change To
<cookie-path>/xmlpserver</cookie-path> <cookie-path>/btmreport</cookie-path>
<context-root>xmlpserver</context-root> <context-root>btmreport</context-root>

The reason for changes of these two files could be related to the oracle document : Read More on Web Applications from Oracle Doc

Step 2 Deploy the application under the same name bipublisher. Go to enterprise manager and deploy the application as below:

Input the location of the btmreport.ear. (This could be found in the previous step)

Deploy the application under the same target bi_cluster -> bi_server1

 Now we come to the deployment page.

The trick here is to put the name as bipublisher. That is why we have to undeploy bipublisher application firstly. Since it will not allow the same application name being created twice. And the consequence of not using bipulisher as the application deployment name is that you would not be able to have a complete xmlpserver login page(It showed as a blank blue page). I would assume in the BIP software, it is hardcoded somewhere to use bipulisher as the name.

Wait until the deployment finishes successfully, and then validate the new context root(In our case, it should be btmreport)

In order to validate the link, we could go back to application console and take a look at the new deployment details:

Go under the configuration of the deployment btmreport and go to testing to view all the links:

(By default the xmlpserver port should be 9704. In my envrionment, I set it to 9500)

Anyone knows how to keep xmlpserver undeployed but deploy a new btmreport application under bipublisher?

Export a table to csv file and import csv file into database as a table

Today, I would be talking about exporting a table to csv file. This method is especially useful for advanced data manipulation within the csv file and I would also talk about how to import the csv data back into the database as a table. I will be showing Java code snippet to explain importing the csv data and the tradeoff for using sql developer. My environment is based on oracle database and so that all the utility I would be using here is targeting oracle database.

Export a table to csv file:

Method 1. Use oracle sql developer. Please take a look at the video below:

Note: This is good for small table with not much data. However, if you are dealing with a large table, I would recommend you try method 2.

Method 2. Generate the csv file from command line. Here is a sample sql file I used to generate the  csv file.

set pause off
set echo off
set verify off
set heading off
set linesize 5000
set feedback off
set termout off
set term off spool FY11_276.csv
set colsep ','
set pagesize 0
select 'BOOK_MONTH_ID','BOOK_MONTH_CODE','BOOK_MONTH_ORDER','QUARTER_NUMBER','BOOK_MONTH_NUMBER','BOOK_MONTH_NAME','QUARTER_NAME', 'DEL_COL' from dual;
select BOOK_MONTH_ID,BOOK_MONTH_CODE,BOOK_MONTH_ORDER,QUARTER_NUMBER,BOOK_MONTH_NUMBER,BOOK_MONTH_NAME,QUARTER_NAME, null from claire_sample.book_month;

spool off 

Note: You could notice that the highlighted select statement has a last column called: DEL_COL.This column is used to fill in the space after the column separator coma.Otherwise the csv file generated from the command line would have a huge last column filled with spaces.You might need to manually delete the column if you would use oracle sql developer to import the csv file back into database later on.

To be continued…

How to back up a table and import data from dump file

There are two approaches to back up a table:

1: Back up a table under the exsiting schema by creating a new table with tablename_bck nameing convention.

   Simply run the following query under the current schema :

   Creat table tablename_bck as select * from <tablename>;

2: Export the table to a dump file.

    Open a command line tool .Use Oracle utility tool expdp

expdp sample/samplepwd@db10g tables=EMP,DEPT directory=TEST_DIR dumpfile=EMP_DEPT.dmp logfile=expdpEMP_DEPT.log

3: Import the dump file into database.

impdp sample/samplepwd@db10g tables=EMP,DEPT directory=TEST_DIR dumpfile=EMP_DEPT.dmp logfile=impdpEMP_DEPT.log

More thoughts:

    I would also like to note about the old utility tool exp and imp.

    The syntax is slightly different. Without creating a reusable directory, in exp and imp, you have to specify explicitly of the directory where your dump file is saved to.

exp sample/samplepwd@db10g tables=EMP,DEPT file="C:\EMP_DEPT.dmp" log="C:\impdpEMP_DEPT.log"
imp sample/samplepwd@db10g tables=EMP,DEPT file="C:\EMP_DEPT.dmp" log="C:\impdpEMP_DEPT.log"

  Error: ORA-39143: dump file “M:\SAMPLE.dmp” may be an original export dump file

    

     The above problem happened whenever you try to use the Import Data Pump client (impdp) to import a dumpfile that was created with the original Export client (exp).

Backup exsiting data and load data dump into Database

Export current data dump as a backup.

   Method 1: Use utility exp

  • Login to the Database Server.
  • Start a windows command prompt, click on Start > Run
  • Type in cmd in the dialog box and click on OK.
  • Change directory to the root C:\ >

Type in the following command:

exp <user_toexport>/<user_toexport_password>

file=<directory>\dumpFileName.dmp log=<directory>\logFileName.log owner=<to_user> buffer=10000

Press [Enter]

The backup dump file will be found in the directory you specified.

For example: the following command is to export sample data from SAMPLE database:

exp sample/sample file=C:\sample.dmp log=C:\sample.log owner=sample buffer=100000

   Method 2: using Data Pump expdp

  • Login to the Database Server.
  • Start a windows command prompt, click on Start > Run
  • Type in cmd in the dialog box and click on OK.
  • Type in the following command to connect to the SAMPLE database

SQLPLUS system/<system password>

Press [Enter]

e.g. SQLPLUS system/<system password>

Execute the following commands to create a database directory. This directory must point to a valid directory on the same server as the database:

SQL> CREATE or REPLACE DIRECTORY <directory_name> AS ‘<directory\folder>\‘;

Directory created.

SQL> GRANT READ, WRITE on directory <directory_name> to <user_toexport>/

e.g.  CREATE or REPLACE DIRECTORY imp_dir as ‘D:\db_dump’;

GRANT READ, WRITE on directory imp_dir to bisbtm;

·         Create a folder under directory

·         Type in the following command:

expdp <user_toexport>/<user_toexport_password>

directory=< directory_name> dumpfile=dumpFileNam.dmp 

e.g. expdp sample/sample directory=imp_dir dumpfile=samp.dmp

Press [Enter]

The backup dump file will be found in the directory you specified.

To be continued….