Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mitsakosgr/943fd60a75d3d55566b65f2ffd74b3d5 to your computer and use it in GitHub Desktop.
Save mitsakosgr/943fd60a75d3d55566b65f2ffd74b3d5 to your computer and use it in GitHub Desktop.

Oracle 11G + GnuCobol installation for Oracle Linux 7

Oracle Database

Add required Groups

groupadd oinstall
groupadd dba
groupadd oper

Add user Oracle

useradd -g oinstall -G dba,oper oracle

Change password for user

passwd oracle

Add kernel parameters

# /etc/sysctl.conf
kernel.shmmni = 4096
kernel.shmmax = 4398046511104
kernel.shmall = 1073741824
kernel.sem = 250 32000 100 128

fs.aio-max-nr = 1048576
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 = 1048586

Apply kernel parameters

sysctl -p

Set shell limits for user oracle

# /etc/security/limits.conf
oracle   soft   nproc    131072
oracle   hard   nproc    131072
oracle   soft   nofile   131072
oracle   hard   nofile   131072
oracle   soft   core     unlimited
oracle   hard   core     unlimited
oracle   soft   memlock  50000000
oracle   hard   memlock  50000000

Set hostname and hosts accordingly

# /etc/hostname
orcl11g.localdomain
# /etc/hosts
127.0.0.1 orcl11g orcl11g.localdomain localhost localhost.localdomain

Add bash variables for user

Add to .bash_profile of user or add file /etc/profile.d/oracle.sh

# Oracle Settings
export TMP=/tmp

export ORACLE_ROOT=/ora01
export ORACLE_HOSTNAME=orcl11g
export ORACLE_UNQNAME=ORCL
export ORACLE_BASE=$ORACLE_ROOT/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=ORCL

PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib;
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;

umask 022

Install required packages

yum install -y \
binutils \
elfutils-libelf \
elfutils-libelf-devel \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
ksh \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
sysstat \
unixODBC \
unixODBC-devel \
compat-libstdc++-33

Create directory structure

# source variables
source /etc/profile.d/oracle.sh

# create directories
mkdir -p $ORACLE_HOME

# change owner to oracle
chown -R oracle:oinstall $ORACLE_ROOT

Disable secure linux

# /etc/selinux/config
SELINUX=permissive

Disable in memory tmp

systemctl mask tmp.mount

Set iptables rules for SSH only

Disable firewalld and install and enable iptable-services

systemct  stop firewalld
systemct  disable firewalld
yum install iptables-services
iptables -P INPUT ACCEPT
iptables -F
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -L -v

service iptables save

Install Database

Graphically login

If GUI is not available install it with

yum groupinstall "Server with GUI" -y

activate it

systemctl set-default graphical.target

and reboot.

To return to shell only

systemctl set-target multi-user.target

Sometimes the popup windows do not show up. Installing XFCE fixes the problem

wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh epel-release-latest-7*.rpm
yum groupinstall -y Xfce

Logout and relogin selecting XFCE.

Unzip and run installer

unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
cd database
./runInstaller

Run installer using custom settings.

During the installation an error about ctx_ins.mk will pop. Edit file $ORACLE_HOME/ctx/lib/ins_ctx.mk and replace

ctxhx: $(CTXHXOBJ)
  $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK)

with

ctxhx: $(CTXHXOBJ)
  -static $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK) /usr/lib/gcc/x86_64-redhat-linux/4.8.2/libstdc++.a

Then edit $ORACLE_HOME/sysman/lib/ins_emagent.mk and replace

$(MK_EMAGENT_NMECTL)

with

$(MK_EMAGENT_NMECTL) -lnnz11

Press retry to continue the installation process.

Autostart

After finishing the installation process to make database autostart change N to Y to oratab

# /etc/oratab
ORCL:/ora01/app/oracle/product/11.2.0/db_1:Y

Add dbora script in /etc/init.d/dbora

#! /bin/sh -x
#
# chkconfig: 2345 80 05
# description: start and stop Oracle Database Enterprise Edition on Oracle Linux 7
#

# In /etc/oratab, change the autostart field from N to Y for any
# databases that you want autostarted.
#
# Create this file as /etc/init.d/dbora and execute:
#  chmod 750 /etc/init.d/dbora
#  chkconfig --add dbora
#  chkconfig dbora on

# Note: Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
ORACLE_HOME=/ora01/app/oracle/product/11.2.0/db_1

#
# Note: Change the value of ORACLE to the login name of the oracle owner
ORACLE=oracle

PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH

case $1 in
'start')
        echo -n $"Starting Oracle: "
        su $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
        ;;
'stop')
        echo -n $"Shutting down Oracle: "
        su $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" &
        ;;
'restart')
        echo -n $"Shutting down Oracle: "
        su $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" &
        sleep 5
        echo -n $"Starting Oracle: "
        su $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
        ;;
*)
        echo "usage: $0 {start|stop|restart}"
        exit
        ;;
esac

exit

Enable service

chmod 750 /etc/init.d/dbora
systemctl enable dbora

Cobol

Oracle Cobol Precompiler

Unzip oracle client and run installer

unzip linux.x64_11gR2_client.zip
cd client
./runInstaller

Install Administrator package

Unzip examples and run installer

unzip linux.x64_11gR2_examples.zip
cd client
./runInstaller

GnuCobol

Install prerequisites

yum install libdb-devel gmp-devel json-glib-devel libxml2-devel ncurses

Download sources

Download source code from https://sourceforge.net/projects/open-cobol/ and untar archive

tar xf gnucobol-3.1-dev.tar.xz
cd gnucobol-3.1-dev

Run configure to create Makefile

./configure

Support Oracle libs

Edit Makefile and replace

COB_LIBS = -L${exec_prefix}/lib -lcob -lm

with

COB_LIBS = -L${exec_prefix}/lib -lcob -lm -L${ORACLE_HOME}/lib ${ORACLE_HOME}/precomp/lib/cobsqlintf.o -lclntsh

Install

Run make and make install

make
make install

Add usr local library to $LD_LIBRARY_PATH variable

/usr/local/lib

Kudos

Thanks to

http://dbaora.com/install-oracle-11gr2-on-oracle-linux-7-oel7/

and

https://forums.centos.org/viewtopic.php?t=65308

for fixes on oracle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment