Blogo Baggins home

Installing Oracle Natively on OS X Leopard

June 23, 2009 – Leesburg, VA

Oracle on OS X Leopard

Oracle 10g server was recently ported1 to run on OS X Leopard. Besides the ginormous installation guide by Oracle, there are a handful of helpful quick install guides already out there. Following them, though, I found that I still had issues installing it, and had additional needs that required sifting through comments, googling, etc.

So, here are my notes, borrowed heavily from the resources below. Perhaps they will alleviate some of the pain I experienced, for other souls unfortunate enough to have to install and use this overly-complicated database.




Create the oracle user and dba group

  1. Start downloading the Oracle binaries for OS X.
  2. Open /Applications/Utilities/
  3. Let’s use 4200 as the GUI and UID, so check if they are available:
    cmurphy:~ oracle$ dscl . -list /groups gid | grep 4200
    cmurphy:~ oracle$ dscl . -list /users uid | grep 4200
  4. Create the oracle account in the dba group:
    cmurphy@cmurphy$ sudo dscl . -create /groups/dba
    sudo dscl . -append /groups/dba gid 4200
    sudo dscl . -append /groups/dba passwd "*"
    sudo dscl . -create /users/oracle
    sudo dscl . -append /users/oracle uid 4200
    sudo dscl . -append /users/oracle gid 4200
    sudo dscl . -append /users/oracle shell /bin/bash
    sudo dscl . -append /users/oracle home /Users/oracle
    sudo dscl . -append /users/oracle realname \
     "Oracle software owner"
    sudo dscl . -append /Groups/dba GroupMembership oracle
    sudo mkdir /Users/oracle
    sudo chown oracle:dba /Users/oracle
    sudo defaults write /Library/Preferences/ \
     HiddenUsersList -array-add oracle
    sudo passwd oracle # use a good password
  5. Add the following to /etc/sysctl.conf (create the file if needed) with sudo:
  6. Reboot. Yes, you have to.
  7. Use oracle’s home directory /Users/oracle for Oracle’s installation directory (oracle base):
    cmurphy@cmurphy$ cd /Users/oracle/
    cmurphy@cmurphy$ sudo mkdir oracle
    cmurphy@cmurphy$ sudo chmod 775 oracle
  8. Login as oracle user and create a bash profile:
    cmurphy@cmurphy$ su - oracle
    cmurphy@cmurphy$ vi .bash_profile
  9. Put the following in .bash_profile:
    # Must match kern.maxprocperuid
    ulimit -Hu 512
    ulimit -Su 512
    # Must match kern.maxfilesperproc
    ulimit -Hn 10240
    ulimit -Sn 10240
    export ORACLE_BASE=/Users/oracle/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
    export ORACLE_SID=dev

Install Oracle

  1. launch the X11 application:
    Applications -> Utilities -> X11
  2. login as oracle user
    [cmurphy@cmurphy]$su - oracle
  3. export the DISPLAY variable so the Oracle installer will launch.
    cmurphy:~ oracle$ export DISPLAY=localhost:0
  4. Trick the Oracle Installer to use localhost (useful if you use DHCP for your network configuration3):
    cmurphy:~ oracle$ export ORACLE_HOSTNAME=localhost
  5. Launch the Oracle installer (I unzipped the Oracle binary in oracle’s home directory):
    cmurphy:~ oracle$ /Users/oracle/db/Disk1/runInstaller
  6. Select the Advanced installation option on the first screen.
  7. Specify the location for the Oracle inventory to be under $ORACLE_BASE: /Users/oracle/oracle/oraInventory
  8. Specify the Inventory OS group: dba
  9. Leave defaults for the rest of the screens until it’s time to select a SID
  10. Use dev for the Global Database Name and SID.
  11. You can also tick the box to create sample schemas on the same screen so you have some data to play with.
  12. Set passwords for the internal Oracle users. I set the same password for all users.
  13. Click Install.
  14. While installing iSqlPlus, the installer will prompt you to manually execute two scripts: and Run them with sudo.
  15. When done, close the X11 application.

Connecting to dev

  1. Start the listener:
    [cmurphy@cmurphy]$su - oracle
    cmurphy:~ oracle$ lsnrctl start
  2. Use SQL*Plus to point the local listener to the dev tnsname:
    cmurphy:~ oracle$ sqlplus system@dev

    SQL> show parameter listener
    NAME             TYPE        VALUE
    ---------------- ----------- -----------------
    local_listener   string      LISTENER_DEV
    remote_listener  string

    SQL> alter system set local_listener='DEV';
    System altered.

    SQL> alter system register;
    System altered.
  3. Make sure your tnsnames.ora4 file contains the following:
    DEV =
        (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = dev)

Administer Oracle from a non-oracle user.

You’ll likely want to administer your database using your normal account, not the oracle account (if not, you’re done). To do so, we need to relax some permissions. There is a script that does just this at $ORACLE_HOME/install/ However, the is not adapted to OS X and uses the wrong default utility locations (like awk, grep, etc.).

See this if you’d like more detail.

  1. Edit and fix the locations:
    [cmurphy@cmurphy]$su - oracle
    cmurphy:~ oracle$ vi $ORACLE_HOME/install/
  2. Find the Macros section, and replace with the following:
    # Macros
  3. Run the script:
    cmurphy:~ oracle$ ./
  4. Startup/shutdown of Oracle database: edit /etc/oratab with sudo and change the N to Y at the end of line for ORCL database – this will be used by the dbstart utility to find which databases should be started automatically.
  5. Add the following to your user account’s .bashrc (or .bash_profile, .bash_local, whatever):
    # Must match kern.maxprocperuid
    ulimit -Hu 512
    ulimit -Su 512
    # Must match kern.maxfilesperproc
    ulimit -Hn 10240
    ulimit -Sn 10240
    export ORACLE_BASE=/Users/oracle/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
    export ORACLE_SID=dev
    alias ostart="sudo -u oracle /bin/bash -l -c
     '$ORACLE_HOME/bin/dbstart $ORACLE_HOME'"
    alias oshut="sudo -u oracle /bin/bash -l -c
     '$ORACLE_HOME/bin/dbshut $ORACLE_HOME'"
  6. Restart your Terminal tab to pick up the bash changes.
  7. Now, from your own user account, you can start/shutdown the Oracle database with ostart and oshut, and connect using sqlplus, sqlldr, etc.:
    [cmurphy@cmurphy]$ oshut
    Processing Database instance "dev": log file

    [cmurphy@cmurphy]$ ostart
    Processing Database instance "dev": log file
    [cmurphy@cmurphy]$ sqlplus system@dev

    SQL*Plus: Release - Production on Tue Jun 16...
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Enter password:
    Connected to:
    Oracle Database 10g Enterprise Edition Release
    With the Partitioning, OLAP, Data Mining and Real Application...
    SQL> select * from dual;
  8. Done!

1 And released April 11th, 2009.

2 The Oracle install guide claims OS X Server is required. Ignore that: desktop OS X Leopard works just fine, especially for development.

3 DHCP will change your IP address as well as the hostname dynamically; so setting the ORACLE_HOSTNAME environment variable will work around this.

4 oracle/product/10.2.0/db_1/network/admin/tnsnames.ora