Monday, July 27, 2009

Installing Oracle on RHEL 5 (32 and 64 bit) - Part 3

In part one of this series, we got the operating system ready for the installation of Oracle. In part two, we got Oracle installed and running. In this, our final (for now) post on Oracle and Linux, we'll look at some of the tweaks that make it better, as well as some of the surprising bumps one encounters when using Oracle on Linux.


ORA-00845 - MEMORY_TARGET not supported on this system

This error is common, and it occurs most frequently when the Linux /dev/shm mount point isn't large enough. Specifically, your SGA and PGA are sized such that there isn't enough space in /dev/shm for the instance to start. So, to fix it:
mount -t tmpfs shmfs -o size=1300m /dev/shm
where 1300m is whatever size that will at least cover your MEMORY_TARGET parameter. Once you've got a value for /dev/shm set that works, you can add it to /etc/fstab, such that it'll be a permanent change. Edit /etc/fstab, and add the following line, adjusting the size to fit your environment:
shmfs /dev/shm tmpfs size=1300m 0 0

Enable Arrow Keys in SQLPlus

One of the best things about using SQLPlus is the ability to up arrow through your command history. As it turns out, though, this functionality isn't available in sqlplus on Linux. It makes for a most unsatisfying experience. Fortunately, there's a simple program -- rlwrap -- that can fix this for us.

Download rlwrap

Download the rlwrap archive here, and extract it to a temporary directory. The INSTALL document is pretty straightforward for compiling and installing it. Once it's installed, you can create an alias using rlwrap, such that it'll provide a keyboard wrapper for sqlplus, allowing you to use the arrow keys.

Create the rlwrap alias

There are two thoughts on what to do with the alias for sqlplus. I'll lay them out, and you can decide which is the better option. Option One is simply to create an alias called "sqlplus", in essence replacing the program call with the alias. This has simplicity in its favor: whenever you or anyone else log in to the system to run sqlplus, it'll behave as it should, and you won't have to think about it. But there's a downside, as well: when someone calls a program by name, it's usually expected that the program is what is running. When you create an alias using the program's name, you introduce the possibility of confusion in troubleshooting a problem later on. Should something happen with rlwrap or one of the libraries it relies upon, sqlplus (unless called with a fully qualified path) could quit working. The risk of confusion is especially great if the person doing the troubleshooting isn't the person who set up the alias: then there's no chance of remembering that the alias is there. Here, should you choose option one, is how you'd set up the rlwrap alias (we'll throw in rman as a bonus):
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
So enter Option Two. This is just creating an alias -- just as above -- with a name besides sqlplus. Using a name that isn't the program name has the advantage of avoiding any possible confusion about what you're doing: if it quits working, it's easy to see if the problem lies with sqlplus or with the alias. The downside is that it's a different command. Sqlplus is the program one uses to execute SQL in Oracle; it will not occur to anyone to use something else. Here's something like what you'd use to create an alias (we'll call them sqlp and rmanp, but they can be pretty much anything):
alias sqlp='rlwrap sqlplus'
alias rmanp='rlwrap rman'
Both options offer something good, and both have a downside. Pick the one that works for you, and make sure your colleagues all know about the changes you made.

A third option

There exist a handful of drop-in sqlplus replacements that many opt for, as well. gqlplus is one of these. For my part, I prefer to stay away from compiled replacements for sqlplus; whatever wrapper goes in front of the application, when it's all said and done I want the Oracle-supplied application communicating with the database.

No comments:

Post a Comment

Thanks for leaving a comment!