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:
- Log in as root through ssh or just go to the console terminal (refer Enable SSH at ESX Host)
- Now you need to find out the physical disk path that you will be doing RDM, using either the following commands:
ls -al /vmfs/devices/disks
- 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
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:
- At the console, hit Alt+F1
- You will enter into console terminal, but you won’t see any prompt. Just key in “unsupported” (without quote) and press enter.
- Now you can see the prompt, edit
/etc/inetd.conf using any editor (vi or nano)
- Look for the line with ssh, uncomment it.
- Exit from editor, then you need to stop the inetd process by killing it.
- Find out the inetd process id and kill it using
kill <process id>
- Start the inetd daemon by issuing the command
Now you should able to connect the ESX host through SSH.
Reference: Get full control over your ESXi Server
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 = ""
-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
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
col varchar2(20) := '&column_input';
val varchar2(20) := '&value_input';
cursor c is select table_name
where owner = '&owner_input'
and column_name = col;
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);
set serveroutput off
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.
Here is another method to install tomcat startup script in Linux (there is another method in my earlier post)
- Download tomcat and rename the file name from tomcat.doc to tomcat only (remove the extension)
- Put the file under /etc/inid.d
- Give execute privilege to the file (chmod +x /etc/init.d/tomcat)
- Adjust 2 parameters in the file, TOMCAT and JAVA_HOME.
- Add the file into service list (chkconfig ––add tomcat)
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”.
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
To do this, follow the steps:
- Shutdown the database either using service or sql statement:
- Copy or move the database to
/db2 and rename the new database directory to
- Edit the initialize parameter file in the
mydb2 (something like initxxx.ora), change the all the paths to the new path (from
- Log in to sqlplus with NOLOG (run in terminal):
- Connect to empty instance (run in SQLPLUS):
connection / as sysdba
- 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';
- Start database in mount mode (run in SQLPLUS):
- 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';
- Ensure you change all the data file path! Or else it will cause the orginal database cannot be startup! (Refer updates below)
- Open your database (run in SQLPLUS):
alter database open;
- 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:
- Rename the new database to mydb2
- Remember to change the database name in
mydb2 parameter file as well.
- 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
- Connect to empty instance (SQLPLUS):
connect / as sysdba
- Create the SPFILE again using the original parameter file (SQLPLUS):
create spfile from pfile='/db/mydb/admin/pfile/initxxx.ora';
- Now you should able to start your database (SQLPLUS):
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
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.
- 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.
- You should enter single user mode, with the root prompt. Instead of using entering only
passwd, enter the following command:
passwd -d root
- “-d” is meant for making the password blank. Now your root password should be blank. Reboot your machine and change your ROOT password.
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.
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):
You can find the trace log at the database folder. The file name is something like host_name.log.