Skip navigation.
Home

Oracle 10 XE installation on FreeBSD 6.2

I've found recently my one year old article. Maybe it'll be usefull.

Installing Oracle XE on FreeBSD 6.2

 

Introduction

My current work is related with DBMS, so I've decided to install Oracle XE, which perfectly works at home on Ubuntu Linux 6.06, on my work computer. At my work I use FreeBSD and I wanted to work with Oracle in this environment. I found an article (in russian) http://www.opennet.ru/base/sys/oracle10g_freebsd.txt.html describing process of installing Oracle XE on FreeBSD 6.2. It is a good article, but it doesnt't suit me. I needed about one week to make Oracle work.

Installing oracle

So, at first, we need to compile kernel with next options:

options COMPAT_LINUX
options SEMMAP=128
options SEMMNI=128
options SEMMNS=32000
options SEMOPM=250
options SEMMSL=250
options SHMMAXPGS=262144
options SHMMAX=1073741824
options SHMMNI=4096
options SHMSEG=4096
options MAXDSIZ="(1024*1024*1024)"
options MAXSSIZ="(1024*1024*1024)"
options DFLDSIZ="(1024*1024*1024)"

After that we need to install emulators/linux_base-fc4 from ports collection. By the next step I found libaio-0.3.104-2.i386.rpm and installed it using command:

rpm --root=/compat/linux --force --ignoreos --ignorearch --noscripts --nodeps -ivh libaio-0.3.104-2.i386.rpm

Also we need to mount linux procfs at startup:

echo "linproc /compat/linux/proc linprocfs rw 0 0" >> /etc/fstab

Now we can download oracle-xe-10.2.0.1-1.0.i386.rpm (thanks to Oracle Company) from http://www.oracle.com/technology/software/products/database/xe/htdocs/102xelinsoft.html. Install it by command

rpm --root=/compat/linux --force --ignoreos --ignorearch --noscripts --nodeps -ivh oracle-xe-10.2.0.1-1.0.i386.rpm

Now move oracle from /compat/linux/usr/lib to /usr/lib (This path is hard coded into oracle scripts).

mv /compat/linux/usr/lib/oracle /usr/lib

I don't know, is it compulsory, but I've added to my rc.conf

ldconfig_paths="/usr/lib/compat /usr/X11R6/lib /usr/local/lib /usr/local/lib/compat/pkg /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/ /usr/lib/oracle /xe/app/oracle/product/10.2.0/server/network/lib /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/"

After that we need to run the following script to configure Oracle install.sh. We can use the following rc script to run Oracle at startup oracle.sh Now Oracle is installed on our computer, but is not ready for use.

Creating database

There are some issues. I couldn't set necessary environment in csh, so I used bash to work with Oracle. Run the following script to set environment:

ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
ORACLE_OWNER=oracle
ORACLE_SID=XE
SQLPLUS=$ORACLE_HOME/bin/sqlplus
LSNR=$ORACLE_HOME/bin/lsnrctl
PS1="# " #This is not necessary, but more comfortable than full path in PS1.
export ORACLE_HOME
export ORACLE_SID
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PS1

First way of database creation.

Now we need to create database. I'll describe two ways - create your own database (But I could not install apex then) and restoring database which comes with Oracle xe. First way is quite easy.

mkdir /var/db/oradata/ # I think databases should be stored in /var
chown oracle:dba /var/db/oradata
cd $ORACLE_HOME
su oracle -c "./bin/sqlplus \"/as sysdba\""
    shutdown;
    startup nomount;
    create database XE
        controlfile reuse
        logfile group 1 ('/var/db/oradata/redo1.log') size 10M,
                group 2 ('/var/db/oradata/redo2.log') size 10M
        character set WE8ISO8859P1
        national character set utf8
        datafile '/var/db/oradata/system.dbf' size 50M autoextend on next 10M maxsize unlimited
        extent management local
        sysaux datafile '/var/db/oradata/sysaux.dbf' size 10M autoextend on next 10M maxsize unlimited
        undo tablespace undo
        datafile '/var/db/oradata/undo.dbf' size 10M
        default temporary tablespace temp
        tempfile '/var/db/oradata/temp.dbf' size 10M;
    shutdown;
    startup;

You can get error about controlfile - in such case remove string "controlfile reuse" from database specification. After that we should run

su oracle -c "./bin/sqlplus \"/as sysdba\" @rdbms/admin/catalog.sql "
su oracle -c "./bin/sqlplus \"/as sysdba\" @rdbms/admin/catproc.sql "

to create catalog in new database. We may want to use xdb. So, at first create user xdb using sqlplus interface.

create user xdb identified by pass;

After that we run script, which creates XDB.

su oracle -c " ./bin/sqlplus \"/as sysdba\" @rdbms/admin/catqm.sql pass XDB TEMP";
This will install xdb. Now we can run the following PL/SQL statements:
begin
    dbms_xdb.sethttpport('8080');
    dbms_xdb.setftpport('0');
end;

Now xdb is running. As I said, I couldn't install apex 3.0 in such a way (After install I've got "Internal server error", when tried to follow http://host:port/apex/ link.

Second way of database creation.

Now I describe alternative for such a way db creation. There is a database backup in downloaded oracle rpm. We may restore it. At first, create directory /var/db/oradata/XE:

mkdirhier /var/db/oradata/XE
chown -R oracle:dba /var/db/oradata

After run the following PL/SQL script:

set echo off;
set serveroutput on;
variable devicename varchar2(255);
declare
    omfname varchar2(512) := NULL;
    done boolean;
begin
    dbms_output.put_line(' ');
    dbms_output.put_line(' Allocating device.... ');
    dbms_output.put_line(' Specifying datafiles... ');
    :devicename := dbms_backup_restore.deviceAllocate;
    dbms_output.put_line(' Specifing datafiles... ');
    dbms_backup_restore.restoreSetDataFile;
    dbms_backup_restore.restoreDataFileTo(1, '/var/db/oradata/XE/system.dbf', 0, 'SYSTEM');
    dbms_backup_restore.restoreDataFileTo(2, '/var/db/oradata/XE/undo.dbf', 0, 'UNDO');
    dbms_backup_restore.restoreDataFileTo(3, '/var/db/oradata/XE/sysaux.dbf', 0, 'SYSAUX');
    dbms_backup_restore.restoreDataFileTo(4, '/var/db/oradata/XE/users.dbf', 0, 'USERS');
    dbms_output.put_line(' Restoring ... ');
    dbms_backup_restore.restoreBackupPiece('/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/seeddb/xeseed.dfb', done);
    if done then
        dbms_output.put_line(' Restore done.');
    else
        dbms_output.put_line(' ORA-XXXX: Restore failed ');
    end if;
    dbms_backup_restore.deviceDeallocate;
end;
/

After that we can recreate controlfile:

CREATE CONTROLFILE REUSE
    SET DATABASE "XE" MAXINSTANCES 8 MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100
    DATAFILE '/var/db/oradata/XE/system.dbf', '/var/db/oradata/XE/undo.dbf', '/var/db/oradata/XE/sysaux.dbf', '/var/db/oradata/XE/users.dbf'
    LOGFILE GROUP 1 SIZE 51200K, GROUP 2 SIZE 51200K, RESETLOGS;

Now recreate temporary tablespace (I did it, because I got an error ORA-25153 Temporary Tablespace is Empty):

CREATE TEMPORARY TABLESPACE temp2
    TEMPFILE '/var/db/oradata/XE/temp2.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1M
    MAXSIZE unlimited EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;

Change default tablespace:

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;

Drop default tablespace:

DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES;

Create new temp tablespace:

CREATE TEMPORARY TABLESPACE temp
    TEMPFILE '/var/db/oradata/XE/temp1.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT 10M
    MAXSIZE unlimited EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;

Change default tablespace:

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

Drop temporary temp tablespace:

DROP TABLESPACE temp2 INCLUDING CONTENTS AND DATAFILES;

Now, if we need, we may allow access to apex from remote hosts using link http://host:port/apex/:

EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);

Change password for sys user:

ALTER USER sys IDENTIFIED BY password;

Hurah! Oracle should work correctly now.

thanks

Hi, thanks for this article. Martin