File-based Swap for Linux

Posted October 28, 2010 by Joey
Categories: Linux, System Administration

Tags: ,

You forgot to create a swap filesystem on Linux, and you don’t know or don’t want to use fdisk to repartition a disk and create swap space.

What do you do?

Fortunately, you still have a chance of saving your job.

1. Logon as root

2. Create a new directory anywhere that you prefer to use as swap fs. I prefer creating under the root directory and name it as /swapfs

mkdir /swapfs

3. We will create a data dump of a bunch of zeroes and store it in a X-bytes worth of file. The X-bytes will represent the size of swap file that you want or need. What is the ideal size? My answer has always been, it depends! If its just your PC for browsing the internet etc…, same size with your RAM will do. If its a database server, you may not want to use swap intensively, so blow up your RAM instead. I typically benchmark it from half of my RAM, to even twice my RAM. Again, it depends on what type application is running on your server or PC.

dd if=/dev/zero of=/swapfs/swap bs=1M count=4096

I am creating here a 1 megabyte swap file. It will create a file named swap under the directory /swapfs

4. I’ll now assign /swapfs/swap file as a SWAP space

mkswap /swapfs/swap

5. Of course, that is not enough, you have to enable it

swapon /swapfs/swap

If you’ll issue a df command, you’d be able to see the new swap filesystem, and the top command will also display the additional swap space.

Oracle Wait Classes

Posted October 28, 2010 by Joey
Categories: Database Administration, Databases, Oracle

Tags: , ,

Here is my favorite SQL  on getting a feel of what is slowing my system down


select wait_class, sum(total_waits), sum(time_waited), round(sum(time_waited)/sum(total_waits),2) WAIT_TIME_PER_TXN
from V$SERVICE_WAIT_CLASS
where service_name='RECONPRD' group by wait_class
order by sum(time_waited)/sum(total_waits) desc

This would immediately tell me how much time is spent (or “wasted”) on any DB component.

As a DBA, it would be of interest to me to maintain wait classes that are high on Administrative, Configuration, Concurrency. I would definitely hit the programmers when it comes Application-related wait events, and the System Administrators for Disk I/O related wait times.

1. Administrative – Commands issued by a privileged user (that is, DBA) that result in other users waiting—an index rebuild, for example.
2. Application  – Generally related to application design, this category includes lock waits caused by row-level locking and explicit or implicit lock commands (implicit lock commands such as those generated by a DDL statement).
3. Cluster  Global cache, global enqueue, and global messaging – related wait events in a RAC environment.
4. Commit -  Currently only includes a wait event for redo log sync confirmation after a commit.
5. Concurrency -  Generally, waits involving concurrent parsing and buffer cache latch and lock contention; indicative of many sessions going after the same resources.
6. Configuration -  Wait events in this category can generally be resolved by tuning; includes undersized log buffer space, logfile sizes, buffer cache size, shared pool size, ITL allocation, HW enqueue contention, ST enqueue contention, and so on.
7. Idle  Session is inactive.
8. Other  – Catchall for wait events not associated with one of the predefined classes.
9. Network  – Waits for data to be sent over the network—specifically waits in the networking layer or on hardware.
10. Scheduler -  Waits due to Resource Manager prioritization.
11. System I/O  – Waits on I/O done by background processes (except for MMON and SMON).
12. User I/O -  Wait for blocks to be read off disk by foreground process, SMON, or MMON.

References:

Oracle-Dox.Net

Beach Kids

Posted August 3, 2010 by Joey
Categories: Photography, Sepia

Tags: , ,

Berks

Pre-Backflip

Backflip

Backflip

Failed Implementation of New Buffer Pool on DB2 UDB v8

Posted May 3, 2010 by Joey
Categories: Database Administration, DB2

Tags: ,

We had this experience when we tried to create a new bufferpool on DB2 v8 running on an AIX v5.3 server, wherein we noticed that the bufferpool creation is taking time, and we had to cancel it. The reason for this is that an incorrect parameter was submitted, specifically the size of the buffer pool. The size of the buffer pool being created was 256GB and we only had 24GB of RAM.

After canceling the creation, we can no longer use the server, and that we had to to do a db2_kill. We had to reboot the server, restart DB2 via Db2start. The other databases will start  after  a successful crash recovery, but the last one, where we created the BP, would then trigger the memory and paging space usage high again.

this is when we discovered that since crash recovery makes use of archive logs to recover, it tries to redo the create bufferpool, thus we cannot start the database. Fortunately, we found a site on IBM specifically  dealing with this case.

We had to stop DB2, and issue a

db2iupdt -w 32 <instance name>

This converts the instance to 32-bit mode, which is immune to this case of irregular size of buffer pool. You can now startup  db2 normally. To move forward the archive log recovery, we had to run a backup, for the database to recognize a new set of archive logs and not to read the old logs with the create BP statement. After the backup, we reverted back to 64-bit mode by issuing

db2iupdt -w 64 <instance name>

We were then able to recover the Database with no damage data.

Grotto. Boracay, Philippines

Posted December 2, 2009 by Joey
Categories: Travel

Tags:
Grotto @ Boracay

Grotto @ Boracay

Subaru Impreza Challenge

Posted November 18, 2009 by Joey
Categories: Living

Tags:

I’m planning on purchasing a Subaru Impreza RS 2.0 MT. However, I’m bothered with its TCO (total cost of ownership)

I’m referring to incidental costs (e.g. repairs on top of the regular maintenance costs), because we can always budget or prepare for the maintenance costs (operating expenses)

Anyone?

SPSS Doesn’t Know Its Addition

Posted November 16, 2009 by Joey
Categories: Programming, Technology

Tags:

 

Stupid SPSS

Stupid SPSS

Try adding up the values on the Frequency field and see if it matches the total

 

 

 

Kia Soul @ CEL 2009 World Trade Center

Posted November 15, 2009 by Joey
Categories: Living

Tags:

Kia Soul is quite tempting. I’m tempted to acquire this over an Honda Civic. Let’s see what would be the result of my test drive tomorrow!

Kia Soul 2009

Kia Soul 2009

Compressing Oracle Tables in Oracle 11g R2

Posted November 15, 2009 by Joey
Categories: Databases, Programming

Tags: ,

Here’s a neat trick I learned on Oracle 11g R2. Compressing Oracle tables

alter table mytable move compress;

Compression depends on the cardinality of data per field on your table. The more that a value repeats itself on a field, the higher the compression is. As i understand it, the algorithm is highly similar with how compression works on Winzip and Gzip.

On one of my produciton tables, I was able to achieve almost 10x compression (a 9.2GB table was compressed to 1GB).

Compression comes at a price though, Read-write will be penalized as the application has to decompress the table prior to writing.

SAS PROC EXPORT via terminal: proc export cannot open X display

Posted November 15, 2009 by Joey
Categories: Programming, Technology

Tags: ,

This error will appear if you have a SAS batch job that triggers a proc export via shell (on Unix systems e.g. HP-UX, AIX, RHEL), or you are simply on the SAS command shell, and x-window is not enabled on your client PC.

To resolve this, save the job on a text file and save it as .sas file.

Trigger your job by using the ff command

!SASROOT/sas -sysin yourprogram.sas -noterminal

 


Follow

Get every new post delivered to your Inbox.