Oracle

From ArchWiki
Revision as of 10:12, 29 October 2016 by Saverio (talk | contribs) (I updated the english version from Netherlands version and improved the content. The reason: the english version was out of date and some information was incomplete.)
Jump to: navigation, search

zh-CN:Oracle This article is related to the installation of Oracle 12c (12.1) - 64-bit.

Note: The Arch Linux distribution is not supported by Oracle !

It is assumed that Xorg is configured and a Window manager or a Desktop environment is installed.

Preparation

Dependencies

Before installing the Oracle Database on the Arch Linux System, it must be checked for the availability of the following packages on the system. These packages must be installed first:

  • base-devel (the entire group)
  • jre8-openjdk, mksh, gdb, gawk, libelf, sysstat, libstdc++5, unzip, sudo, icu, lib32-libstdc++5, python2
  • gcc-multilib, gcc-libs-multilib, libtool

Next, it's necessary to create the following symbolic links because Oracle installer expects some software packages available on specific paths, which are different compared to the Arch standard paths:

ln -s /usr/lib /usr/lib64
ln -s /usr/bin/basename /bin/basename
rm /usr/bin/python
ln -s /usr/bin/python2 /usr/bin/python
ln -s /usr/lib64/libgcc_s.so.1 /lib64/

Oracle user

Then, create an Oracle user (e.g. the user named oracle) that is a member of the group oinstall and dba:

 groupadd oinstall
 groupadd dba
 useradd -m -g oinstall -G dba oracle

and configure the password for this user:

passwd oracle

Edit the .bashrc file for this user with a text editor (e.g. vi):

sudo oracle
vi ~/.bashrc

and add the following content, to set the Oracle environment variables, Oracle path and the default text editor:

export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/product/db
export ORACLE_INVENTORY=/oracle/inventory
export ORACLE_SID=<SID of your DB>
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export EDITOR=vi
export VISUAL=vi

If you prefer another text-editor instead of vi to edit your text files, you can modify the value of EDITOR and VISUAL environment variables above. Use the editor of your choice, setting for example these variables to nano or gedit or kate or atom or other. Make sure to give the correct value to ORACLE_SID variable. It is the SID you choose in dbca tool. If you don't know the SID right now, you must set the variable after running dbca.

Configuration

Kernel parameters

The following kernel parameters must be adjusted. Add to file /etc/sysctl.d/99-sysctl.conf the following parameters, or adjust them if already defined:

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

and activate the modified settings:

# sysctl --system

Pam Limits

Also the PAM module limits must be configured (see also: Realtime process management). Add to file /etc/security/limits.conf the following:

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

Installation

And now the easy part. Login as oracle user:

DISPLAY=:0.0; export DISPLAY; xhost +
su - oracle
DISPLAY=:0.0; export DISPLAY

Download the Oracle software from Oracle site towards the oracle user folder: http://www.oracle.com/technology/software/products/database/index.html

and unzip it in /media folder:

 su -
 unzip /home/oracle/Downloads/linuxamd64_12102_database_1of2.zip -d /media
 unzip /home/oracle/Downloads/linuxamd64_12102_database_2of2.zip -d /media

then, adjust the owner and group of the extracted installation directory structure as follows:

 chown -R oracle:oinstall /media/database

if not allowed to change the ownership by the oracle user, please use the su user to modify the ownership as reported.

Target directory structure

Now create the directory structure where the Oracle software will be installed:

mkdir -p /oracle/{inventory,recovery,product/db}

Launch the Oracle installer

/media/database/runInstaller

Now, you have to answer to several questions:

Installation option
"Install database software only"
Grid Options
"Single instance database installation"
Product Languages
"English"
Database Edition
"Enterprise Edition"
Installation Location
Oracle Base: /oracle and the Software Location: /oracle/product/db
Create Inventory
Inventory Directory: /oracle/inventory and the oraInventory Group Name: oinstall
Operating System Groups
Database Administrator Group: dba and the Database Operator Group: oinstall
Prerequisite Checks
Ignore all

Possible errors

During installation you may get some error messages.

The first error in the corresponding log file can be:

Note: this error message appeared in Oracle 11gR2 x64
INFO: /usr/lib64/libstdc++.so.5: undefined reference to `memcpy@GLIBC_2.14'
collect2: error: ld returned 1 exit status

In case it appears, ignore the error message: click "Continue". Unfortunately, this error leads to the unavailability of the lexical compiler: it won't work. The lexical compiler is used to generate its own Chinese and Japanese dictionaries.

Another error message can be:

/oracle/product/db/lib/libnnz11.so: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

To fix it: open the file $ORACLE_HOME/sysman/lib/ins_emagent.mk in the text editor and go to line 190: replace $(MK_EMAGENT_NMECTL) door:

$(MK_EMAGENT_NMECTL) -lnnz11

Now click "Retry" on the installer window.

Start scripts

To automatically start the Oracle database during the boot process, it's possible to create two init scripts:

/etc/rc.d/ora.listener :

#!/bin/sh
export ORACLE_HOME="/oracle/product/db"
export ORACLE_BASE=/oracle
export ORACLE_SID=<SID of your DB>
export ORACLE_INVENTORY=/oracle/inventory
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH

case "$1" in
start)
 echo "Start Oracle Listeners"
 /bin/su oracle -c "$ORACLE_HOME/bin/lsnrctl start LISTENER"
 ;;
stop)
/bin/su oracle -c "$ORACLE_HOME/bin/lsnrctl stop LISTENER"
;;
esac

/etc/rc.d/ora.database :

#!/bin/sh
export ORACLE_HOME="/oracle/product/db"
export ORACLE_BASE=/oracle
export ORACLE_SID=<SID of your DB>
export ORACLE_INVENTORY=/oracle/inventory
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH

case "$1" in
start)
 echo "Start Oracle Database"
 /bin/su oracle -c "$ORACLE_HOME/bin/dbstart"
 ;;
stop)
 /bin/su oracle -c "$ORACLE_HOME/bin/dbshut"
 ;;
esac

Make both scripts executable:

chmod +x /etc/rc.d/ora*

You can now call the two scripts from /etc/rc.conf

DAEMONS=( ... ora.listener ora.database ...)

an alternative way is to manually start the database by logging on the inactive database as sysdba, using sqlplus :

$ su - oracle
$ sqlplus / as sysdba

and then start the database with:

SQL> startup

To stop the database:

SQL> shutdown immediate

To start or stop the database instance listener, it's possible to use the command lsnrctl:

To start the listener:

$ su - oracle
$ lsnrctl start

To stop the listener:

$ su - oracle
$ lsnrctl stop

To check for the status of the listener:

$ su - oracle
$ lsnrctl status

Completion

The Oracle db graphical installer can ask for the execution of two scripts as root:

su
/oracle/inventory/orainstRoot.sh
/oracle/product/db/root.sh

The last script asks for the full pathname. Give this:

/usr/local/bin

Listener

As last step, the instance listener must be created. This is done by starting (as oracle user) the following graphical tool

netca

Answer to the configuration wizards as follows:

Choose the configuration you would like to do
Listener configuration
Select what you want to do
Add
Listener name
LISTENER
Selected Protocols
TCP
Which TCP/IP port number should the listener use ?
standard port number of 1521
Would you like to configure another listener
No

Then click on "Finish"

Moreover, when you connect to an Oracle database running on the same machine where the connection request is done, you don't need an instance listener. The listener is needed when you want to access the database from "outside", or when you make a connection through the JDBC driver, for example in a Java application.

Post Installation

A database can now be created by the user oracle who starts the dbca graphical tool:

dbca

After the db creation, edit the file /etc/oratab and change this row from:

<your sid>:<oracle home>:N

to :

<your sid>:<oracle home>:Y

Listener IPv6 problem

As default, the listener is configured with the localhost.localdomain to listen. It seems that Arch default IPv6 deployment is different, so the database instance can not register with the listener. To solve this problem, check for the listener status, to verify if it's listening the events from/to the database instance:

# lsnrctl status

If you see:

The listener supports no services

Go to the path $ORACLE_HOME/network/admin and edit the file listener.ora. Change the following line:

      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))

to:

      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))

This forces the listener to use your external IP address and therefore IPv4.

Now, if you check again for the listener status:

# lsnrctl status

it's possible to see that database is registered and the listener is listening to it:

Service "<SID name>" has 1 instance(s).
Instance "<SID name>", status READY, has 1 handler(s) for this service...