Alvin Sim’s Blog

October 15, 2009

Setting Java Environment in Linux

Filed under: Blogroll — Tags: , — Alvin Sim @ 1:55 pm

This article shows the steps in setting up a Java environment in a Linux system.

The Java SDK version which will be installed is 1.4.2 which was downloaded from Sun Microsystems and the Linux involved is Oracle Enterprise Linux (based on the Red Hat distribution).

  1. Download Java SDK. The file which I downloaded was j2sdk-1_4_2_19-linux-i586-rpm.bin.
  2. As a root user, make the downloaded bin file executable.
    # chmod 755 j2sdk-1_4_2_19-linux-i586-rpm.bin
  3. Execute the bin file and agree to the terms and condition. Then it will extract the file to a RPM file.
    # ./j2sdk-1_4_2_19-linux-i586-rpm.bin

    Press the space bar to scroll down in “More”.
    Do you agree the the above license terms? [yes or no] yes
  4. Use the rpm command to install the RPM package.
    # rpm –ivh j2sdk-1_4_2_19-linux-i586.rpm
  5. The Java SDK is successfully installed. It is installed in /usr/java/j2sdk1.4.2_19.
  6. Setup the environment variables. Using your favorite text editor, open the user’s .bash_profile ($HOME/.bash_profile) and add in the variables below.
    PATH=/usr/java/j2sdk1.4.0_03/bin:$PATH:$HOME/bin:./
    export PATH
    export JAVA_HOME=/usr/java/j2sdk1.4.0_03
    export CLASSPATH=/usr/java/j2sdk1.4.0_03/lib/tools.jar:/usr/java/j2sdk1.4.0_03/jre/lib/rt.jar:./
  7. Logout from your system and log back in again.
  8. Run the below commands to make sure the environment variables are set correctly.
    $ which java

    /usr/java/j2sdk1.4.2_19/bin/java

    $ java -version

    java version “1.4.2_19″

    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)

    Java HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)

Resources/references:

  1. YO Linux Tutorial: Java on Linux

September 2, 2008

Hug A Developer Today

Filed under: Blogroll — Alvin Sim @ 6:55 pm

If you have been cruel to your developers, stop! And give them a hug. They are in pain.

May 30, 2008

Moving Oracle Tablespaces

Filed under: Blogroll, database, oracle, work — Tags: — Alvin Sim @ 5:17 pm

Our customers are in the midst of reallocating their UAT DB server’s volume group. There are currently two volume groups – rootvg, datavg. And temporarily, the datavg has to be removed.

Inside the datavg volume group are two directories – /oraBackup and /oradata. The oraBackup directory contains dump files and the datafiles are in the /oradata directory.

The files inside the oraBackup directory aren’t very important and they could be copy/paste or moved to another directory.

But, to move the datafiles is not that easy. We have to move the datafiles from /oradata to /oradata2 (rootvg). Below are the steps for the reallocation.

  1. Backup
    • Before doing anything to the database, always backup! We used RMAN to backup the database.
    •  $> rman target /
      Recovery Manager: Release 10.2.0.3.0 - Production on Fri May 30 16:37:24 2008
      Copyright (c) 1982, 2005, Oracle.  All rights reserved.
      connected to target database: PROFIT (DBID=3292098349)
      RMAN> backup database plus archivelog delete input;
  2. Non-Oracle Datafiles
    • Bring the tablespace offline
    • SQL> alter tablespace USERS offline;
    • Copy the datafile to a new location. Always copy instead of move just in case something happened to the datafile.
    • $ cp /oradata/USERS01.dbf /oradata2
    • Rename the datafile
    • SQL> alter tablespace USERS
        2  rename datafile '/oradata/USERS01.dbf'
        3  to '/oradata2/USERS02.dbf';
  3. Temporary Tablespace
    • Create new tablespace in the new directory
      SQL> create temporary tablespace TEMP02
      2 tempfile ‘/oradata2/TEMP02.dbf’
      3 size 50M
      4 autoextend on 50M maxsize unlimited
      5 extent management local default;
    • Set this temporary tablespace as the default tablespace
      SQL> alter database default temporary tablespace TEMP02; 
  4. Copy/Move SYSTEM/SYSAUX/UNDOTBS1 Tablespaces
    • Database must be in mount state
    • SQL> shutdown immediate;
      Database closed.
      Database dismounted.
      ORACLE instance shut down.
      SQL> startup mount;
      ORACLE instance started.
      
      Total System Global Area  612368384 bytes
      Fixed Size                  1292036 bytes
      Variable Size             348129532 bytes
      Database Buffers          255852544 bytes
      Redo Buffers                7094272 bytes
      Database mounted. 
    • Copy all the affected datafiles to the new directory
    • $ cp /oradata/SYSTEM01.DBF /oradata2/SYSTEM01.DBF 
    • Rename the datafiles
    • SQL> alter database
        2  rename file '/oradata/SYSTEM01.DBF'
        3  to '/oradata2/SYSTEM01.DBF'; 
    • Do the same for the other datafiles
    • Open the database
    • SQL> alter database open;
      Database altered.

March 27, 2008

This Is Open Source

Filed under: geek stuffs — Alvin Sim @ 9:32 am

This is a good example of what open source means. I saw this notice on my office lobby’s wall :)

March 22, 2008

ORA 00257

Filed under: database, oracle, work — Alvin Sim @ 4:00 pm

While importing an Oracle’s dump file (15Gb) to one of our client’s schemas, I encountered a problem. My import script has the feedback parameter turned on for every 100,000 records. After an hour, my import was stuck. It should have gone through but somehow it didn’t for the last 200,000 thousand records.

I opened up a telnet session and logged into SQLPlus and executed “ALTER SYSTEM SWITCH LOGFILE”. It was stuck as well.

I then fired up TOAD and tried to connect to the database but it failed with ORA-00257.

So I googled it up and people in forums were saying that the disc space where the flash recovery area is is
full. So I did a df -k (Unix server) and checked the volume group still has 20% free space – around 10Gb. The volume group still has space. So, why am I getting ORA-00257?

I login to RMAN to remove obsolete and expired backups. But the imp I executed was still stuck.

The current retention policy was 3, so I changed it to 1 and removed obsolete backups again.

As a final solution, I jarred the archivelog directory and moved it to another directory and was about to execute the command DELETE ARCHIVELOG ALL;” in RMAN when suddenly I read somewhere that it’s not stating the disc space is full, but the lash Recovery Area is full.

This Flash Recovery Area size is set in Oracle’s parameter. I quickly logged into SQLPlus and did a “SHOW PARAMETER recovery;”.

The size set was 30G. So, I went to google again to look for the command to change the size to 35G. “ALTER SYSTEM SET db_recovery_file_dest_size=35G scope=both;”

Then I checked the imp function again and it continued to run. I then quickly started moving other miscellaneous files in that volume group to a different volume group and increasing the db_recovery_file_dest_size bit by bit every time ORA-00257 happened.

After finishing the import the FRA current size was 53Gb. The same error happened again when our users were using the system. Our application couldn’t login to the database. It was throwing out ORA-00257 again. So, the quickest solution then was to increase the db_recovery_file_dest_size to a bigger size and then figure out on a new destination for the flash recovery area so that a full database backup could be done.

What I should have before importing the dump file that night was to do a full backup of the database using RMAN plus the archive log files. This way, the older and obsolete archive logs could be removed to safe space.

Well, the point to this is actually ORA-00257 doesn’t not necessarily means the disc space is full. It could me the recovery destination has reached its maximum space allocated.

Older Posts »

Blog at WordPress.com.