Você está na página 1de 21

Oracle Database 11g Release 2 on Ubuntu 12.

04 HOWTO
Submitted by hswong3i on Sat, 2012-04-28 10:37 This HOWTO will guide you though installation of Oracle Database 11g Release 2 on Ubuntu 12.04. Before start I will assume you have a clean Ubuntu Server 12.04 installed with minimal packages requirement. It is strongly recommend to install on a new host, as it will modify a lot of default settings ;-)

Install the base system


First of all you should install Ubuntu 12.04 with minimal packages, almost nothing else is required at the beginning. After initial installation run the following command to upgrade your system as latest stable + some optional useful packages:
aptitude update && \ aptitude -y full-upgrade && \ tasksel install openssh-server && \ tasksel install server && \ tasksel install mail-server && \ aptitude -y install colordiff mlocate ntp pwgen rsync vim

In case you are NOT using remote X11 with SSH so local GUI is required, install additional packages as below:
tasksel install lubuntu-core

Once everything get ready you may start the GUI and test with:
startx

Check your /etc/hostname and update as below:


localhost.localdomain

Check your /etc/hosts and update as below:


127.0.0.1 localhost.localdomain localhost

Check your /etc/resolv.conf and update as below:

search localdomain

In case of using OpenStack VM, default search domain assigned by DHCP would be "novalocal"; therefore we need to update /etc/dhcp/dhclient.conf as below:
supersede domain-name "localdomain"; supersede domain-search "localdomain", "novalocal";

Then restart network by:


/etc/init.d/networking restart

Running /etc/init.d/hostname.sh (or simply reboot your Ubuntu), then test the hostname of system with:
hostname

Remeber to double check if time zone setup correctly:


dpkg-reconfigure tzdata

Ok up to this point your Ubuntu 12.04 should basically configure for installing Oracle 11gR2.

Check your hardware setup


First of all, you need to have AT LEAST 1GB of physical memory (I use 2GB here). Check it with:
grep MemTotal /proc/meminfo

On the other hand, it is suggest to have swap with 1.5 time of your physical memory, e.g. around 2GB. Check it with:
grep SwapTotal /proc/meminfo

In case I am using libvirt + KVM VM client, I don't hope to create swap partition by default or else if all VMs are running out of resourse they will all keep on swapping to harddisk and finally all gone... Here I will create a temperate swap file and activate it during installation; once reboot it will gone automatically (or manually disable it with swapoff /tmp/swap):
dd if=/dev/zero of=/tmp/swap bs=1M count=4096 chmod 600 /tmp/swap mkswap /tmp/swap swapon /tmp/swap grep SwapTotal /proc/meminfo

Shared memory is very important, too. Or else you may face the ORA-00845 error message. First check it with:
df -kh /dev/shm/

If you have less than 512MB (I will suggest for 1GB), edit your /etc/fstab and add/modify the following line:
tmpfs /dev/shm tmpfs defaults,size=1024M 0 0

Then remount it and check the size once again:


mount -o remount /dev/shm df -kh /dev/shm/

Install dependence packages


As I assume you have Ubuntu 12.04 installed correctly with X11, we just need to dig into dependence packages installation directly (in case of AMD64):
aptitude -y install alien binutils build-essential cpp-4.4 debhelper g++4.4 gawk gcc-4.4 gcc-4.4-base gettext html2text ia32-libs intltool-debian ksh lesstif2 lib32bz2-dev lib32z1-dev libaio-dev libaio1 libbeecrypt7 libc6 libc6-dev libc6-dev-i386 libdb4.8 libelf-dev libelf1 libltdl-dev libltdl7 libmotif4 libodbcinstq4-1 libodbcinstq4-1:i386 libqt4-core libqt4-gui libsqlite3-0 libstdc++5 libstdc++6 libstdc++6-4.4-dev lsb lsbcore lsb-cxx lsb-desktop lsb-graphics lsb-qt4 make odbcinst pax podebconf rpm rpm-common sysstat unixodbc unixodbc-dev unzip

System groups and users


Check your existing setup with:
grep oinstall /etc/group grep dba /etc/group grep nobody /etc/group id oracle id nobody

Most likely, you should run the following command for create the required system groups and users. Latest Ubuntu already come with user nobody so we don't need to retouch it:
addgroup --system oinstall addgroup --system dba useradd -r -g oinstall -G dba -m -s /bin/bash -d /var/lib/oracle oracle passwd oracle

Configure kernel parameters


Check your existing setup with:

/sbin/sysctl /sbin/sysctl /sbin/sysctl /sbin/sysctl /sbin/sysctl /sbin/sysctl /sbin/sysctl /sbin/sysctl

-a -a -a -a -a -a -a -a

| | | | | | | |

grep grep grep grep grep grep grep grep

sem shm file-max ip_local_port_range rmem_default rmem_max wmem_default wmem_max

Then edit your /etc/sysctl.conf and add the following lines:


fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 536870912 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 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 = 1048586

Run the following command to reload these kernel parameters:


sysctl -p

Shell limits for oracle user


Add the following to /etc/security/limits.conf as below:
oracle oracle oracle oracle oracle soft hard soft hard soft nproc nproc nofile nofile stack 2047 16384 1024 65536 10240

Check (or add) if the following line exits within /etc/pam.d/login:


session required /lib/security/pam_limits.so

Check (or add) if the following line exits within /etc/pam.d/su:


session required pam_limits.so

Create required directories


Create required directory and change permission:
rm -rf /u01 /u02 mkdir -p /u01/app/oracle mkdir -p /u02/oradata

chown -R oracle:oinstall /u01 /u02 chmod -R 775 /u01 /u02

Configuring the oracle user's environment


Add following line to /var/lib/oracle/.profile (as i will create a AL32UTF8 database; change to US7ASCII if you will create ASCII database). This will also map Oracle's /bin to your $PATH so can run Oracle's binary directly when login as user oracle:
if [ $SHELL ulimit -p ulimit -n else ulimit -u fi = "/bin/ksh" ]; then 16384 65536 16384 -n 65536

umask 022 export ORACLE_HOSTNAME=localhost.localdomain export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 export ORACLE_SID=AL32UTF8 export NLS_LANG=.AL32UTF8 export ORACLE_UNQNAME=AL32UTF8 unset TNS_ADMIN if [ -d "$ORACLE_HOME/bin" ]; then PATH="$ORACLE_HOME/bin:$PATH" fi

Fake Oracle installer


As mentioned before , Ubuntu is not listed as Oracle officially support platform and so we need to "fake" it. Create symbolic links:
mkdir ln -s ln -s ln -s ln -s ln -s ln -s ln -s ln -s ln -s /usr/lib64 /etc /etc/rc.d /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib64/ /usr/bin/awk /bin/awk /usr/bin/basename /bin/basename /usr/bin/rpm /bin/rpm /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64/ /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib64/ /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /lib64/ /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib64/

Also mask ourself as RedHat:


echo 'Red Hat Linux release 5' > /etc/redhat-release

Last step before installation start


First of all, login with your new oracle user, with X enabled.

If you are using PuTTY + Xming, for sure that the X11 forward is enabled. Copy the file linux_11gR1_database.zip to oracle's home directory, then unzip it:
cp linux.x64_11gR2_database_1of2.zip /var/lib/oracle cp linux.x64_11gR2_database_2of2.zip /var/lib/oracle cd /var/lib/oracle unzip -q linux.x64_11gR2_database_1of2.zip unzip -q linux.x64_11gR2_database_2of2.zip chown -Rf oracle:oinstall /var/lib/oracle/

I will STRONGLY suggest for a complete reboot, and double-check ALL pre-installation BEFORE starting the next step.

Recommended installation procedures


First of all login with useraccount "oracle" and start the X11 with startx, then start the installer with:
cd /var/lib/oracle/database && ./runInstaller

Next we go though the installation (I don't have the "Oracle Support Password" so just skip in here):

In "Selection Installation Option", choose "Create and configure a database":

In "System Class", choose "Server Class" (we hope to give a full control during installation):

In "Node Selection", choose "Single instance database installation":

In "Select Install Type", choose "Advanced install":

In "Select Product Languages", I choose to install all available languages:

In "Select Database Edition", I choose "Enterprise Edition":

In "Specify Installation Location", it should default as below:


Oracle Base: /u01/app/oracle Sofeware Location: /u01/app/oracle/product/11.2.0/dbhome_1

In "Create Inventory", it should default as below:


Inventory Directory: /u01/app/oraInventory oraInventory Group Name: oinstall

In "Select Configure Type", choose "General Purpose / Transaction Processing":

(IMPORTANT!) In "Specify Database Identifiers", configure as below:


Global database name: AL32UTF8.localdomain Oracle Service Identifier (SID): AL32UTF8

In "Specify Configuration Options", configure as below:


Memory -> Enable Automatic Memory Management: TRUE Character sets: Use Unicode (AL32UTF8)

In "Specify Management Options", choose "Use Database Control for database management" but keep other else empty:

In "Specify Database Storage Options", choose "File System" where:

Specify database file location: /u02/oradata

In "Specify Recovery Options", choose "Do not enable automated backups":

In "Specify Schema Passwords", I am a bit lazy so choose "Use the same password for all accounts" (don't do this in production server!):

In "Privileged Operating System Groups", confirm as below:


Database Administrator (OSDBA) Group: dba Database Operator (OSOPER) Group: oinstall

In "Preform Prerequisite Checks", just simply ignore all warning message (since we are using Debian but not Oracle officially supported OS):

So just confirm everything in "Summary":

And now let's go for a coffee break ;-)

Oh it should that almost done! Special note for Ubuntu 12.04: If you face error during installation so update as below:
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 sed -i 's/^\(\s*\$(MK_EMAGENT_NMECTL)\)\s*$/\1 -lnnz11/g' $ORACLE_HOME/sysman/lib/ins_emagent.mk sed -i 's/^\(\$LD \$LD_RUNTIME\) \(\$LD_OPT\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/bin/genorasdksh sed -i 's/^\(\s*\)\(\$(OCRLIBS_DEFAULT)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/srvm/lib/ins_srvm.mk

sed -i 's/^\(TNSLSNR_LINKLINE.*\$(TNSLSNR_OFILES)\) \(\$(LINKTTLIBS)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/network/lib/env_network.mk sed -i 's/^\(ORACLE_LINKLINE.*\$(ORACLE_LINKER)\) \(\$(PL_FLAGS)\)/\1 Wl,--no-as-needed \2/g' $ORACLE_HOME/rdbms/lib/env_rdbms.mk

Then keep ongoing for installation ;-)

Now following the instructions and run the following commands with "root" user:
/u01/app/oraInventory/orainstRoot.sh /u01/app/oracle/product/11.2.0/dbhome_1/root.sh

Ok you get it!

Confirm with installation progress In previous screen the installer mentioned that we can access "Enterprise Manager Database Control URL - (AL32UTF8)" from https://localhost.localdomain:1158/em, so now let's open the browser and test it with following account:

User Name: SYS Password: your_secret_password Connect As: SYSDBA

Once login it should show as below:

Autostart Oracle during system boot


There is almost for sure that you will hope to start your Oracle automatically during system boot. Even you may turn this feature off, but the init.d script is very useful, too. First of all, specify which database instant will be started together with Oracle. Edit /etc/oratab as below:
AL32UTF8:/u01/app/oracle/product/11.2.0/dbhome_1:Y

Next, create init.d script as /etc/init.d/oracle:


#!/bin/bash # # Run-level Startup script for the Oracle Instance and Listener # ### BEGIN INIT INFO # Provides: Oracle # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Startup/Shutdown Oracle listener and instance ### END INIT INFO ORA_HOME="/u01/app/oracle/product/11.2.0/dbhome_1" ORA_OWNR="oracle" # if the executables do not exist -- display error if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ] then echo "Oracle startup: cannot start" exit 1 fi # depending on parameter -- startup, shutdown, restart # of the instance and listener or usage display case "$1" in start) # Oracle listener echo -n "Starting su - $ORA_OWNR -c su - $ORA_OWNR -c and instance startup Oracle: " "$ORA_HOME/bin/dbstart $ORA_HOME" "$ORA_HOME/bin/lsnrctl start"

#Optional : for Enterprise Manager software only su - $ORA_OWNR -c "$ORA_HOME/bin/emctl start dbconsole" touch /var/lock/oracle echo "OK" ;; stop) # Oracle listener and instance shutdown echo -n "Shutdown Oracle: " #Optional : for Enterprise Manager software only su - $ORA_OWNR -c "$ORA_HOME/bin/emctl stop dbconsole" su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop" su - $ORA_OWNR -c "$ORA_HOME/bin/dbshut $ORA_HOME" rm -f /var/lock/oracle echo "OK" ;; reload|restart) $0 stop

$0 start ;; *) echo "Usage: $0 start|stop|restart|reload" exit 1 esac exit 0

Permission is very important, too:


chmod 755 /etc/init.d/oracle

Finally, install the script so Oracle will start during system bootup:
update-rc.d-insserv oracle defaults 99 01

NOTE: You may find the following error message during /etc/init.d/oracle/stop:
Shutdown Oracle: ulimit: 25: bad number

You can then update /u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl with #!/bin/bash to solve the problem:
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 sed -i 's/^#!\/bin\/sh -f\s*/#!\/bin\/bash -f/g' $ORACLE_HOME/bin/emctl

Você também pode gostar