vicker313 tech blog

February 24, 2013

Add Local Storage as Raw Disk Mapping in ESX

Filed under: VMWare — Tags: , , , — vicker313 @ 7:39 am

In newer version of VMWare (example version 5), you can only Raw Disk Mapping (RDM) a SAN storage, and not the local storage or harddisk. However there is a trick to do this:

  1. Log in as root through ssh or just go to the console terminal (refer Enable SSH at ESX Host)
  2. Now you need to find out the physical disk path that you will be doing RDM, using either the following commands:
    • esxcfg-mpath -l
    • ls -al /vmfs/devices/disks
  3. Then you need to map the disk as a virtual disk using following command:
    vmkfstools -r /vmfs/devices/disks/<physical disk path> /vmfs/volumes/<vmfs datastore name>/<folder name>/<virtual disk name>.vmdk

Now you can view the physical disk as virtual disk and add it to VM.

Reference: Add Local Storage (e.g. a SATA disk) as a Raw Disk Mapping (RDM) or Mapped RAW LUN to a virtual machine hosted on ESXi

Enable SSH at ESX Host

Filed under: VMWare — Tags: , , — vicker313 @ 7:22 am

In newer version of ESX such as version 5, you have the option to enable the SSH daemon from the console menu (console directly from the host). However for older version like version 3, you need to do some tricks for it to happen:

  1. At the console, hit Alt+F1
  2. You will enter into console terminal, but you won’t see any prompt. Just key in “unsupported” (without quote) and press enter.
  3. Now you can see the prompt, edit /etc/inetd.conf using any editor (vi or nano)
  4. Look for the line with ssh, uncomment it.
  5. Exit from editor, then you need to stop the inetd process by killing it.
    1. Issue ps|grep inetd
    2. Find out the inetd process id and kill it using kill <process id>
  6. Start the inetd daemon by issuing the command inetd

Now you should able to connect the ESX host through SSH.

Reference: Get full control over your ESXi Server

December 4, 2012

How to adjust Tomcat PermGen Space Size

Filed under: Tomcat — Tags: , — vicker313 @ 8:10 pm

When we putting more than 3 applications in Tomcat Webapp, we might experience slowness and eventually application crash, even after we have increase Tomcat reserved memory. It is normally refer as Out of Memory Error in PermGen space.

Default PermGen space size is 64MB. To increase it, similar to increase Tomcat reserved memory, we need to edit $TOMCAT/bin/catalina.bat (or catalina.sh in Linux) and look for JAVA_OPTS:

set JAVA_OPTS = ""

Add in -XX:PermSize=500m -XX:MaxPermSize=500m to JAVA_OPTS. If JAVA_OPTS exists with other parameters, just append the new parameters to it.

set JAVA_OPTS = "-Xms2000m -Xmx2000m -XX:PermSize=500m -XX:MaxPermSize=500m"

It is recommended to set size as 1/4 of the reserved memory, eg 1/4 of the 2GB reserved memory will be 500MB PermGen space size.

Other reference: 2 solution of java.lang.OutOfMemoryError in Java

February 2, 2012

Oracle PL/SQL Script to Find Table(s) Based on Column Name and Value

Filed under: Oracle — Tags: , , — vicker313 @ 8:12 pm

Here is a simple oracle PL/SQL script, to find table(s) based on a column name and value that match with it. Just copy the scripts below and run it in SQL Plus. It will prompt user to enter the column name, the value you want to match and the schema, then it will show the table name and row count.

set serveroutput on
declare
col varchar2(20) := '&column_input';
val varchar2(20) := '&value_input';
cursor c is select table_name
from dba_tab_columns
where owner = '&owner_input'
and column_name = col;
cnt number;
begin
for r in c loop
cnt := 0;
execute immediate 'select count(*) from ' || r.table_name ||
' where ' || col || ' = ''' || val || '''' into cnt;
dbms_output.put_line(r.table_name || ': ' || cnt);
end loop;
end;
/
set serveroutput off

November 26, 2011

Setup CRON job to Trigger an URL

Filed under: Server — Tags: , — vicker313 @ 7:42 pm

The following CRON script can be used to trigger an URL (example below is schedule to run every minute, for other schedule setting please refer to other CRON tutorial).

0 * * * * wget -q -O - http://www.example.com/notify.php >/tmp/cron 2>&1

In Linux, wget is used to download file from internet (or network). -q option means quiet, -O means output file. It is important to put the -O option so that your server won’t end up with annoying CRON output file.

August 12, 2011

Make Tomcat Auto Start in Linux

Filed under: Tomcat — Tags: , — vicker313 @ 7:50 am

Here is another method to install tomcat startup script in Linux (there is another method in my earlier post)

  1. Download tomcat and rename the file name from tomcat.doc to tomcat only (remove the extension)
  2. Put the file under /etc/inid.d
  3. Give execute privilege to the file (chmod +x /etc/init.d/tomcat)
  4. Adjust 2 parameters in the file, TOMCAT and JAVA_HOME.
  5. Add the file into service list (chkconfig ––add tomcat)
  6. Done!
Now you can double check whether tomcat is inside your service list or not by using “chkconfig ––list tomcat”. To start or stop tomcat, simply “service tomcat start” and “service tomcat stop”.

June 11, 2011

Copy or Move Oracle Database

Filed under: Oracle — Tags: , , — vicker313 @ 12:18 pm

Consider the following scenario: I got a oracle database that reside in /db/mydb. For some reason I need to copy or move the database to somewhere else, let’s say /db2/mydb2.

To do this, follow the steps:

  1. Shutdown the database either using service or sql statement: shutdown immediate.
  2. Copy or move the database to /db2 and rename the new database directory to mydb2.
  3. Edit the initialize parameter file in the mydb2 (something like initxxx.ora), change the all the paths to the new path (from /db/mydb to /db2/mydb2)
  4. Log in to sqlplus with NOLOG (run in terminal): sqlplus /nolog
  5. Connect to empty instance (run in SQLPLUS): connection / as sysdba
  6. Create SPFILE, aware that the path of the initialize parameter file might be vary (run in SQLPLUS): create spfile from pfile='/db2/mydb2/admin/pfile/initxxx.ora';
  7. Start database in mount mode (run in SQLPLUS): startup mount;
  8. Change the data file path to the new path (run in SQLPLUS): alter database rename file '/db/mydb/data.dbf', '/db/mydb/system.dbf' to '/db2/mydb2/data.dbf', '/db2/mydb2/system.dbf';
  9. Ensure you change all the data file path! Or else it will cause the orginal database cannot be startup! (Refer updates below)
  10. Open your database (run in SQLPLUS): alter database open;
  11. Now it is good to go.

If you want to run both databases in the same time, you need to rename the new database. Follow the following steps:

  1. Rename the new database to mydb2
  2. Remember to change the database name in mydb2 parameter file as well.
  3. Log into SQLPLUS. At this point, you need to aware the SID_NAME in your environment parameter, need to be point to the database that you want to log in. Now we want to log in to the original, so we set the SID_NAME to mydb (terminal): export SID_NAME=mydb
  4. Connect to empty instance (SQLPLUS): connect / as sysdba
  5. Create the SPFILE again using the original parameter file (SQLPLUS): create spfile from pfile='/db/mydb/admin/pfile/initxxx.ora';
  6. Now you should able to start your database (SQLPLUS): startup

Update 2013/2/24

You may find out the data files path using the following query (thanks to Concerned_Netizen):

  • select name from v$datafile
  • select member from v$tempfile
  • select member from v$logfile

June 8, 2011

Recover Root Password in RHEL6

Filed under: Linux — Tags: , , — vicker313 @ 10:59 pm

There are a lot of guide lines on recovering ROOT password in a Red Hat or Fedora, by entering single user mode and change the ROOT password using passwd command. However the trick isn’t work in RHEL 6 any more, where issuing the passwd command in single user mode will not prompt you to enter the new password.

Here is a trick where I discover in order to recover the ROOT password in RHEL6.

  1. First enter single user mode. To do this, boot your machine and wait until the message to enter GRUB (the one with a counter). Press any key to enter GRUB, then press e to edit the boot argument. Just append the word single at the back of the arguments and press enter to continue boot.
  2. You should enter single user mode, with the root prompt. Instead of using entering only passwd, enter the following command:passwd -d root
  3. “-d” is meant for making the password blank. Now your root password should be blank. Reboot your machine and change your ROOT password.

Rebuild Partition after Change Hard Disk in Disk Array of HPUX Machine

Filed under: HPUX — Tags: , , , — vicker313 @ 10:38 pm

A little experience on dealing with Disk Array in HPUX machine to be shared.

It is happened at an old HPUX machine with disk array attached. After 2 of the hard disks in the disk array are being replaced, the new hard disks cannot be seen in SAM. To discover back the missing hard disks, issue the following command:

armdiscover <array alias>

After the command, you should able to see the hard disks in SAM, and even can see the unmounted partitions. However you wouldn’t able to do anything with it, either mount it, remove it or recreate it. You should get some errors like “can’t find /dev/dsk/cxtxdx”. Then issue the following command:

armdsp -s <array alias>

This command will show the hard disks path in the disk array. You will see that the path is not the same inside the error. The unmounted partitions are actually still referring to the old hard disk path, where you need to remove it using the following command:

vgreduce -l /dev/vgxx /dev/dsk/cxtxdx

You must include “-l” in the command to remove the missing path. After that you need to add back the actual hard disk path either using SAM or vgextend command, and everything should be back to normal.

April 8, 2011

Turn on MYSQL Trace Feature

Filed under: MySQL — Tags: , — vicker313 @ 2:34 pm

To turn on MySQL trace feature, simply issue following command in MySQL console (OFF to turn off)

SET GLOBAL general_log = 'ON';

Or add following option to MySQL start up command (to turn off use 0):

mysqld --general_log=1

You can find the trace log at the database folder. The file name is something like host_name.log.

Older Posts »

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.