Parts of this document are direct quotations from the Oracle Installation Guide for Linux Release 8.0.5, which is almost certainly copyrighted by Oracle. However I believe that it's stupid to have to go back and forth between this document and the Installation Guide, so I have included the text here where applicable. Hopefully Oracle's lawyers will cut me a break.
The FreeBSD kernel needs to be rebuilt in order to incorporate some specific code. The code enables the Linux emulation for FreeBSD and allows the operating system to support the execution of Linux binaries. The FreeBSD kernel configuration file usually resides in the subdirectory /usr/src/sys/i386/conf. If you have not ever built a kernel before, then I suggest that you copy the GENERIC kernel file to a new file. Name the new file whatever you named your machine. For example, on a machine named millenium.mjuice.com, type "cp GENERIC MILLENIUM" to copy the GENERIC kernel file to a new file named MILLENIUM, then edit the file named MILLENIUM. Add the line "options COMPAT_LINUX" to the new kernel file. This instructs the config program to include the Linux compatibility code in the new kernel. In addition, add the following lines to the kernel configuration file (MILLENIUM in this example):
options SHMMAXPGS=10000
options SHMMNI=100
options SHMSEG=10
options SEMMNS=200
options SEMMNI=70
options SEMMSL=61
options SYSVSHM
options SYSVSEM
options SYSVMSG
The first six options indicate the maximum allowable size for shared memory and interprocess communication structures in the kernel. The last three options enable ATT System V style shared memory, semaphores, and messaging.
Save the kernel configuration file and type "config MILLENIUM" (or whatever you named your kernel configuration file. If you typed everything correctly, the config command will respond with a "kernel build directory".
Change to that directory and type "make depend && make". The system should build your kernel without errors. When the kernel is built, type "make install". The system will store your old kernel as kernel.old. Next type "reboot" and your system should restart with the new kernel. If something goes wrong with the new kernel and you cannot reboot, you can tell the system to use the old kernel by typing "kernel.old" when the "boot" prompt is displayed.
FreeBSD actually utilizes several components of the Linux operating system to allow Oracle to work. These components were included as part of the FreeBSD ports collection at the time this document was written. To ensure that the ports are available to you, it is a good idea to reinstall the ports connection from the FreeBSD development tree. To do this, you will first need to install the cvsup-bin port. Cvsup-bin allows you to remotely update your entire FreeBSD system, or portions of the system, by remotely accessing the FreeBSD CVS repository.
To install cvsup-bin, change to the /usr/ports/net/cvsup-bin and type "make". The system will automatically connect to the FreeBSD site via the network and will fetch and build the cvsup-bin port. When the build is complete, type "make install" to install the port.
Next change to the subdirectory /usr/share/examples/cvsup-bin. Copy the file named ports-supfile to a file in the /etc directory. For this example, we will call the copy cvsup-ports. Edit the new cvsup-ports file. Change the line that reads "*default host=CHANGE_THIS.FreeBSD.org" to a valid server name. For example, replace the "CHANGE_THIS" with "cvsup", so that the string reads "cvsup.FreeBSD.org". Save the file.
If you are using the C shell, you will want to type the command "rehash" now so that the shell will pick up the new cvsup command that we just built and installed. Next type "cvsup -L2 -g /etc/cvsup-ports". If you want to know what the command line options do, consult the UNIX man page for cvsup. The cvsup command will run for a while, so go get something to drink and come back and check on it.
After the cvsup of the ports collection finishes, change to the subdirectory /usr/ports/emulators/linux_base. This is one of the ports necessary to run the Linux emulation. Type "make" and the port should build automatically. The port installs several large Linux components, so now would be a good time to get some food and come back and check on the progress of the build. When the linux_base port finishes building, type "make install" to install the port in the /compat/linux directory.
After the Linux_base port has been installed, change to the subdirectory /usr/ports/devel/linux_devtools and type "make" as before. The port should build automatically. This is also a substantial port, so now would be a good time to go have a cigarette and come back and check on the progress of the build. When the linux_devtools port finishes building, type "make install" to install the port in the /compat/linux directory.
If you are using the C shell, you will want to type the command "rehash" now so that the shell will pick up the new commands that we just built and installed. The Linux ports that were built now reside in a directory named /compat/linux.
Now that the Linux support is installed, we want to start creating the directory structure for Oracle. Be sure that you choose a disk partition that has ample free space. The total size of the Oracle installation is around 400 MB. The Oracle Linux client tar file itself is a whopping 141MB, so be sure that you have enough room to complete the installation.
For this example we will create a structure in the /usr partition. Our Oracle installation will begin by creating the directory structure below:
/usr/local/oracle/app/oracle/product/8.0.5
Make this directory structure on your FreeBSD machine using the "mkdir" command. Oracle's installation procedure will make the directory for you, but it's better to think about where you want the installed programs to wind up now than in the middle of the installation program, so think about it and then make it so.
Now that we have the directory structure, we can create a user and a group to own the directories and the file that we will install there. First, edit the file /etc/group and create a group named "dba". The group entry can be any group number that is not already taken. For this example, we will add the following line to our group file:
dba:*:10:
Don't worry about entering the user name into the group file, since dba will be the default group for the user. Save the group file.
Next, we need to create an oracle user. The only special characteristic of the oracle user is that the oracle user needs to use the bash shell that was installed with the Linux compatibility ports. The Linux bash shell is installed as /compat/linux/bin/bash. In order to make that shell valid for the FreeBSD system, edit the file /etc/shells and add the full path name, /compat/linux/bin/bash, to the file and save it.
The command for creating a user on FreeBSD is called adduser. Type adduser, press Enter and follow the prompts. Name the user oracle, and make its default group dba. Also add the oracle user to the operator group. Choose a good strong password for the oracle user, since the oracle user will have operator privileges on the FreeBSD system. Our oracle user looks like this after we finish doing adduser:
Name: oracle
Password: ****
Fullname: Oracle userid
Uid: 1003
Gid: 10 (dba)
Class:
Groups: dba operator
HOME: /home/oracle
Shell: /compat/linux/bin/bash
Press Enter to create your oracle user.
Now we can go back and change the ownership of the Oracle directory tree to the userid and group that we just created. Change to the subdirectory /usr/local/oracle, type "find . -exec chown oracle:dba {} \;" and press Enter. The subdirectory /usr/local/oracle and all the subdirectories below it will now be owned by the oracle userid.
The file may be downloaded directly from the Oracle Web site. Currently the URL is http://www.oracle.com/download/Linux/oracle8/html/download.html. Oracle usually requires you to register for the software. However this URL points directly at the file. Please note that this software is listed as an evaluation product, so commercial use is restricted. I suggest that you check your disk usage by typing the command "df -k". This command will tell you, among other things, how much available disk space you have on your file systems.
The oracle client file name is 805ship.tgz, and it is 141MB in size. Start the download and go get lunch (or dinner) unless you have a serious amount of bandwidth.
While you're downloading the file, let's take a minute to define some terms. In the Oracle world, there are two recurring directories, referred to as ORACLE_BASE and ORACLE_HOME. Many things in the Oracle installation procedure, including the creation of the oratab file below, refer to these directories. For this example, ORACLE_BASE is the subdirectory /usr/local/oracle/app/oracle, and ORACLE_HOME is /usr/local/oracle/app/oracle/product/8.0.5. Please note that ORACLE_BASE is always a parent of ORACLE_HOME. Also note that making ORACLE_HOME the same as the directory where the Oracle Linux client tar file is decompressed is a bad idea. The Oracle installation will not run if the ORACLE_HOME subdirectory is not different from the subdirectory where the Oracle Linux client tar file is decompressed.
When the file download completes, the file must be decompressed. To do this, type the command "tar zxvf 805ship.tgz. The 805ship.tgz file will be decompressed in the directory /usr/local/oracle/staging.&nbap;
The Oracle installation program requires a file called "oratab" to run. Before we create the oratab file, it is necessary to set an environment variable named ORACLE_OWNER to the name of the oracle userid. If the environment variable is not set, the oratab.sh script will not run. If using the C shell, type "setenv ORACLE_OWNER oracle" and press Enter. For Bourne shell, it's "ORACLE_OWNER=oracle; export ORACLE_OWNER".
Now we need to create the oratab file. The oratab file will live in the /etc directory. To create the file, change to the subdirectory /usr/local/oracle/app/oracle/product/8.0.5/orainst (also knows as $ORACLE_HOME/orainst). In this subdirectory is a shell script named oratab.sh. This shell script will create the oratab file. However first the shell script must be modified to run properly under FreeBSD.
Edit the oratab.sh script. Near the top are two lines that define the variables CHOWN and CHGRP. Change these two lines to look like this:
CHOWN=/usr/sbin/chown
CHGRP=/usr/bin/chgrp
These are the correct paths to the chown and chgrp commands under FreeBSD. Save the file, then type "./oratab.sh" (don't forget the leading dot and forward slash) and press Enter. When prompted for the ORACLE_OWNER environment variable, press Enter. The oratab file should be created in the /etc directory. If you want to see it, type "ls -la /etc/oratab" and the output should look something like this:
-rw-rw-r-- 1 oracle dba 667 Sep 24 02:09 /etc/oratab
There is one final step that we must perform as the root user. There is a bug in the Linux_devtools port that prevents the Oracle installation from completing successfully. To rectify this problem, make a symbolic link to the library named libgcc.a in the subdirectory /compat/linux/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29. Change to the subdirectory /compat/linux/usr/lib and type the command "ln -s /compat/linux/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29/libgcc.a libgcc.a" and press Enter. This will allow the Oracle installation scripts to find the libgcc.a library for the final link edit steps of the Oracle installation.
The first thing that has to be modified for the oracle user is the .profile file. This "dot" file is read by the bash shell every time the oracle user logs in. We will put our startup commands in this file. Edit the file and insert the following lines (for this example):
# Oracle specific variables
# Specified for the FreeBSD install
Umask 022
ORACLE_BASE=/usr/local/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/8.0.5; export ORACLE_HOME
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/compat/linux/usr/lib; export LD_LIBRARY_PATH
ORACLE_SID=MJDB; export ORACLE_SID
ORACLE_TERM=386x; export ORACLE_TERM
ORA_NLS33=$ORACLE_HOME/ocommon/admin/data; export ORA_NLS33
CLASSPATH=$ORACLE_HOME/jdbc/lib/classes111.zip; export CLASSPATH
TMPDIR=/tmp; export TMPDIR
PATH=/compat/linux/bin:/compat/linux/sbin:/compat/linux/usr/bin:/compat/linux/usr/sbin:/bin:/sbin:/usr/bin:
/usr/sbin:/usr/local/bin:/usr/local/bin:$ORACLE_HOME/bin; export PATH
Change the values of the variables to match your installation. For example, if your temporary file directory is not very large, you might want to substitute /var/tmp for /tmp in the above example. Also, if you are working from a console and not from an xterm, you will want to use ORACLE_TERM=386 instead. Save the .profile file, then type ". ./.profile" (three dots) and press Enter. This will force bash to read the .profile file and incorporate the changes we just made.
Before we start, be prepared for the fact that the oracle installation software will show up looking like a poorly written MS-DOS GUI. The navigation around the GUI is via the tab key and the spacebar. It's pretty easy once you get used to it, but pay attention the first time through to save yourself the headache of redoing the installation later.
In the following paragraphs, the screen name in quotes refers to the text that the Oracle installation displays at the top center of the xterm or console.
To start the Oracle installation, change to the directory ORACLE_HOME/orainst, type "./orainst" and press Enter. The "Install Type" screen is displayed. Select "Custom Install" using the tab key and press Enter.
Next the "preamble.txt" screen is displayed. Press Enter.
Next the "README.FIRST" screen is displayed. Press Enter.
Next the "Installation Activity Choice" screen is displayed. "Install, Upgrade, or De-Install Software" is highlighted. Press Enter.
Next the "Installation Options" screen is displayed. Select the "Install New Product - Do Not Create DB Objects" option using the tab key and the down arrow cursor key, then press Enter.
Next the "Environment Variables" screen is displayed. Make sure that the values displayed agree with what was set up previously. In our example, ORACLE_BASE is /usr/local/oracle/app/oracle, and ORACLE_HOME is /usr/local/oracle/app/oracle/product/8.0.5. Press Enter.
Next the "Logging and Status" screen is displayed. Examine the values for the various log files, which Oracle will write in the ORACLE_HOME subdirectory. Press Enter.
Next the "Install Source" screen is displayed. Select the "Install from Staging Area" options using the tab key, the down arrow cursor key, and the space bar. Press Enter.
Next the "Source Staging Area" screen is displayed. We are installing from the subdirectory /usr/local/oracle/staging, which is where we decompressed the 805ship.tgz file. Press Enter.
Next the "NLS" screen is displayed. For American English installation, select the option American/English by pressing the tab key and the down arrow cursor key. Press Enter.
Next Oracle displays an "Information" screen that shows where it will write commands that have to be executed later as the root user. The default file name is root.sh. Press Enter.
Next the "Software Asset Manager" screen is displayed. Here is where we select the Oracle components that we are to install. We will install three components. The three components are named Net8 8.0.5.0.0, Pro*C/C++ 8.0.5.0.0, and SQL*Plus 8.0.5.0.0. Select the three components by pressing the down arrow cursor key until the cursor appears to the left of each component, then press the spacebar to select the component. After the three components are selected, press the tab key to move the cursor to the word "Install" Press Enter and the Oracle screen is displayed. Oracle is now installing the selected Oracle components.
When the Oracle Installation completes, press Enter to return to the "Software Asset Manager" screen.
Use the tab key to select the Exit button at the bottom right hand of the installation screen. Press Enter and Oracle displays a "Confirmation" screen. Use the tab key to select Yes and press Enter.
Oracle says it best: Result: Success. The Linux Oracle client is now installed on FreeBSD.
Here's a chance to show off your kung fu. Change to the subdirectory /usr/local/oracle/app/oracle/bin (also knows as ORACLE_BASE/bin) and type "./tnsping <database_IP> 9" where "database_IP" is the IP address of a machine that you are running the Oracle relational database on. The response (from the Oracle database machine should look something like this:
millenium $ tnsping 204.71.191.69 9
TNS Ping Utility for Linux: Version 8.0.5.0.0 - Production on 24-SEP-99 03:25:27
(c) Copyright 1997 Oracle Corporation. All rights reserved.
Attempting to contact (ADDRESS=(PROTOCOL=TCP)(HOST=204.71.191.69)(PORT=1521))
OK (10 msec)
OK (0 msec)
OK (10 msec)
OK (0 msec)
OK (0 msec)
OK (10 msec)
OK (0 msec)
OK (10 msec)
OK (0 msec)
Edit the file root.sh. Near the top you will find a line that defines the variable CHOWN. This line needs to be modified to read CHOWN=/usr/sbin/chown. Change the line and save the file.
Next we must define some environment variables before we can run the root.sh script. Unless you hard coded the variable definitions in the startup files (.profile or .cshrc) for your root account (you should not have done so), these environment variables need to be set. If you are using the C shell, type the following lines one at a time at your command prompt:
setenv ORACLE_BASE /usr/local/oracle/app/oracle
setenv ORACLE_HOME /usr/local/oracle/app/oracle/product/8.0.5
setenv ORACLE_OWNER oracle
Now that you have the environment variables defined, type "./root.sh" and press Enter. The script displays your settings for the environment variables and asks whether they are correct. Press Enter and the script should run to completion.
We have to tell Oracle what to connect to and how to connect to it. We need to copy and edit a file to do this. Change to the directory $ORACLE_HOME/network/admin. Edit the sample file $ORACLE_HOME/network/admin/tnsnames.ora. In this file we will specify the database server that we want to connect to, and the system identifier for that database. Replace each instance of the string To ensure that we can access sqlplus, add the subdirectory /usr/local/oracle/app/oracle/product/8.0.5/bin ($ORACLE_HOME/bin) to the end of your PATH variable. You can do this by editing the root .login file and adding the subdirectory to the end of the path variable. If you use the $ORACLE_HOME environment variable when you specify the subdirectory, make sure that you have defined it in the .login file before you define the path.
Another environment variable that is useful when connecting to the database is the TWO_TASK environment variable. The TWO_TASK environment variable contains the value of the database server that you want to connect with and the database system identifier (the $ORACLE_SID). If you are using the C shell, type "setenv TWO_TASK T:208.48.124.40:MJDB". In this example our database server is 208.48.124.40 and our $ORACLE_SID is MJDB. If you are using the Bourne shell, type "set TWO_TASK=T:208.48.124.40:MJDB;export TWO_TASK".
Try and connect to the database. Type "sqlplus <userid>/<password>@ORACLE_SID" where <userid> is the userid that you need to connect to your database (this is not "oracle"), <password> is that userid's password, and ORACLE_SID is the system identifier for your database. In our example, the value of $ORACLE_SID is MJDB. Make sure to include the forward slash between the <userid> and the <password>, and the "@" between the <password> and the $ORACLE_SID. The system should respond with the following:
SQL*Plus: Release 8.0.5.0.0 - Production on Mon Sep 27 10:50:28 1999
(c) Copyright 1998 Oracle Corporation. All rights reserved.
Connected to:
Oracle8 Enterprise Edition Release 8.0.5.0.0 - Production
With the Partitioning and Objects options
PL/SQL Release 8.0.5.0.0 - Production
SQL>
You are now connected with the Oracle database on your database server.