Tuesday, March 20, 2012

Install Oracle DB11gR2 on arch linux within a virtual box

based on https://wiki.archlinux.org/index.php/Oracle

install arch i686 (archlinux-2011.08.19-core-i686.iso)

useradd --home /home/zlu -m --shell /bin/bash -U zlu

pacman -S filesystem --force
rm /etc/profile.d/locale.sh
pacman -Syu

install yaourt
[archlinuxfr]
Server = http://repo.archlinux.fr/$arch

install virtualbox-archlinux-additions
modprobe -a vboxguest vboxsf vboxvideo
/usr/bin/VBoxClient-all
# groupadd vboxsf
# gpasswd -a $USER vboxsf

sudo mount -t vboxsf -ogid=1000,uid=1000 zlu_host ./zlu_host

pacman -S sudo openssh

pacman -S python

Install and test Xorg.
# pacman -S xorg

# pacman -S xfce4
# pacman -S pcmanfm
$ startxfce4

Arch i686:

    java-runtime (openjdk7)
    pdksh, gawk, gdb, libaio, libelf, sysstat, unixodbc, libstdc++5
    unzip
yaourt -S rpm

Some prerequisite symbolic links for Oracle Universal Installer.
# ln -s /usr/bin/rpm /bin/rpm
# ln -s /bin/tr /usr/bin/tr
# ln -s /usr/bin/basename /bin/basename

Create users and group for Oracle database:
# groupadd oinstall
# groupadd dba
# useradd -m -g oinstall -G dba oracle

# passwd oracle

Add these lines to /etc/sysctl.conf (Review Oracle documentation to adjust these settings).
# oracle kernel settings
fs.file-max = 6553600
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144

Add these lines to /etc/security/limits.conf (Review Oracle documentation to adjust these settings)
# oracle settings
oracle           soft    nproc   2047
oracle           hard    nproc   16384
oracle           soft    nofile  1024
oracle           hard    nofile  65536

Create some directories for Oracle database. You can chose the directory path. Here is an example.
mkdir -p /oracle
mkdir -p /oracle/inventory
mkdir -p /oracle/recovery
mkdir -p /oracle/product/db

Set permissions for the directories.
chown -R oracle:dba /oracle
chmod 777 /tmp
(if Oracle installer complains no space, umount /tmp)

Create or update oracle bashrc /home/oracle/.bashrc. Here is an example of the oracle user settings.

export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/product/db
export ORACLE_SID=DB11G
export ORACLE_INVENTORY=/oracle/inventory
export ORACLE_BASE ORACLE_SID ORACLE_HOME
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export EDITOR=vi
export VISUAL=vi

unzip Oralce files
unzip linux_11gR2_database_1of2.zip -d /media
unzip linux_11gR2_database_2of2.zip -d /media

chmod -R 777 /media/database
chown -R oracle:oinstall /media/database

as oracle
startxfce4
cd /media/database
./runInstaller -ignoreSysPrereqs

install software only

Create Listener
netca
Listener name: LISTENER
TCP 1521
need to change /etc/hosts to give hostname IP address and change listener.ora to use the hostname

/oracle/product/db/bin/lsnrctl start LISTENER

crete databse
dbca

Global database name: DB11G.WORLD
SID: DB11G

create user:
create user xxx identified by xxx
grant connect to xxx
grant resource to xxx
grant dba to xxx
(select name from system_privilege_map)

Start/Stop database server:
sqlplus /nolog
SQL>connect sys/ as sysdba
SQL>startup

stop server:
SQL>shutdown immediate

Start/Stop listener: (port 1521)
as oracle
lsnrctl start
lsnrctl stop

port forwarding:
/Applications/VirtualBox.app/Contents/MacOS/VBoxManage modifyvm "oracle_32" --natpf1 "oracle,tcp,,1521,,1521"