Oracle Database 11g Release 2 on Ubuntu 12.04 HOWTO

来源:互联网 发布:情绪管理网络课程答案 编辑:程序博客网 时间:2024/06/10 06:32

转自:http://edin.no-ip.com/blog/hswong3i/oracle-database-11g-release-2-ubuntu-12-04-howto

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:

aptitude -y install lxde-core xorg

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=4096chmod 600 /tmp/swapmkswap /tmp/swapswapon /tmp/swapgrep 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/shmdf -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 lsb-core lsb-cxx lsb-desktop lsb-graphics lsb-qt4 make odbcinst pax po-debconf rpm rpm-common sysstat unixodbc unixodbc-dev unzip

System groups and users

Check your existing setup with:

grep oinstall /etc/groupgrep dba /etc/groupgrep nobody /etc/groupid oracleid 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 oinstalladdgroup --system dbauseradd -r -g oinstall -G dba -m -s /bin/bash -d /var/lib/oracle oraclepasswd oracle

Configure kernel parameters

Check your existing setup with:

/sbin/sysctl -a | grep sem/sbin/sysctl -a | grep shm/sbin/sysctl -a | grep file-max/sbin/sysctl -a | grep ip_local_port_range/sbin/sysctl -a | grep rmem_default/sbin/sysctl -a | grep rmem_max/sbin/sysctl -a | grep wmem_default/sbin/sysctl -a | grep wmem_max

Create /etc/sysctl.d/99-oracle.conf and add the following lines:

fs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmall = 2097152kernel.shmmax = 536870912kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048586

Run the following command to reload these kernel parameters:

service procps start

Shell limits for oracle user

Create /etc/security/limits.d/oracle.conf as below:

oracle  soft    nproc   2047oracle  hard    nproc   16384oracle  soft    nofile  1024oracle  hard    nofile  65536oracle  soft    stack   10240

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

session    required   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 /u02mkdir -p /u01/app/oraclemkdir -p /u02/oradatachown -R oracle:oinstall /u01 /u02chmod -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 = "/bin/ksh" ]; then  ulimit -p 16384  ulimit -n 65536else  ulimit -u 16384 -n 65536fiumask 022export ORACLE_HOSTNAME=localhost.localdomainexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1export ORACLE_SID=AL32UTF8export NLS_LANG=.AL32UTF8export ORACLE_UNQNAME=AL32UTF8unset TNS_ADMINif [ -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 /usr/lib64ln -s /etc /etc/rc.dln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib64/ln -s /usr/bin/awk /bin/awkln -s /usr/bin/basename /bin/basenameln -s /usr/bin/rpm /bin/rpmln -s /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64/ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib64/ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /lib64/ln -s /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/oraclecp linux.x64_11gR2_database_2of2.zip /var/lib/oraclecd /var/lib/oracleunzip -q linux.x64_11gR2_database_1of2.zipunzip -q linux.x64_11gR2_database_2of2.zipchown -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_1sed -i 's/^\(\s*\$(MK_EMAGENT_NMECTL)\)\s*$/\1 -lnnz11/g' $ORACLE_HOME/sysman/lib/ins_emagent.mksed -i 's/^\(\$LD \$LD_RUNTIME\) \(\$LD_OPT\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/bin/genorasdkshsed -i 's/^\(\s*\)\(\$(OCRLIBS_DEFAULT)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/srvm/lib/ins_srvm.mksed -i 's/^\(TNSLSNR_LINKLINE.*\$(TNSLSNR_OFILES)\) \(\$(LINKTTLIBS)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/network/lib/env_network.mksed -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)" fromhttps://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 INFOORA_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"ORA_OWNR="oracle"# if the executables do not exist -- display errorif [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]then        echo "Oracle startup: cannot start"        exit 1fi# depending on parameter -- startup, shutdown, restart# of the instance and listener or usage displaycase "$1" in        start)                # Oracle listener and instance startup                echo -n "Starting Oracle: "                su - $ORA_OWNR -c "$ORA_HOME/bin/dbstart $ORA_HOME"                su - $ORA_OWNR -c "$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 1esacexit 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_1sed -i 's/^#!\/bin\/sh -f\s*/#!\/bin\/bash -f/g' $ORACLE_HOME/bin/emctl

原创粉丝点击