Tuesday, April 20, 2010

Install Oracle 11g R2 on Ubuntu 10.4

I follow the steps from
http://www.pythian.com/news/1355/installing-oracle-11gr1-on-ubuntu-810-intrepid-ibex/

I have to make some adjustments for my Ubuntu 10.4 64 bits, so here are steps:

luan@luan-laptop:~$ sudo su -
[sudo] password for luan:
root@luan-laptop:~# apt-get install gcc make binutils gawk x11-utils rpm alien ksh lsb-rpm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
(... long list ...)
Suggested packages:
(... another long list ...)
The following NEW packages will be installed:
(... even longer list ...)
0 upgraded, 54 newly installed, 0 to remove and 0 not upgraded.
Need to get 29.3MB of archives.
After this operation, 93.0MB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://us.archive.ubuntu.com lucid/main gawk 1:3.1.6.dfsg-0ubuntu1 [500kB]
Get:2 http://us.archive.ubuntu.com lucid/main libdrm2 2.3.1-0build1 [260kB]
(...)
Setting up build-essential (11.4) ...
Processing triggers for libc6 ...
ldconfig deferred processing now taking place
root@luan-laptop:~#

root@luan-laptop:~# apt-get install libaio1 lesstif2 libmotif3
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libxp6
The following NEW packages will be installed:
lesstif2 libaio1 libmotif3 libxp6
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 1941kB of archives.
After this operation, 4772kB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://us.archive.ubuntu.com lucid/main libxp6 1:1.0.0.xsf1-2 [16.7kB]
Get:2 http://us.archive.ubuntu.com licid/multiverse libmotif3 2.2.3-2 [1283kB]

root@luan-laptop:~# cd /bin
root@luan-laptop:/bin# ls -l /bin/sh

lrwxrwxrwx 1 root root 4 2010-20-04 21:33 /bin/sh -> dash
root@luan-laptop:/bin# ln -sf /bin/bash /bin/sh
root@luan-laptop:/bin# ls -l /bin/sh

lrwxrwxrwx 1 root root 4 2010-20-04 22:34 /bin/sh -> bash
root@luan-laptop:/bin#
Now create some users:

root@luan-laptop:/bin# cd
root@luan-laptop:~# pwd

/root
root@luan-laptop:~# addgroup oinstall
Adding group `oinstall' (GID 1001) ...
Done.
root@luan-laptop:~# addgroup dba
Adding group `dba' (GID 1002) ...
Done.
root@luan-laptop:~# addgroup nobody
Adding group `nobody' (GID 1003) ...
Done.
root@luan-laptop:~# usermod -g nobody nobody
root@luan-laptop:~# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
root@luan-laptop:~# mkdir /home/oracle
root@luan-laptop:~# chown -R oracle:dba /home/oracle
root@luan-laptop:~# ln -s /usr/bin/awk /bin/awk
root@luan-laptop:~# ln -s /usr/bin/rpm /bin/rpm
root@luan-laptop:~# ln -s /usr/bin/basename /bin/basename
root@luan-laptop:~# mkdir /etc/rc.d
root@luan-laptop:~# for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
root@luan-laptop:~# mkdir -p /u01/app/oracle
root@luan-laptop:~# chown -R oracle:dba /u01
root@luan-laptop:~#

Copy the unpacked Oracle 11gR1 to the box we’re working on:


luan@luan-laptop:~$ sudo su -
root@luan-laptop:~# mv /home/download/database /media/database
root@luan-laptop:~# chown -R oracle:oinstall /media/database
root@luan-laptop:~#

Now change some system-wide configuration files, starting with /etc/sysctl.conf:

root@luan-laptop:~# cd /etc
root@luan-laptop:/etc# cp sysctl.conf sysctl.conf.original

Edit it, adding the following lines to the bottom of the file:

fs.file-max = 65535
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
Then, let’s modify /etc/security/limits.conf:

root@luan-laptop:/etc# cd /etc/security/
root@luan-laptop:/etc/security# cp limits.conf limits.conf.original

Add the following lines to the bottom of the file:

oracle soft nproc 2047
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535
The last one, for now, is /etc/pam.d/login:

root@luan-laptop:/etc/security# cd /etc/pam.d
root@luan-laptop:/etc/pam.d# cp login login.original

Edit login, adding to it:

session required /lib/security/pam_limits.so
session required pam_limits.so

Here is how to get display working on my laptop.

oracle@luan-laptop:~$ exit
logout
root@luan-laptop:~# DISPLAY=:0; export DISPLAY; xhost +;
access control disabled, clients can connect from any host
root@luan-laptop:~# su - oracle
oracle@luan-laptop:~$ DISPLAY=:0 ; export DISPLAY
oracle@luan-laptop:~$ xclock
oracle@luan-laptop:~$


oracle@luan-laptop:~$ cd /media/database
oracle@luan-laptop:/media/database$ ./runInstaller -ignoreSysPrereqs


Now the windows installation screen will appear. You should be able to follow the default installation.

....

This is a startup script:

root@luan-laptop:/# cat /etc/init.d/oracledb
#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Listener and Instances
# It relies on the information on /etc/oratab

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi

case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
touch /var/lock/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
rm -f /var/lock/oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac

exit 0
root@luan-laptop:/#


root@luan-laptop:/# chmod a+x /etc/init.d/oracledb
root@luan-laptop:/# update-rc.d oracledb defaults 99

update-rc.d: warning: /etc/init.d/oracledb missing LSB information
update-rc.d: see
Adding system startup for /etc/init.d/oracledb ...
/etc/rc0.d/K99oracledb -> ../init.d/oracledb
/etc/rc1.d/K99oracledb -> ../init.d/oracledb
/etc/rc6.d/K99oracledb -> ../init.d/oracledb
/etc/rc2.d/S99oracledb -> ../init.d/oracledb
/etc/rc3.d/S99oracledb -> ../init.d/oracledb
/etc/rc4.d/S99oracledb -> ../init.d/oracledb
/etc/rc5.d/S99oracledb -> ../init.d/oracledb


To startup database:


oracle@luan-laptop:~$ . oraenv
ORACLE_SID = [oracle] ? testdb

The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle
oracle@luan-laptop:~$
oracle@luan-laptop:~$
oracle@luan-laptop:~$ sqlplus '/as sysdba'


SQL*Plus: Release 11.2.0.1.0 Production on Wed Apr 21 09:39:17 2010

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

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1269366784 bytes
Fixed Size 2212976 bytes
Variable Size 822086544 bytes
Database Buffers 436207616 bytes
Redo Buffers 8859648 bytes
SQL> alter database mount;

Database altered.

SQL> alter database open;

Database altered.

SQL>

------

How to start Oracle Enterprise Manager


oracle@luan-laptop:~$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
https://luan-laptop:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ............. started.
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.2.0/dbhome_1/luan-laptop_testdb/sysman/log
oracle@luan-laptop:~$

8 comments:

  1. Hi Luan, you installed Oracle 11g R2 on a laptop, right? Does your laptop have a static ip address or does it get an ip addr through dhcp?

    ReplyDelete
  2. Good Artical....

    Add "sysctl -p " for quick reflection

    ReplyDelete
  3. Hi,

    I am not able to connect from client machine to oracle server. I got following error in my Rails App

    rake db:migrate
    rake aborted!
    ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA

    (See full trace by running task with --trace)


    Can you help me.. How to fix it

    ReplyDelete
  4. My database unavailable after machine reboot and I have to give following commands to open database for access.
    1) #. oraenv (To set SID to orcl)
    2) sqlplus '/as sysdba'
    3) SQL > startup nomount;
    4) SQL > alter database mount;
    5) SQL > alter database open;
    6) # emctl start dbconsole


    How to make above steps automatic ?

    Thanks,
    Avin Tokade

    ReplyDelete
  5. You can try something like this:

    This is for version 11.1 but you may change to fit with your version.

    #!/bin/bash
    #
    # /etc/init.d/oracledb
    #
    # Run-level Startup script for the Oracle Listener and Instances
    # It relies on the information on /etc/oratab

    # these are the paths for our base installation
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=/u01/app/oracle/product/11.1.0/jaunty11
    export ORACLE_OWNR=oracle
    export PATH=$PATH:$ORACLE_HOME/bin

    if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
    then
    echo "Oracle startup: cannot start"
    exit 1
    fi

    case "$1" in
    start)
    # Oracle listener and instance startup
    echo -n "Starting Oracle: "
    su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
    su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
    touch /var/lock/oracle
    echo "OK"
    ;;
    stop)
    # Oracle listener and instance shutdown
    echo -n "Shutdown Oracle: "
    su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
    su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
    rm -f /var/lock/oracle
    echo "OK"
    ;;
    reload|restart)
    $0 stop
    $0 start
    ;;
    *)
    echo "Usage: `basename $0` start|stop|restart|reload"
    exit 1
    esac

    exit 0

    ReplyDelete
  6. @Toi, I am sorry. I didn't see your comment until now. No, I am not using static ip address. My database is not online. Only one my laptop.

    Thanks,
    Luan

    ReplyDelete
  7. Hello,

    When i given command "DISPLAY=:0; export DISPLAY; xhost +;" in root i got following error:-

    No protocol specified
    xhost: unable to open display ":0"

    Thanks,
    Amol Shinde.

    ReplyDelete
  8. Hi,

    When I am executing command . oraenv it shows error "bash: oraenv: No such file or directory"

    Please help to resolve it

    -sunil

    ReplyDelete