O'Reilly Databases

oreilly.comSafari Books Online.Conferences.

We've expanded our coverage and improved our search! Search for all things Database across O'Reilly!

Search Search Tips

advertisement
AddThis Social Bookmark Button

Listen Print Discuss Subscribe to Databases Subscribe to Newsletters

Installing Oracle 9i on Mac OS X, Part 3
Pages: 1, 2, 3, 4

Create Oracle File Directories

For this example installation, external drive volumes named u01, u02, u03 will be used for the installation. On Mac OS X, external drives are mounted automatically by the automounter daemon, after being partitioned and erased by the Disk Utility. These disk volumes are located under the /Volumes directory once they are mounted by Mac OS X. Mac OS X can easily work with volume and directory names containing space characters if the HFS+ file system is used for a volume; it is recommended that spaces not be used in volume names/directories that will be used for Oracle files. The Oracle database software operates as any other UNIX application and is not as forgiving when dealing with these issues as Mac OS X!



Change the ownership of each of the top-level mount points and dump directories:

oracle% sudo mkdir /Volumes/u01/prod1
oracle% sudo mkdir /Volumes/u01/udump
oracle% sudo mkdir /Volumes/u01/cdump
oracle% sudo mkdir /Volumes/u01/bdump
oracle% sudo mkdir /Volumes/u02/prod1
oracle% sudo mkdir /Volumes/u03/prod1
oracle% sudo chown -R oracle:dba /Volumes/u01
oracle% sudo chown -R oracle:dba /Volumes/u02
oracle% sudo chown -R oracle:dba /Volumes/u03

Add the following info to the /Users/oracle/.bashrc file and add "source .bashrc" to the .bash_profile file so that you won't have to manually execute Oracle's set_ulimit script:

ulimit -c unlimited # max size of core dump file is unlimited
ulimit -d unlimited # maximum data file size
ulimit -s 65536 # set stacksize to 64Mb
ulimit -u 500 # max number of processes
ulimit -n 10000 # max number of open files

If you choose to use a different shell, like /bin/tcsh, then add the following limit settings to the .tcshrc file within the /Users/oracle directory:

limit coredumpsize unlimited
limit datasize unlimited
limit memoryuse unlimited
limit stacksize 64M
limit maxproc 500
limit descriptors 10000

I also recommend putting these values into the into the /private/var/root/.tcshrc file that will be used by the root account if you use the default tcsh shell. I have set the maximum number of processes to 500 and number of open files to 10000 because Mac OS X reports hard limits of 532 and 12288, respectively, on my Titanium Powerbook G4. These parameters don't cause problems if they are set higher than necessary; they only set maximum limits for resource usage. Feel free to adjust them lower if you like.

Update the /etc/profile file with the following environment variable enhancements:

ORACLE_BASE=/Users/oracle/v920
ORACLE_HOME=/Users/oracle/v920
PATH=$PATH:$ORACLE_HOME/bin
SRCHOME=$ORACLE_HOME
ORACLE_SID=prod1
CLASSPATH=$ORACLE_HOME/DBCreate/oradev/classes/orapts.jar:$ORACLE_HOME/jdbc/lib/classes12.zip:$CLASSPATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
DYLD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:$DYLD_LIBRARY_PATH
ORACLE_OWNER=oracle
ORAENV_ASK=NO
TNS_ADMIN=$ORACLE_HOME/network/admin
TERM=vt100
NLS_LANG=AMERICAN_AMERICA.US7ASCII

export TNS_ADMIN PATH ORACLE_HOME SRCHOME ORACLE_SID DYLD_LIBRARY_PATH CLASSPATH LD_LIBRARY_PATH ORACLE_OWNER ORAENV_ASK TERM NLS_LANG

You can verify the ulimit settings by using the ulimit command while logged in as the oracle UNIX user; this should show results similar to the following.

[G4:/Volumes/u01] oracle% ulimit -a -H
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (Kbytes, -l) unlimited
max memory size (Kbytes, -m) unlimited
open files (-n) 10000
pipe size (512 bytes, -p) 1
stack size (Kbytes, -s) 65536
cpu time (seconds, -t) unlimited
max user processes (-u) 500
virtual memory (Kbytes, -v) 9007199254806527

Note: If the hard process limits have not previously been set by root, then the oracle account will only be able to make changes up to the soft limit. This fact will probably affect the "max user processes" parameter more than any other, because it has a soft limit of 100. On a test server, this will not generally be an issue, but on a production server, you may commonly have a need for more than 100 user processes because each user or application logged into the server will generally spawn a new oracle process unless some type of connection pooling is implemented in the application.

The startup script listed below will set these process limits as the root user before invoking the database startup commands via an oracle UNIX account subshell process that will then use the limits specified in the .bashrc file.
If you want to avoid rebooting in order to get the higher values for the hard limits, put the tcsh version of the limit commands into the /private/var/root/.tcshrc file. Then open a new terminal session as root before executing the su - oracle command.

Create the Database Startup Script

The Oracle instructions for Developer Release 1 specify the use of the allup.sh script to be run manually to start up the database, and the use of the alldown.sh script to shut down the database before the Mac OS X server is shut down. This startup/shutdown procedure should be automated to ensure that the database can be started up or shut down unattended. Automating this task will ensure database availability upon server startup and prevent a known issue with datafile corruption if the database is not shut down properly before Mac OS X shuts down.

Unfortunately, it is not currently possible to run a shut down script with Mac OS X, so for now this task will still need to be performed manually. The startup script presented here does contain the shutdown code, in preparation for Apple's update of Mac OS X beyond version 10.2.2 to correct this issue. Two files are used by the Mac OS X SystemStarter in order to run scripts or applications upon system startup. The first file is either a binary executable or, more commonly, an executable shell script located within a directory with the same name as the executable file within /Library/StartupItems. The second file is a configuration property list file named StartupParameters.plist, located within the same directory as the startup script. This property list file contains the text describing the item to be started, along with dependencies and services provided.

Create an Oracle directory within /Library/StartupItems and put the executable script listed in Listing #1 into this directory. This script should be given the name of the enclosing directory, which will be Oracle (not Oracle.sh). Note: Some Mac OS X books (not written by O'Reilly!) incorrectly give examples of installing startup scripts in the path /System/Library/StartupItems/*. The directory paths under /System/Library/StartupItems and /Network/Library/StartupItems are reserved for startup scripts created and installed by Apple as part of the core operating system. The path under /Library/StartupItems is available for developers and system administrators to use for additional startup scripts that they may add to the server. For more details about the startup process, please see Chapter 4 of the Inside Mac OS X: System Overview book.

oracle% sudo mkdir /Library/StartupItems/Oracle
oracle% sudo chmod 700 /Library/StartupItems/Oracle/Oracle
oracle% sudo chown root:wheel /Library/StartupItems/Oracle/Oracle
oracle% sudo cp Oracle_startup /Library/StartupItems/Oracle/Oracle
oracle% sudo cp StartupParameters.plist /Library/StartupItems/Oracle/StartupParameters.plist
oracle% sudo chown root:wheel /Library/StartupItems/Oracle/StartupParameters.plist

Listing #1 -- filename: /Library/StartupItems/Oracle/Oracle

#!/bin/bash
# define globally used paths/variables
PATH=/bin:/sbin:/usr/bin:/usr/sbin:.
ORACLE_BASE=/Users/oracle/v920
ORACLE_HOME=/Users/oracle/v920
ORACLE_OWNER=oracle
ORACLE_OWNER_PATH=/Users/oracle
ORACLE_GROUP=dba
PATH=$PATH:$ORACLE_HOME/bin
SRCHOME=$ORACLE_HOME
ORACLE_SID=prod1
CLASSPATH=$ORACLE_HOME/DBCreate/oradev/classes/orapts.jar:$ORACLE_HOME/jdbc/lib/classes12.zip:$CLASSPATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
DYLD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:$DYLD_LIBRARY_PATH
ORAENV_ASK=NO
TNS_ADMIN=$ORACLE_HOME/network/admin
TERM=vt100
NLS_LANG=AMERICAN_AMERICA.US7ASCII

export PATH ORACLE_BASE ORACLE_HOME SRCHOME ORACLE_SID CLASSPATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH ORACLE_OWNER TNS_ADMIN TERM NLS_LANG

# the following ulimit parameters are required by the Oracle database on Mac OS X
ulimit -c unlimited
ulimit -d unlimited
ulimit -s 65536
ulimit -u 500
ulimit -n 10000

ORA_BDUMP_DIR=/Volumes/u01/bdump/
OEM_ADMIN=admin
OEM_ADMIN_PASSWORD=zx-vnm

export OEM_ADMIN OEM_ADMIN_PASSWORD ORA_BDUMP_DIR

# get common system config settings
. /etc/rc.common

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo 'Oracle startup: cannot start'
echo ' (cannot find one or both of dbstart or $ORACLE_HOME)'
exit
fi

StartService()
{

# Rotate the Oracle alert error log before database starts
LOG=alert_$ORACLE_SID.log
cd $ORA_BDUMP_DIR
test -f $LOG.5 && mv $LOG.5 $LOG.6
test -f $LOG.4 && MV $LOG.4 $LOG.5
test -f $LOG.3 && MV $LOG.3 $LOG.4
test -f $LOG.2 && MV $LOG.2 $LOG.3
test -f $LOG.1 && MV $LOG.1 $LOG.2
test -f $LOG.0 && MV $LOG.0 $LOG.1
MV $LOG $LOG.0

ConsoleMessage 'Starting Oracle databases...'
su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbstart
ConsoleMessage 'Started Oracle database.'

ConsoleMessage 'Starting Oracle Intelligent Agent...'
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/agentctl start"
ConsoleMessage 'Started Intelligent Agent.'

ConsoleMessage 'Starting Oracle listener...'
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
ConsoleMessage 'Started Listener.'

# ConsoleMessage 'Starting Oracle Enterprise Management Server'
# su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/oemctl start oms &"
# ConsoleMessage 'Started OMS.'

}

StopService()
{

# stop in reverse order from startup process
# ConsoleMessage 'Stopping Oracle Enterprise Management Server'
# su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/oemctl stop oms $OEM_ADMIN/$OEM_ADMIN_PASSWORD &"
# ConsoleMessage 'Stopped OMS.'

ConsoleMessage 'Stopping Oracle Intelligent Agent'
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/agentctl stop"
ConsoleMessage 'Stopped Intelligent Agent.'

ConsoleMessage 'Stopping Oracle listener...'
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"
ConsoleMessage 'Stopped Listener.'

ConsoleMessage 'Stopping Oracle databases...'
su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbshut
ConsoleMessage 'Stopped Oracle database.'

}

RestartService()
{

# stop in reverse order from startup process
# ConsoleMessage 'Stopping Oracle Enterprise Management Server'
# su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/oemctl stop oms $OEM_ADMIN/$OEM_ADMIN_PASSWORD &"
# ConsoleMessage 'Stopped OMS.'

ConsoleMessage 'Stopping Oracle Intelligent Agent'
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/agentctl stop"
ConsoleMessage 'Stopped Intelligent Agent.'

ConsoleMessage 'Stopping Oracle listener...'
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"
ConsoleMessage 'Stopped Listener.'

ConsoleMessage 'Stopping Oracle databases...'
su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbshut
ConsoleMessage 'Stopped Oracle database.'

# Rotate the Oracle alert error log before database starts
LOG=alert_$ORACLE_SID.log
CD $ORA_BDUMP_DIR
test -f $LOG.5 && MV $LOG.5 $LOG.6
test -f $LOG.4 && MV $LOG.4 $LOG.5
test -f $LOG.3 && MV $LOG.3 $LOG.4
test -f $LOG.2 && MV $LOG.2 $LOG.3
test -f $LOG.1 && MV $LOG.1 $LOG.2
test -f $LOG.0 && MV $LOG.0 $LOG.1
MV $LOG $LOG.0

ConsoleMessage 'Starting Oracle databases...'
su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbstart
ConsoleMessage 'Started Oracle database.'

ConsoleMessage 'Starting Oracle Intelligent Agent...'
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/agentctl start"
ConsoleMessage 'Started Intelligent Agent.'

ConsoleMessage 'Starting Oracle listener...'
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
ConsoleMessage 'Started Listener.'

# ConsoleMessage 'Starting Oracle Enterprise Management Server'
# su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/oemctl start oms &"
# ConsoleMessage 'Started OMS.'

}

RunService "$1"



Pages: 1, 2, 3, 4

Next Pagearrow




Tagged Articles

Be the first to post this article to del.icio.us

Sponsored Resources

  • Inside Lightroom

Related to this Article

Understanding Oracle Clinical Understanding Oracle Clinical
by Joan M. Johnson
May 2007
$9.99 USD

Inside SQLite Inside SQLite
by Sibsankar Haldar
April 2007
$9.99 USD

Advertisement
O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
O'Reilly FYI
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com