I was very surprised that Oracle released Oracle Database for Mac OSX, especially, version 10g now that 11g has been out for almost 2 years. Well, I guess Oracle wanted to please Mac users expecting things just work and decided that good proved 10g is the way to go. On the other hand, we’ve been supporting 11g in production for quite a while and I must say it’s much better quality compare to 10g when it came out. I’m pretty sure there was a significant customer that influenced that decision — interesting who might that be?
Anyway, there is no quick install guide for OS X but only a standard Oracle® Database Installation Guide
10g Release 2 (10.2) for Apple Mac OS X (Intel). It’s fine but if you want to install Oracle on your MacBook and not for production use then you might take some shortcuts and follow a quick instructions so I gathered my notes while installing just released Oracle Database 10.2.0.4 on my MacBook and this is what you see now.
First things first — prerequisites
- You must be on OS X 10.5.4 or higher. You are probably keeping your system up to date and is on the current release (10.5.6 as I’m writing this). Note that the guide requires OS X Server but for your playground, desktop OS X will work just fine. Update 14-Sep-09: this Guide has been updated for Snow Leopard 10.6.
- You need to install Xcode 3.0 but if you are a Mac enthusiast, you will have it installed already. If not, you can find Xcode on your OS X Installation DVD or you can download it from from Apple Developer Connection but it’s quite large.
- Disk space — about 5GB for software installation including temporary needs.
- You can run with as low as 1GB of RAM but you do want to have at least 2GB to avoid your system crawling.
Creating OS oracle user
Oracle installation guides always instruct to have at least two groups —
oinstall as a software owner and
dba as an OSDBA group. I never saw an organization with the natural split of these responsibilities so I always prefer to create a single
dba group and use it for both purposes.
I use 4200 as GID and UID so checking if they are available (Updated on 19-Apr-09: Thanks Gleb!):
macbook:~ gorby$ dscl . -list /groups gid | grep 4200 macbook:~ gorby$ dscl . -list /users uid | grep 4200 macbook:~ gorby$
To create user oracle with default dba group, run the following script. I assume you run it as “admin” user so that you can sudo to root (you will need to enter your user password at the first time):
Updated 01-May-09: oracle->dba group membership line added. Thanks Johannes.
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/com.apple.loginwindow HiddenUsersList -array-add oracle sudo passwd oracle
The last command will prompt for the new password and the command prior to the last will remove
oracle user from login window — I find it annoying otherwise.
Next, you will need to set kernel parameters. Some of them are already good and some I would question changing on my MacBook just to have Oracle installed so I’d rather keep them. Use the following command to check current values (recommended values are after hash symbol as comment):
sysctl kern.sysv.semmsl # 87381 sysctl kern.sysv.semmns # 87381 sysctl kern.sysv.semmni # 87381 sysctl kern.sysv.semmnu # 87381 sysctl kern.sysv.semume # 10 sysctl kern.sysv.shmall # 2097152 sysctl kern.sysv.shmmax # max SGA you need. sysctl kern.sysv.shmmni # 4096 sysctl kern.maxfiles # 65536 sysctl kern.maxfilesperproc # 65536 sysctl net.inet.ip.portrange.first # 1024 sysctl net.inet.ip.portrange.last # 65000 sysctl kern.corefile # core sysctl kern.maxproc # 2068 sysctl kern.maxprocperuid # 2068
From semaphores and shared memory setting, I only needed to change
maxfilesperproc were set lower (12288 and 10240 respectively) but I would prefer to keep it this way – my test database won’t need so many open files descriptors unless something is wrong with it. IP port range by default is 49152-65535 and I would prefer to keep it this way to have as little impact on my environment as possible. I also don’t want the core files to be generated in oracle way as a file
core in a process’ current directory so I’ll leave the
corefile value at “/cores/core.%P”. Finally, I believe values for maxproc and maxprocperuid should be enough if I set 1024 and 512 respectively.
Unfortunately, 4 values I need to change can’t be modified at run-time so I have to configure them in /etc/sysctl.conf and reboot. For this, add the following to /etc/sysctl.conf (you probably will need to create a new file) and reboot:
kern.sysv.shmall=2097152 kern.sysv.shmmni=4096 kern.maxproc=1024 kern.maxprocperuid=512
After reboot here are my kernel parameters:
kern.sysv.semmsl: 87381 kern.sysv.semmns: 87381 kern.sysv.semmni: 87381 kern.sysv.semmnu: 87381 kern.sysv.semume: 10 kern.sysv.shmall: 2097152 kern.sysv.shmmax: 4194304 kern.sysv.shmmni: 4096 kern.maxfiles: 12288 kern.maxfilesperproc: 10240 net.inet.ip.portrange.first: 49152 net.inet.ip.portrange.last: 65535 kern.corefile: /cores/core.%P kern.maxproc: 1024 kern.maxprocperuid: 512
Creating ORACLE_BASE directory
I want to have my Oracle binaries installed on a non-system partition
HD2 so I’m creating directory there:
sudo mkdir /Volumes/HD2/oracle sudo chown oracle:dba /Volumes/HD2/oracle sudo chmod 775 /Volumes/HD2/oracle
You can also use oracle’s home directory
/Users/oracle if you just have one disk/partition.
Update 14-Sep-09: If you don’t have another hard disk or partition mounted, the DO NOT use path in /Volumes/… You can use oracle’s home directory instead —
Next I login as oracle user (
su - oracle) and create bash profile ~/.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=/Volumes/HD2/oracle export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1 export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib export ORACLE_SID=mac10g PATH=$PATH:/$ORACLE_HOME/bin
Starting X11 server
X11 server is not running by default but you can kick it off either from Applications -> Utilities -> X11 or from command line (by default DISPLAY variable is pointing to a socket file):
macbook:~ gorby$ echo $DISPLAY /tmp/launch-ArvCjk/:0 macbook:~ gorby$ xclock Warning: locale not supported by Xlib, locale set to C ^C macbook:~ gorby$ netstat -an | grep 6000 | grep LISTEN tcp4 0 0 *.6000 *.* LISTEN tcp6 0 0 *.6000 *.* LISTEN
Update 14-Sep-09: If you don’t see X11 listening on this port (and by default it doesn’t listen on Snow Leopard 10.6) then enable it in X11 preferences “Allow connections from network clients” or use this command line
sudo defaults write org.x.X11 nolisten_tcp 0 (Thanks Tomasz).
Installing the software
Become oracle user with
su - oracle, export
DISPLAY variable and verify it works by running xclock:
macbook:~ oracle$ export DISPLAY=localhost:0 macbook:~ oracle$ xclock ^C macbook:~ oracle$
Update 14-Sep-09: Above works only for OS X 10.5 Leopard. OS X 10.6 Snow Leopard has stricter security settings so you cannot simply su to oracle user and export DISPLAY — you actually have to login as oracle user (logout in GUI and login as oracle “Oracle software owner”) instead of “su – oracle”. Thanks to Raimond for this.
I assume you have already downloaded and unzipped Oracle 10g Release 2 installation binaries. If not do it now and unzip in a temporary location.
I use DHCP for network configuration of my MacBook and it changes IP address as well as hostname dynamically so I’d rather install database for localhost as it never changes. There is a trick with Oracle Installer for exactly that purpose — just set ORACLE_HOSTNAME environment variable before running the Installer. Don’t do that if you want your Oracle database to be accessible by other computers on the network but then you probably want to have your network configured with static IP. You can always change it later by reconfiguring the listener.
Update 01-Sep-09: Thanks to Chris Murphy for an update re installation on OS X 10.6 Snow Leopard:
* Edit runInstaller and change
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0. Raimond Simanovskis proposes to just create a link which is probably a better solution —
sudo ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0 /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2.
* Use additional option —
Update 1-Mar-10: Nicolas reported another way — install 1.4.2 JDK.
Now, run the installer from Disk1 directory:
macbook:~ oracle$ /Users/oracle/db/Disk1/runInstaller Starting Oracle Universal Installer... No pre-requisite checks found in oraparam.ini, no system pre-requisite checks will be executed. Preparing to launch Oracle Universal Installer from /tmp/OraInstall2009-04-13_08-24-33PM. Please wait ...macbook:~ oracle$
Select Advanced installation option on the first screen. On the next screen, specify location for Oracle inventory to be under ORACLE_BASE —
/Volumes/HD2/oracle/oraInventory and inventory OS group
dba. The rest of the screens leave with defaults unless you know what you need to tweak so keep clicking next… next… next… Specify desired ORACLE_SID for the new database and make Global Database Name the same (I use
mac10g as you could see from my
.bash_profile). Plus, you can also tick the box to create sample schemas on the same screen so you have some data to play with. Finally, set some tough passwords for internal Oracle users (we all know that it’s the best to use
sys/change_on_install as top secret) and you are ready to rock-n-roll.
The last part (installation and linking) is usually the most troublesome when installing Oracle software but in case of Mac OS X there are very few dependencies so it should work just fine unless you missed
Xcode 3.0 install. Well, at least it did work fine for me. Binaries installation took just few minutes on my Macbook and Configuration Assistants were relatively quick as well. Oh, you will be prompted to accept network connections to application
oracle and you should answer “Yes” — it’s only asked the first time and answer is valid until oracle binaries are changed. At the end, you will need to run couple scripts as root user — usual stuff.
Snow Leopard update 14-Sep-09: If you get
Error in invoking target ‘all_no_orcl ipc_g ihsodbc32 error during linking then edit file
$ORACLE_HOME/rdbms/lib/ins_rdbms.mk (without exiting installer – just switch to the terminal) and comment out line with
$(HSODBC_LINKLINE) — just place hash # in front. Then switch back to the error in the installer and click “Retry”. I picked it up from Raimonds Simanovskis’s post — thanks a bunch.
Raimond also suggests how to fix Java GUI tools (netca and dbca) so that they run on Snow Leopard. Quoting him — “modify
$ORACLE_HOME/jdk/bin/java script and change
…java -Xbootclasspath… to
…java -d32 -Xbootclasspath…“.
Completing network configuration
The installer doesn’t start the listener automatically so do that as oracle user if you need network connectivity using
lsnrctl start. Automatic instance registration won’t work because the PMON process it trying to register with a listener on the default port 1521 of the main host IP but we forced Oracle Installer to use localhost. Not a problem, just set local_listener parameter accordingly:
SQL> show parameter listener NAME TYPE VALUE ---------------- ----------- ----------------- local_listener string remote_listener string SQL> alter system set local_listener='localhost'; System altered. SQL> alter system register; System altered.
I personally don’t want to start an Oracle database instance automatically on reboot of my MacBook so I use command-line prompt. Automatic shutdown on reboot — well, I can shutdown manually or just let it crash. I’m way too confident in Oracle crash recovery mechanism.
We are done!
macbook:~ oracle$ uname -a Darwin macbook 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 macbook:~ oracle$ sw_vers ProductName: Mac OS X ProductVersion: 10.5.6 BuildVersion: 9G55 macbook:~ oracle$ sqlplus [email protected] SQL*Plus: Release 10.2.0.4.0 - Production on Mon Apr 13 21:04:56 2009 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Enter password: Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>
What’s next? Perhaps, get APEX working on Mac OS X?
So now, dear reader, we hope we have helped you figure out something you needed to know. It turns out that you can help us here at Pythian with something we need to know! If you are aware of a DBA requirement within your organization, salaried or consulting, please pop in your email address here:
We respect your privacy and will not share your address with any third party. As a thank you for just participating, we will enter you into a monthly draw for a year’s membership in the ACM, which includes access to 600 books from the O’Reilly Bookshelf Online, 500 books from Books24x7 and 3000 online courses from SkillSoft, including tons of courseware on Oracle, SQL Server, and MySQL.