Sep 4, 2013

Install Oracle 11g Release 2 on FreeBSD 9

We Continue providing functionality to our Jail Debian GNU / Linux just installed. For it I decided to install Oracle 11gR2 for Linux, because it is one of the most demanding software packages that can be found, I think it's a good way to explore the limits of the proposed solution.

Another motivation is the fact that in the FreeBSD HandBook  the chapter  dedicated to installing Oracle is referred to version  Oracle 8.0.5, which is quite old, this circumstance stimulated my curiosity.

For failing be certified by Oracle, this platform is not suitable for a production environment, which does not diminish the utility as a test environment and even a development environment for small projects, depends on the risk you want to take.

The advantages of using FreeBSD as an infrastructure for virtualized environments are:
  1. ZFS File System.
  2. Virtual network stack.
  3. Network security with pf.
  4. Dtrace performance analysis.
The advantages of using Debian GNU/Linux  inside a Jail are:
  1. Debian GNU  is one of the most reliable Linux distribution and have a very predictable release cycle.
  2. Using a complete distribution saves us a lot of work when you install Oracle.
  3. Provide updated technical documentation.
As I am not in favor of installing a GUI on servers, especially if they have to support a database engine as heavy as it is Oracle, I will perform a text mode installation using a response file for the Oracle Installer.

Preinstallation Tasks for Oracle

In all installations of Oracle database, must be prepared the OS so that you can install and run properly. These preliminary tasks are specific to each OS and Oracle version.

Specific tasks in FreeBSD

The following tasks must be run as root:

1.- We cloned  the predefined Jail deb-master , using Lenny version, to create the new Jail debora:
root@morsa:/root # zfs clone fbsdzpool1/jailz/deb-master@deboostrap fbsdzpool1/jailz/debora
2.- We configure semaphores, shared memory and asynchronous I/O according to the requirements of Oracle 11gR2, for this we edit the files /boot/loader.conf and /etc/sysctl.conf:

// Start the excerpt of file /boot/loader.conf
kern.ipc.shmmni=4096
kern.ipc.semmns=32000
kern.ipc.semmni=128
aio_load="YES"
// End the excerpt of file/boot/loader.conf

// Start the excerpt of file /etc/sysctl.conf
security.jail.sysvipc_allowed=1
kern.ipc.shmall=2097152
kern.ipc.shmseg=128
kern.ipc.shmmin=1
kern.ipc.shmmax=1073741824
kern.ipc.semaem=16384
kern.ipc.semvmx=32767
kern.ipc.semusz=632
kern.ipc.semume=50
kern.ipc.semopm=100
kern.ipc.semmsl=340
kern.ipc.semmnu=150
// End the excerpt of file /etc/sysctl.conf

3.- We enable shared memory in the  Jail debora:


//  Start the excerpt of file /jailz/etc/jail.conf
debora {
  path = /jailz/debora;
  allow.mount;
  allow.sysvipc;
  host.hostname = debora;
  mount.devfs;
  mount.fstab="/jailz/etc/fstab.debora";
  ip4.addr = 127.0.0.25;
  interface = lo0;
  exec.start = "/etc/init.d/rc 3";
  exec.stop = "/etc/init.d/rc 0";
}
//  End the excerpt of file /jailz/etc/jail.conf


4.- Start the Jail and login:
root@morsa:/root # jail -f /jailz/etc/jail.conf -c debora
debora: created
Starting periodic command scheduler: crond.
root@morsa:/root # jls
   JID  IP Address      Hostname                      Path
     1  127.0.0.25      debora                        /jailz/debora
root@morsa:/root # jexec 1 /bin/bash
debora:/# uname -a
Linux debora 2.6.16 FreeBSD 9.1-RELEASE-p4 #0: Mon Jun 17 11:42:37 UTC 2013 i686
 GNU/Linux

Specific tasks in Debian

The following steps are done inside the Jail debora as root. 

5 .- Install the required packages for Oracle 11gR2 on Debian:
debora:/# apt-get install gcc make binutils lesstif2 rpm libaio1 libdb4.6 libstdc++5 unzip openjdk-6-jdk
Note: Package openjdk-6-jdk jre is installed to provide an alternative jre to that supplied by the Oracle installer.

6.- Create the following symbolic links:
debora:/# ln -s /usr/bin/awk /bin/awk
debora:/# ln -s /usr/bin/rpm /bin/rpm
debora:/# ln -s /usr/bin/basename /bin/basename

7.- Create the groups dba, oinstall and   the  oracle user:
debora:/# groupadd oinstall -g 1000
debora:/# groupadd dba -g 1001
debora:/# useradd -m -g oinstall -G dba -p passwd -s /bin/bash -d /home/oracle -u 1000 oracle
debora:/# passwd oracle
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

8.- Create the directories for the software and the database and change the owner to the oracle user:
debora:/# mkdir -p /oracle/product/11.2.0
debora:/# mkdir -p /oracle/admin/ORATEST/create
debora:/# mkdir /oracle/admin/ORATEST/adump
debora:/# mkdir /oracle/admin/ORATEST/logbook
debora:/# mkdir /oracle/oraInventory
debora:/# mkdir /oracle/oradata
debora:/# mkdir /oracle/flash_recovery_area

debora:/# chown  oracle.oinstall /oracle
debora:/# chown -R oracle.oinstall /oracle/product
debora:/# chown oracle.oinstall /oracle/oraInventory
debora:/# chown -R oracle.dba /oracle/admin
debora:/# chown oracle.dba /oracle/oradata
debora:/# chown oracle.dba  /oracle/flash_recovery_area

9.- Add the hostname to the file /etc/hosts.
debora:/# echo '127.0.0.25 debora' >> /etc/hosts

10.-  Create the file /etc/oraInst.loc and change the owner to the oracle user:

 // Begin file /etc/oraInst.loc
inventory_loc=/oracle/oraInventory
inst_group=oinstall
 // End File  /etc/oraInst.loc

debora:/# chown oracle.oinstall /etc/oraInst.loc


Installing the Oracle Database Software

The following steps are done inside the Jail debora as oracle.

11.- Change the root user to oracle:
debora:/# su - oracle
oracle@debora:~$ id
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)
oracle@debora:~$
12.- Copy to the /oracle directory (for example) the files linux_11gR2_database_1of2.zip and linux_11gR2_database_2of2.zip that contains the installer and unzip:
oracle@debora:/oracle $ unzip linux_11gR2_database_1of2.zip
oracle@debora:/oracle $ unzip linux_11gR2_database_2of2.zip 
13.- To perform an unattended installation, create the response file /oracle/database/response/install_debora.rsp. Marked in bold are the values ​​that can be useful to modify the rest of the file should be left unchanged, as this version of the installer is problematic and this is the format that it must maintain by  the response file:

// Begin file install_debora.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=debora
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/oracle/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/oracle/product/11.2.0
ORACLE_BASE=/oracle
oracle.install.db.InstallEdition=SE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=false
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=username@mailaddress.com
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
//End file install_debora.rsp

14.- Run the installer with the options listed as they are:
oracle@debora:~$ /oracle/database/runInstaller -silent  -ignorePrereq -jreloc /usr/lib/jvm/java-6-openjdk -responseFile /oracle/database/response/install_debora.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 80 MB.   Actual -2147483648 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 4096 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-09-01_08-30-45PM. Please wait ...
[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
   CAUSE: The Central Inventory is located in the Oracle base.
   ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
   CAUSE: The Central Inventory is located in the Oracle base.
   ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
You can find the log of this install session at:
 /oracle/oraInventory/logs/installActions2013-09-01_08-30-45PM.log
 
The following configuration scripts need to be executed as the "root" user.
 #!/bin/sh
 #Root scripts to run

/oracle/oraInventory/orainstRoot.sh
/oracle/product/11.2.0/root.sh
To execute the configuration scripts:
         1. Open a terminal window
         2. Log in as "root"
         3. Run the scripts
         4. Return to this window and hit "Enter" key to continue

Successfully Setup Software.

15.- Check the installer logs:
debora:~# tail -10 /oracle/oraInventory/logs/installActions2013-09-01_08-30-45PM.log
INFO: Validating state <finish>
WARNING: Validation disabled for the state finish
INFO: Completed validating state <finish>
INFO: Terminating all background operations
INFO: Terminated all background operations
INFO: Successfully executed the flow in SILENT mode
INFO: Finding the most appropriate exit status for the current application
INFO: Exit Status is 0
INFO: Shutdown Oracle Database 11g Release 2 Installer
INFO: Unloading Setup Driver
16.- If the installation is successful, run as root the scripts orainstRoot.sh and root.sh:
oracle@debora:~$ logout
debora:~# id
uid=0(root) gid=0(root) groups=5(tty)
debora:~# /oracle/oraInventory/orainstRoot.sh
Changing permissions of /oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /oracle/oraInventory to oinstall.
The execution of the script is complete.

debora:~# /oracle/product/11.2.0/root.sh
Check /oracle/product/11.2.0/install/root_debora_2013-09-01_20-39-01.log for the
 output of root script

debora:~# more /oracle/product/11.2.0/install/root_debora_2013-09-01_20-39-01.log

Running Oracle 11g root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /oracle/product/11.2.0

Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.

Creating a test Database

Prior to create an Oracle database is required an init.ora parameter file and a script with the SQL commands that perform the database creation.

17.- Create the file /oracle/admin/ORATEST/create/initORATEST.ora:
// Begin file initORATEST.ora
db_name='ORATEST'
db_domain=''
sga_target=512M
sga_max_size=1G
pga_aggregate_target=1G
processes = 150
audit_trail ='db'
db_block_size=8192
db_recovery_file_dest='/oracle/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/oracle/'
#dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
compatible ='11.2.0'
db_create_file_dest='/oracle/oradata'
filesystemio_options = SETALL
disk_asynch_io = TRUE
//End file initORATEST.ora

18.- Create the files /oracle/admin/ORATEST/create/ORATEST.sh and /oracle/admin/ORATEST/create/cr_ORATEST.sh:
// Begin file ORATEST.sh
ORACLE_HOME=/oracle/product/11.2.0
ORACLE_SID=ORATEST

NLS_LANG=American_america.WE8ISO8859P15
ORA_NLS11=${ORACLE_HOME}/nls/data
PATH=$PATH:$ORACLE_HOME/bin
export PATH
export ORACLE_BASE
export ORACLE_HOME
export ORACLE_SID
export NLS_LANG
export ORA_NLS33

//End file ORATEST.sh

// Begin file cr_ORATEST.sh
#!/bin/bash

. ./ORATEST.sh

rm ${ORACLE_HOME}/dbs/orapw${ORACLE_SID}
orapwd file=${ORACLE_HOME}/dbs/orapw${ORACLE_SID} password=diablo entries=2

rm -r /oracle/oradata/${ORACLE_SID}

sqlplus /nolog << EOF
spool ../logbook/cr_${ORACLE_SID}.log
conn / as sysdba;
CREATE SPFILE
FROM   PFILE='/oracle/admin/${ORACLE_SID}/create/init${ORACLE_SID}.ora';

DISCONNECT;

conn / as sysdba;

STARTUP NOMOUNT;
CREATE DATABASE ${ORACLE_SID}
CHARACTER SET WE8ISO8859P15
NATIONAL CHARACTER SET UTF8
USER SYS IDENTIFIED BY diablo
USER SYSTEM IDENTIFIED BY diablo
EXTENT MANAGEMENT LOCAL
DEFAULT TEMPORARY TABLESPACE temp
UNDO TABLESPACE undotbs1
DEFAULT TABLESPACE users;

@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/sqlplus/admin/pupbld.sql

SHUTDOWN IMMEDIATE;

EXIT
spool off

EOF

// End file de cr_ORATEST.sh

19.- Grant execute permissions to the scripts:

oracle@debora:/oracle/admin/ORATEST/create$ chmod 750 *.sh
oracle@debora:/oracle/admin/ORATEST/create$ ls -la
total 31
drwxr-xr-x 2 oracle dba   5 Sep  1 21:04 .
drwxr-xr-x 5 oracle dba   5 Sep  1 20:11 ..
-rwxr-x--- 1 oracle dba 258 Sep  1 21:02 ORATEST.sh
-rwxr-x--- 1 oracle dba 782 Sep  1 21:04 cr_ORATEST.sh
-rw-r--r-- 1 oracle dba 490 Sep  1 21:01 initORATEST.ora

20.- Start creating the database.
oracle@debora:/oracle/admin/ORATEST/create$ nohup ./cr_ORATEST.sh &
21.- Check that the creation of the database was completed successfully:
oracle@debora:/oracle/admin/ORATEST/create$ tail -10 nohup.out
SQL> CREATE PUBLIC SYNONYM PRODUCT_USER_PROFILE FOR SYSTEM.PRODUCT_PRIVS;

Synonym created.

SQL>
SQL> -- End of pupbld.sql
SQL> SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> SQL> Disconnected from Oracle Database 11g Release 11.2.0.1.0 - Production

22.- Start the database and login:
oracle@debora:/oracle/admin/ORATEST/create$  . ./ORATEST.sh
oracle@debora:/oracle/admin/ORATEST/create$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Sun Sep 1 22:09:58 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL>  conn / as sysdba;
Connected to an idle instance.

SQL> startup;
ORACLE instance started.

Total System Global Area 1071333376 bytes
Fixed Size                  1341312 bytes
Variable Size             750782592 bytes
Database Buffers          314572800 bytes
Redo Buffers                4636672 bytes
Database mounted.
Database opened.
SQL>
SQL> select * from v$instance;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION           STARTUP_T STATUS       PAR    THREAD# ARCHIVE LOG_SWITCH_WAIT
----------------- --------- ------------ --- ---------- ------- ---------------
LOGINS     SHU DATABASE_STATUS   INSTANCE_ROLE      ACTIVE_ST BLO
---------- --- ----------------- ------------------ --------- ---
              1 ORATEST
debora
11.2.0.1.0        01-SEP-13 OPEN         NO           1 STOPPED
ALLOWED    NO  ACTIVE            PRIMARY_INSTANCE   NORMAL    NO


SQL> !uname -a
Linux debora 2.6.16 FreeBSD 9.1-RELEASE-p4 #0: Mon Jun 17 11:42:37 UTC 2013 i686
 GNU/Linux

SQL>

Done.

Oracle 11gR2 running on FreeBSD9


23.- Shut down ORATEST database.
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> SQL> Disconnected from Oracle Database 11g Release 11.2.0.1.0 - Production
 24.- Shut down debora Jail.
root@morsa:/root # jail -f /jailz/etc/jail.conf -r debora
Using makefile-style concurrent boot in runlevel 0.
Stopping device state change daemon: devd.
Asking all remaining processes to terminate...done.
All processes ended within 1 seconds....done.
Stopping enhanced syslogd: rsyslogd.
/etc/init.d/umountnfs.sh: 106: cannot open /etc/mtab: No such file
Deconfiguring network interfaces...done.
Cleaning up ifupdown....done.
Deactivating swap...done.
mount: /: unknown special file or file system
Will now halt.
ifdown: shutdown usbus0: Operation not permitted
ifdown: shutdown ath0: Operation not permitted
ifdown: shutdown usbus1: Operation not permitted
ifdown: shutdown lo0: Operation not permitted
ifdown: shutdown wlan0: Operation not permitted
startpar: service(s) returned failure: umountnfs.sh ... failed!
deb-master: removed
24.- Make a  snapshot of the debora jail, so as to have a template of a Jail configured for Oracle databases.

root@morsa:/root # zfs snapshot fbsdzpool1/jailz/debora@oracle11gR2

Final Thoughts

The decision to install in the Jail the Lenny version of Debian GNU/Linux is motivated by two reasons: first, the kernel version of Linux that the Oracle Installer  requires as a prerequisite is 2.6.9, and on the other hand, the minimum kernel version for squeeze is 2.6.18, which is higher than that supported by the Linux compatibility module for FreeBSD 9.

//  Start the excerpt of file installActions.log
INFO: *********************************************
INFO: OS Kernel Version: This is a prerequisite condition to test whether the system kernel version is at least "2.6.9".
INFO: Severity:CRITICAL
INFO: OverallStatus:SUCCESSFUL
INFO: -----------------------------------------------
INFO: Verification Result for Node:debora
INFO: Expected Value:2.6.9
INFO: Actual Value:2.6.16
INFO: -----------------------------------------------
INFO: *********************************************
//  End the excerpt of file installActions.log

During the development of this Post, I detected a problem while running Oracle Installer, that randomly failed on at initial startup. One way to avoid this problem is to use an alternate jre to the provided with the installer.

I have not been able to configure the Automatic Memory Management (AMM) which is one of the new features introduced in version 11g. This is because I have not managed to configure the device /dev/shm within the Jail.

Therefore, there is no choice but to use the Automatic Shared Memory Management (ASMM) giving values ​​to the parameters SGA_TARGET and SGA_MAX_SIZE  in the parameter file initORATEST.ora.

The file system on which you created the database is not optimized for the files in the database, is an issue that should be improved to a more intensive use of the database.

4 comments:

  1. What version freebsd did you use ? 32bit or 64bit ?

    i got stuck to running java as oracle user inside jail , i cannot running java when used oracle user , but running smooth when using root user , can you help me ?

    ReplyDelete
  2. First of all, this guide was developed under FreeBSD 9.1-RELEASE-p4 amd64 .Next openjdk-6-jdk must run flawlessly, however in your case check permissions for the jdk executables.

    Regards

    ReplyDelete
  3. Thanks for this tutorial. It's very helpful. Do you think Oracle 12c could be installed on FreeBSD 10 using this tutorial as a guide?

    ReplyDelete
  4. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Oracle 11g, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on Oracle 11g. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us:
    Name : Arunkumar U
    Email : arun@maxmunus.com
    Skype id: training_maxmunus
    Contact No.-+91-9738507310
    Company Website –http://www.maxmunus.com


    ReplyDelete

Comments are welcome, I encourage you to contribute by proposing topics of your interest to develop in this blog.