jueves, 7 de mayo de 2015

install and configure Oracle 11g Express Edition on Ubuntu

There are several guides online how to achieve the installation of Oracle XE on Ubuntu, in my case I need it for academic purposes, I am pretty sure the installation of the full Oracle Suite has to be more friendly.

Cool, I read several of those guides, maybe some of them are out of date, in other cases the steps were enough, but in my case I had to mix a lot of them in other to accomplish the process, I am using Ubuntu 14.10 so maybe this would required to custom the installation. Before begin I need to say Oracle XE just accept up to 11GB of data storage, it may use up to 1 GB of RAM -although I you have more it won't be used- and the resources used will not exceed one CPU. As you may read, Oracle XE works great if you are a beginner in this DBMS.

1. the first step is to download the package -by the way for Linux there is a RPM package-, just go to this URL:
www.oracle.com/technetwork/products/express-edition/downloads/index.html  
create your account and then the download process will start.

2. From your $HOME directory create a directory called "oracle", copy the ZIP file and unzip it using:
  unzip oracle-xe*.zip

3. Open a terminal and install some needed packages:
  sudo apt-get install alien libaio1 unixodbc vim

4. next you have to convert the rpm package to deb, using:
   sudo alien --to-deb --scripts oracle*.rpm

5. then we need to configure awk and chkconfig:
    sudo ln -s /usr/bin/awk /bin/awk
    sudo mkdir /var/lock/subsys

6. Oracle requires to have a separate shm mount moint, in order to get this type:
   sudo rm -rf /dev/shm
   sudo mkdir /dev/shm
   sudo mount -t tmpfs shmfs -o size=2048m /dev/shm

   Notice you are typing size=2048m, this is related to the amount of physical RAM your system has, take some notes about it:
   -whether you are using a 32bit based system you must type just 2048m even whether you have more of it.
   -whether you are using a 64bit based system you are free to type the amount of RAM installed. in my case I have 4 GB but I just type 3GB of it
   -if you have a swap partition less than 2 GB you need to create expand it or create a swap file. I will avoid this step because most of the systems have more than 2 GB of RAM, enough HDD space so it would be a good a idea to expand you swap partition instead to do extra -and even more confused- steps

 Now, the idea is to everytime you start your system, you may have an available working environment for Oracle, so you need to write these steps in one file as I show next:

   sudo nano /etc/rc2.d/S01shm_load
    #!/bin/sh
    case "$1" in
    start) mkdir /var/lock/subsys 2>/dev/null
           touch /var/lock/subsys/listener
           rm /dev/shm 2>/dev/null
           mkdir /dev/shm 2>/dev/null
           mount -t tmpfs shmfs -o size=2048m /dev/shm ;;
    *) echo error
       exit 1 ;;
   esac

    Finally save the file and give exec permissions:
     sudo chmod 755 /etc/rc2.d/S01shm_load

7. Now, we need to create a chkconfig script (please type each line without any quote for read purpose at the blog I had to use them), login as root:
    sudo -i
 
  Then copy these lines:
 

 
Since blogger does not have a way how to embed code snippet I had to use an external service. 
 
Type the lines exactly as they are in. 


8. logout from root:
exit

9. give exec permissions:
   sudo chmod 755 /sbin/chkconfig

10. go to the "oracle" directory you created from step 2:
    cd ~/oracle/Disk1

11. install the deb package generated:
     sudo dpkg -i oracle*deb

Wait some minutes.

At this stage, oracle-xe is installed and ready to be configured, the next steps are really important so be prepare:

12. Edit your .bashrc en add the next lines at the end:
     export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
     export ORACLE_SID=XE
     export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
     export ORACLE_BASE=/u01/app/oracle
     export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
     export PATH=$ORACLE_HOME/bin:$PATH
     save it and close it
13. configure oracle using this command:
     sudo /etc/init.d/oracle-xe configure
    

     You'll be asked about:
     -available port for Oracle XE(it suggested 8080 I chose another one)
     -available port for Oracle Listener (I kept the default: 1521)
     -A password for SYS and SYSTEM user accounts

    Then You have to wait some minutes in order to confirm all stages, If evey of them were OK you should see something like this:
    Starting Oracle Net Listener...Done
    Configuring database ... Done
    Starting Oracle Database 11g Express Edition instance... Done
    Installation completed successfully

14. So at this point, all howtos online say eveything is ready, in my case I got an error at the "configure database" stage, this is where this guide might give you something new:

After this, you have to check 4 log files at:
/u01/app/oracle/product/11.2.0/xe/config/log

At least in my case I found something useful in cloneDBCreation.log, the other ones looked ok. So I found this error:
ORA-01109 database not open

besides this message, everything looks ok, the database was mounted and unmounted, for some reasons it could not be reopened. It seems the configure process almost finished, so I decided to try to connect to DB Engine using sqlplus.

15. Cool, before this, your current user needs to be part of the dba group:
    usermod -a -G dba 
16. login using sqlplus:
     sqlplus / as sysdba

17. now you have to be logged, then type these commands:
    shut immediate
    startup

18. Verify if some instante is ready to accept connections:
   select status from v$instance;

And that's all, for the moment, I know I missed the part to load oracle as a service, for now you may use it loading it manually, it's not perfect but it is a start. In fact, the log files do not give the necessary information in order to solve properly this issue. Several years ago I tried to install Oracle (I guess it was 8i) on CentOS and the process was less complex. It would be great the guys from Oracle may create a deb package.

Suggestions are welcome.

Be good

No hay comentarios:

Publicar un comentario