Friday, January 6, 2012

How to install Oracle 11g Database Server on CentOS 6.2

UPDATED!:

The former post I wrote was a how to install an Oracle-ready CentOS 6.2 Linux Server box.Its time then to install the Oracle 11g Database server. This post is about the same thing, but using a CentOS 5, so I based this how to on it and improve some minor things, but the whole idea is pretty much the same.

Hardware Requirements

To check out your recommended hardware requirements, login to the CentOS 6.2 Linux Server box as the bozz user and verify the below list:

    How much memory:

$ grep -i memtotal /proc/meminfo


        results: should be at least 1GB

     How much swap:

$ grep -i swaptotal /proc/meminfo

        results:
       
        - should be 1.5 the size of memtotal if memtotal < 2GB

             - should be equal to memtotal if memtotal is between 2GB and 8GB

             - should be .75 the size of memtotal if memtotal > 8GB

    What processor type:

$ grep "model name" /proc/cpuinfo

        results: informational
   
    How much available RAM and swap:

$ free

        results: informational

    How much shared memory available:

$ df -k /dev/shm

        results: informational

        purpose: The shared memory should be sized to be at least the greater of MEMORY_MAX_TARGET and MEMORY_TARGET for each Oracle instance on the computer.

    How much disk space in /tmp:

$ df -k /tmp

        results: should have at least 400MB available

    How much disk space for Oracle binaries:

$ df -k

        results: Depending on installation type you should have between 1.5GB and 3.5GB


Software Requirements

To check out your recommended software requirements, login to the CentOS 6.2 Linux Server box as the bozz user and verify the below list:      

   What distribution and version of Linux is installed:

$ cat /proc/version
        results:  Linux version 2.6.32-220.2.1.el6.x86_64 (mockbuild@c6-x8664-build.centos.org) 

(gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) 

#1 SMP Fri Dec 23 02:21:33 CST 2011


    What version of the kernel is installed:

$ uname -r
        results: 2.6.32-220.2.1.el6.x86_64

    Ensure that the following packages are installed:

$ rpm -q compat-libstdc++-33.x86_64 binutils elfutils-libelf elfutils-libelf-devel 
$ rpm -q glibc glibc-common glibc-devel glibc-headers gcc gcc-c++ libaio-devel 
$ rpm -q libaio libgcc libstdc++ libstdc++ make sysstat unixODBC unixODBC-devel
    if some of this packages are missing then install them
  
$ sudo yum install compat-libstdc++-33.x86_64 binutils elfutils-libelf elfutils-libelf-devel 
$ sudo yum install glibc glibc-common glibc-devel glibc-headers gcc gcc-c++ libaio-devel 
$ sudo yum install libaio libgcc libstdc++ libstdc++ make sysstat unixODBC unixODBC-devel

     also install unzip package:
$ sudo yum install unzip 

Install Steps

  1. Login in as bozz user
  2. Create Oracle's user and groups
    1. Create groups oinstall & dba:
    2. $ sudo groupadd oinstall
      $ sudo groupadd dba
      
    3. Create the oracle user and set its password:
    4. $ sudo useradd -m -g oinstall -G dba -s /bin/bash oracle
      $ sudo passwd oracle
      
    5. Check if nobody user exists, this user is almost always created on a base CentOS installation:
    6. $ id nobody
      uid=99(nobody) gid=99(nobody) groups=99(nobody)
      
      if this user doesn't exists then use the following command to create it:
      $ sudo useradd nobody
      
  3. Configure some kernel parameters. The following kernel parameters must be validated and possibly changed. Use the commands given below to view a particular kernel setting and then change it if the setting is lower than the recommendation given here. The changed parameters are in bold in my case.
    1. Verify kernel parameters: 
    2. # semaphores: semmsl, semmns, semopm, semmni
      $ sysctl -a | grep kernel.sem
      
      results should be >= than: 
      
      kernel.sem = 250        32000   100     128
      
      $ sysctl -a | grep kernel.shm
      
      results should be >= than: 
      
      kernel.shmmax = 536870912
      
      kernel.shmmni = 4096
      
      kernel.shmall = 2097152
      
      $ sysctl -a | grep file-max
      
      results should be >= than: 
      
      fs.file-max = 6815744
      
      $ sysctl -a | grep ip_local_port_range
      
      results should be >= than: 
      
      net.ipv4.ip_local_port_range = 9000 65500
      
      $ sysctl -a | grep rmem_default
      
      results should be >= than: 
      
      net.core.rmem_default = 262144
      
      $ sysctl -a | grep rmem_max
      
      results should be >= than: 
      
      net.core.rmem_max = 4194304
      
      $ sysctl -a | grep wmem_default
      
      results should be >= than: 
      
      net.core.wmem_default = 262144
      
      $ sysctl -a | grep wmem_max
      
      results should be >= than: 
      
      net.core.wmem_max = 1048576
      
      $ sysctl -a | grep aio-max-nr
      
      results should be >= than: 
      
      fs.aio-max-nr = 1048576
      
    3. Make the changes permanent by editing the archive /etc/sysctl.conf file. This is given as an example only and does not reflect the results obtained above by the sysctl commands. Only add lines that are needed and do not change any values to be lower than the base installation might have assigned. In my case I only change the following settings on /etc/sysctl.conf:
    4. kernel.sem = 250 32000 100 128
      fs.file-max = 6815744
      net.ipv4.ip_local_port_range = 9000 65500
      net.core.rmem_default = 262144
      net.core.rmem_max = 4194304
      net.core.wmem_default = 262144
      net.core.wmem_max = 1048576
      fs.aio-max-nr = 1048576
      
    5. Apply the changes now:
    6. $ sudo sysctl -p
      
  4. Setting shell limits for the oracle user
    1. Edit the file /etc/security/limits.conf:
    2. $ sudo nano /etc/security/limits.conf
      
      and add the following:
      oracle soft nproc  2047
      oracle hard nproc  16384
      oracle soft nofile 1024
      oracle hard nofile 65536
      
    3. Edit /etc/pam.d/login:
    4. $ sudo nano /etc/pam.d/login
      and add the following depending on the architecture:
      session required /lib64/security/pam_limits.so
      session required pam_limits.so
      NOTE: be aware of the real location of pam_limits.so. It depens on the architecture and distro. On CentOS 6.2 64 bits /lib64/security/pam_limits.so
    5. Create a new profile archive at  /etc/profile.d/custom.sh:
    6. $ sudo nano /etc/profile.d/custom.sh
      and add the following content:
      #!/bin/bash
      
      if [ $USER = "oracle" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
          ulimit -p 16384
          ulimit -n 65536
        else
          ulimit -u 16384 -n 65536
        fi
      fi
      then add execution permissions to profile script: 
      $ sudo chmod +x /etc/profile.d/custom.sh
  5. Creating necessary directories to install the Oracle Software
    1. Check if you have enough space on disk and choose a directory to install:
    2. $ df -kh
    3. Create subdirectories and give permissions to the oracle user:
    4. $ sudo mkdir -p /opt/app/oracle/product/11.2.0
      $ sudo chown -R oracle:oinstall /opt/app
      $ sudo chmod -R 775 /opt/app
      
  6. Logout, login as oracle user (don't forget ssh -Y oracle@SERVER) and set the environment for the installation by adding the following to ~/.bash_profile: :
  7. $ nano ~/.bash_profile
    
    add the following line:
    umask 022
    
    export TMPDIR=$TMP
    export ORACLE_BASE=/opt/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    export PATH=$ORACLE_HOME/bin:$PATH
    
    exit nano (Ctrl+X) and execute oracle's .bash_profile for testing purposes:
    $ source ~/.bash_profile
    logout from oracle user:
    $ exit
  8. Ensure oracle user is using an X Windows System. For example you can install and execute xterm:
  9. $ sudo yum install xterm
    
    logout and login remotely again as oracle user from a Linux client machine with Desktop environment:
    $ ssh -Y oracle@SERVER
    
    test if xterm works you should be able to see a X11 Windows on your client Desktop environment, if not then enable SSH X11 Forwarding (see last step)
    $ xterm
    
  10. Start the database installer (you should be able to see a X11 Windows with the Oracle database installation wizard on your client Desktop environment):
    $ cd /tmp/database 
    $ ./runInstaller
  11. NOTE: I assume you already had the database installer on the server. If not then copy the installer archives to the server via scp and uncompress them: 
    on the client run:
    $ scp linux.x64_11gR2_database_1of2.zip oracle@SERVER:/tmp
    $ scp linux.x64_11gR2_database_2of2.zip oracle@SERVER:/tmp
    
    on the server run:
    $ pushd /tmp
    $ unzip linux.x64_11gR2_database_1of2.zip
    $ unzip linux.x64_11gR2_database_2of2.zip
    $ popd 
    
  12. Optionally specify email address to be informed about security issues
  13. Choose "Install database software only", click "Next"
  14. Choose "Single instance database installation", click "Next"
  15. Add another language besides of English if you wish, click "Next"
  16. Choose 'Enterprise Edition' and on "Select options" choose the components you wish to install, click "Next"
  17. Set the following settings and click "Next":
    • verify Oracle Base: '/opt/app/oracle'
    • verify Oracle Home: '/opt/app/oracle/product/11.2.0/db_1'
  18. Verify path of inventory directory: '/opt/app/oraInventory'  and verify group name for install of 'oinstall', click "Next" 
  19. Prerequisite Checks:  the installer will verify the system environment and report on any issues it may find. If all goes well you will get the status of 'Succeeded' for every check. You have to check 'Ignore All' but ensure at least that the following checks pass
    1. Physical memory (also Available)
    2. Free space
    3. User and groups existence
    4. Group membership
    5. Hard and soft limits
    6. Architecture
    7. Kernel version
    8. OS Kernel parameters
    9. Swap size
    10. Run level.
    11. Packages
    12. Users with same ID
  20. Summary: This screen give a summary of the installation you are about to perform. Click and expand the products being installed to give you an idea of the what product and version is going to be installed.
    1. validate 'Global Settings' for directories
    2. validate 'Space Requirements'
    3. Click NEXT
  21. Install: This screen gives a status of what is being installed. If all system settings have been properly set and all packages been installed properly then this should proceed without error. 
    1. Note the time it takes for specific products. If you notice one hanging or taking a long amount of time (greater than 10 minutes) you could have a condition that requires a pre-installation patch. Don't stop the installer yet but instead start looking for a bug / patch for the Oracle 11g installation process and the actual product being installed.
    2. Execute configuration scripts, when the wizard ask it:
      • open up a different terminal window
      • login as the bozz user
      • run:
      • $ sudo /opt/app/oraInventory/orainstRoot.sh
        $ sudo /opt/app/oracle/product/11.2.0/db_1/root.sh
        accept a default of /usr/local/bin
      • click OK
  22. Cleanup: If you downloaded the software from the net you can now remove .zip file and the complete directory structure you unzipped it to.
  23. Final setup:  Add the following lines to oracle's $HOME/.bash_profile archive. This will allow you to execute various Oracle binaries to create databases, configure network settings, and generally manage the Oracle database environment:
  24. umask 022
    
    export TMPDIR=/tmp
    export ORACLE_BASE=/opt/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    export PATH=$ORACLE_HOME/bin:$PATH
    NOTE: remember to first login as oracle user to edit the $HOME/.bash_profile archive. Finally ensure the execution permissions for this archive.

Post Install

References

18 comments:

  1. Hey, thanks for this very informative step-by-step post. It was really handy. I ran through the install in CentOS 6.2 on a VirtualBox VM. I ran into a couple of minor issues that might help other folks:
    I went and installed all of the packages listed in the Oracle Quick Install guide and in this post. I was able to install compat-libstdc++-33.x86_64. However, there is no package called just compat-libstdc++. This one failed. And during the Installer's prerequisite checks, it failed to fing some of the packages. Since I knew I had installed some version (perhaps not the specific version number that Oracle was looking for) I went ahead and ignored all of these, and proceeded withe the install. Everything worked ok. Also, adding the line:
    export TMPDIR=$TMP
    to oracle's .bash_profile caused the GUI login to fail every time. This was because there was no environment variable set for $TMP. Once I changed that to TMPDIR=/tmp, everything started working again.
    Anyway, hopefully that helps others. And thanks again for your post!

    ReplyDelete
    Replies
    1. Thanks!, I fixed it according to your suggestions.

      Delete
    2. Spot on! Took me ages to find this out for myself, I then thought I would check this post to see if someone else had seen this before. Adding specifics for google searchability

      /usr/libexec/gconf-sanity-check-2 exited with status 256

      This is caused by TMPDIR being set incorrectly to $TMP (assuming $TMP has not been set.

      Delete
  2. This guide worked great for centos 6.3 64 bit, but also needed the i386 equivalent packages of some of the ones you listed(named i686 on rhel/centos 6+). The checks still don't pass due to the new naming, but at least I know they were there after installing them.
    Here are the packages:
    libaio.i686
    libaio-devel.i686
    compat-libstdc++.i686
    libgcc.i686
    unixODBC
    unixODBC-devel
    unixODBC.i686
    unixODBC-devel.i686
    ksh
    mksh

    ReplyDelete
    Replies
    1. On my Centos 6.3 install this this translated. As you say the names still won't match, but at least you know there are there

      sudo yum install libaio.i686
      sudo yum install libaio-devel.i686
      sudo yum install compat-libstdc++-33.i686
      sudo yum install libgcc.i686
      sudo yum install unixODBC.i686
      sudo yum install unixODBC-devel.i686
      sudo yum install unixODBC
      sudo yum install unixODBC-devel.x86_64
      sudo yum install ksh.x86_64
      sudo yum install mksh.x86_64
      sudo yum install mksh.x86_64

      Delete
  3. Thanks for your post. It helped me al lot. I get an Error on running the /etc/profile.d/custom.sh script. I changed it to make it work properly.

    if [ $USER == "oracle" ]; then
    if [ $SHELL == "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
    else
    ulimit -u 16384 -n 65536
    fi
    fi

    ReplyDelete
  4. Hi guys. I am running into a problem while running runInstaller:
    Checking Temp space: must be greater than 80 MB. Actual 8111 MB Passed
    Checking swap space: must be greater than 150 MB. Actual 2015 MB Passed
    Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed
    Preparing to launch Oracle Universal Installer from /tmp/OraInstall2012-11-03_06-41-36AM. Please wait ...[oracle@localhost database]$ Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/OraInstall2012-11-03_06-41-36AM/jdk/jre/lib/i386/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory

    I do see the file there:

    /tmp/OraInstall2012-11-03_06-41-36AM/jdk/jre/lib/i386/xawt/libmawt.so
    /tmp/OraInstall2012-11-03_06-41-36AM/jdk/jre/lib/i386/motif21/libmawt.so
    /tmp/OraInstall2012-11-03_06-41-36AM/jdk/jre/lib/i386/headless/libmawt.so

    I've installed the packages indicated above. On googling that error I see it might have to do with the LD_LIBRARY_PATH being set.

    Any ideas of what I am doing wrong here?

    Thanks
    J.








    ReplyDelete
  5. Hello, could you please advise me how to make xclock working for oracle user?
    I did everything you have mentioned in "enable SSH X11 forwarding", but i cant start xclock:/

    xclock is working with root or my user

    under oracle user i have this error :

    No protocol specified
    Error : Can`t open display: :0.0
    I can not start ./runInstaller with user oracle because of xterm not working :/

    ReplyDelete
    Replies
    1. Hey Michal ,

      did u find solution to your problem?
      as i m also getting this problem

      thanks

      Delete
  6. of note, we could not execute .runInstaller (error was permission denied at line 157 on the /tmp/database/install/.oui file)

    ran 'chmod -R a+x /tmp/database/install' (whatever your install path is obviously) per this CKPT's comment on this forum post:
    https://forums.oracle.com/forums/thread.jspa?threadID=1102139

    and that seemed to work.

    (also, thanks to Rob Vanstone for the google search 411 on that gconf-sanity-check error! totally found it via google...)

    ReplyDelete
  7. Hi all ,

    Need urgent help.

    i m installing oracle 11g 32 bit s/w on mine centos system.

    but while installing i m getting this error.

    Xlib: connection to ":0.0" refused by server
    Xlib: No protocol specified


    while checking i found oracle user can not start xterm s/w but same is running fine by root user.

    please let me know how xterm can be used by oracle user ...what and where configuration needs to be done....please help

    thanks
    akash

    ReplyDelete
  8. I need ur helps in my host PC windows 7 64 bit and 4 GB RAM in that I have installed vm ware workstations on Cent Os in that OS how can i install oracle11g linux x-64 while am trying to install get some error like operating system not found. whether Cent OS will be support Oracle linux 11g or not...

    --
    Thanks & Regards
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Karthick Chinnaraj
    Mobile : (TN) - 09629108283 / (KA) - 09035810969
    Skype : karthickchinnaraj / Linkedin : www.linkedin.com / Facebook : www.facebook.com
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. The following line in the oracle user's ~/.bash_profile breaks GNOME/xterm sessions:

    export TMPDIR=$TMP

    The TMPDIR variable should not be redefined. Apparently GNOME session's "sanity check" has a problem with that setting: "/usr/libexec/gconf-sanity-check-2 exited with status 256"

    ReplyDelete
  11. excellent description; install everything ok.
    Thanks & Regards

    ReplyDelete
  12. can i follow the same steps to install oracle 11g on ubuntu 12.04 lts 64bits???
    any help please!!!!!!??

    ReplyDelete
    Replies
    1. Yes, you can, but there may be some missing libraries on ubuntu, at least named differently. If you happen to find out how to, please publish it! I tried on past Ubuntu versions using the same steps above w/o success. Nevertheless you can try again!. Let me know your result.

      Thanks for the feedback!

      Delete