Download oracle11rgr2 database from website :- oracle
database for linux
I assume that you have installed oracle or Centos 6 linux and on that you are installing
oracle database. ( Be noted oracle 11g R2 doesn't install on Centos 7 and above version )
Create following groups and users for oracle :-
# groupadd dba
# groupadd oinstall
# groupadd oper
# groupadd asmadmin
# useradd -g ointall -G dba,oper,asmadmin oracle
# passwd oracle
now you have to add following entries in files : (edit these files as root
user)
file 1 : /etc/security/limits.conf
Entry will be :-
#added for oracle 11gR2
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
file 2 : /etc/sysctl.conf
Entry will be :-
#added for Oracle 11gR2
kernel.shmmin = 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 : -
# /sbin/sysctl -p
file 3 : /etc/pam.d/login
Entry will be :-
# added for oracle 11gR2
session required pam_limits.so
file 4 : .bash_profile ( profile of user oracle )
Entry will be :-
TMPDIR=/tmp; export TMPDIR
ORACLE_HOSTNAME=`hostname`; export ORACLE_HOSTNAME
ORACLE_SID=ora11gr2; export ORACLE_SID
ORACLE_UNQNAME=ora11gr2; export ORACLE_UNQNAME
ORACLE_BASE=/opt/oracle/app/oracle; export ORACLE_BASE
ORACLE_TERM=xterm; export ORACLE_TERM
ORACLE_HOME= $ORACLE_BASE /product/11.2.0/dbhome_1; export ORACLE_HOME
PATH=/usr/bin:$PATH:$ORACLE_HOME/bin; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if after restarting of server machine i.e. Centos 6 linux server PC , and does not starts or crashes at booting OS, then go to emergency mode and open file "/home/oracle/.bash_profile" in vim and remove special character "^M" from all lines and save and exit and restart PC.
Now it will be started.
file 5 : /etc/hosts
Entry will be :-
<ip-address> <hostname> <fully qualified domain name of
host>
e.g mine is :
192.168.10.254 oel11gr2 oel11gr2.oraclehomenet.com
Verify your network settings :-
[root@centos7 ~]# ping -c 1 centos7
PING centos7 (127.0.0.1) 56(84) bytes of data.
64 bytes from centos7 (127.0.0.1): icmp_seq=1 ttl=64 time=0.040 ms
--- centos7 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.040/0.040/0.040/0.000 ms
Now install or update following packages : (from your oracle linux ISO, all
packages will be there)
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
Create following paths :-
# mkdir -p /opt/oracle/app/oracle/product/11.2.0/dbhome_1
# chown oracle:oinstall -R /opt/oracle/
# chmod -R 755 /opt/oracle/
Disable secure linux by editing the
/etc/selinux/config
SELINUX=permissive
file making sure the SELINUX flag is set as follows. It requires REBOOT to be effective !!!
Now begin installation of oracle 11g R2( login as user : oracle
then start installation ) :-
In path of oracle uncompressed directory ( mine is : /opt/software/database and
be sure that there should not be any space in path of oracle setup directory
database )
$ ./runInstaller ( press enter )
01 configure security updates :-
04 grid options :- 05 install type :- 06 product language :- 07 database edition :- 08 installation location :-
09 create inventory :-
10 general purpose :-
16 leave as it is :-
17 database storage :- 18 no automated backup :-
19 sys passwords :-
then click on next, this will check prerequisites and then installation will begin finally :-
21 installation :-
22 dbca :-
Now Oracle 11g R2 is installed in your oracle linux 6 or centos 6 linux.
To set "gedit " or "vim" as default editor, which comes out via command "ed path_to_sqlfile"
set in a file of location "$ORACLE_HOME/sqlplus/admin/glogin.sql" :-
"define _editor=gedit" or "define _editor=/usr/bin/vim" ,of course without quotes.
Now fire command in sqlplus :-
SQL> ed /opt/a <-| ( i.e. press enter )
type in file, save and exit. Then run a.sql ( by default extension changes by oracle)
SQL> @/opt/a <-|
result......
Thats it.
e.g. :-
SQL> ed /opt/as
SQL> SQL>
SQL> @as
SP2-0310: unable to open file "as.sql"
SQL> @/opt/as
select * from emp
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL>
Now for installation of oracle instant client, see mine older post. "how to install oracle instant client in centos 7 VM"
--------------------------------------------------------------------------------------------------
Now its time to set auto start of Oracle database after restart of PC or Server.
Installing Oracle Database 11g R2 on a Linux Server does not provide the database the possibility to preform an automatic startup/shutdown when the system is starts or shutdown, we need to do it manually!
so here is a few steps to make it happen automatically.
The automatic startup and shutdown of the Oracle database can be achieved with the files dbstart and dbshut both provided by Oracle. These files rely on the existence of the file /etc/oratab to work.
The format of the /etc/oratab file is as follows:
SID:ORACLE_HOME:AUTO
or in my example:
ORCL:/opt/oracle/app/oracle/product/11.2.0/dbhome_1:Y
To start and stop the database when the machine comes up and goes down by modifying the startup routines for the Linux machine. This is quite easy, although I should point out here that this may change depending on which flavor of Linux (slackware, debian, redhat, etc). I will show examples which work for Oracle Linux 5.x. To modify these for your own flavor of Linux, please see your Linux documentation sets.
Note: /etc/init.d is the official location for placing start up scripts and most, but not all distros follow this convention. /etc/rc.d/init.d is where Red Hat (which Oracle Linux is based on) places startup scripts, but in order to comply with modern convention, they make /etc/init.d a symlink to /etc/rc.d/init.d.
Firstly, we need to create the script which will run dbshut and dbstart in the /etc/rc.d/init.d directory. Create the following file as /etc/init.d/oracle:
Note1: The parts in red are optional where if you like to have Oracle Enterprise Manager starting/shutting down with the system.
Note2: If you copy and paste the script you may/will get errors because of the double quotation and the (-) chars, please read Mike’s comment, here is the script with the correct chars.
it’s important to remember to make the script executable by simply run the command:
$ chmod +x /etc/init.d/oracle
this file's coding is given below, just copy and paste code in file "oracle".
It is worth checking that this file actually correctly stops and starts the databases for your system. Check the log file, /var/log/oracle for error messages.
Once this script is working we need to create start and kill symbolic links in the appropriate runlevel directories /etc/rc.d/rcX.d.
The following commands will ensure that the databases will come up in runlevels 2,3,4 and 5:
$ ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc2.d/S99oracle
$ ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc3.d/S99oracle
$ ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc4.d/S99oracle
$ ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc5.d/S99oracle
To stop the databases on reboot or restart we need the following links:
$ ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc0.d/K01oracle # Halting
$ ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc6.d/K01oracle # Rebooting
Oracle autostart shell script file I named : "oracle". do not append ".sh" extension, and is as follows copy and paste these code in to text file named "oracle" and set it as executable permission.
File is :- "oracle" :-
------------------------------------------------------------------------------------------------------------------
#!/bin/sh
#
# /etc/rc.d/init.d/oracle
# Description: Starts and stops the Oracle database, listeners and Enterprise Manager
# See how we were called.
case "$1" in
start)
echo "Starting Oracle"
echo "—————————————————-" >> /var/log/oracle
date +"! %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
echo "—————————————————-" >> /var/log/oracle
echo -n "Starting Oracle Listeners: "
su - oracle -c "lsnrctl start" >> /var/log/oracle
echo "Done."
echo -n "Starting Oracle Databases: "
su - oracle -c "dbstart $ORACLE_HOME" >> /var/log/oracle
echo "Done."
echo -n "Starting Oracle Enterprise Manager: "
su - oracle -c "emctl start dbconsole" >> /var/log/oracle
echo "Done."
echo ""
echo "—————————————————-" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "—————————————————-" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
stop)
echo "Shutting Down Oracle"
echo "—————————————————-" >> /var/log/oracle
date +"! %T %a %D : Shutting Down Oracle Databases as part of system down." >> /var/log/oracle
echo "—————————————————-" >> /var/log/oracle
echo -n "Shutting Down Oracle Enterprise Manager: "
su - oracle -c "emctl stop dbconsole" >> /var/log/oracle
echo "Done."
echo -n "Shutting Down Oracle Listeners: "
su - oracle -c "lsnrctl stop" >> /var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle
echo -n "Shutting Down Oracle Databases: "
su - oracle -c "dbshut $ORACLE_HOME">> /var/log/oracle
echo "Done."
echo ""
echo "—————————————————-" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "—————————————————-" >> /var/log/oracle
;;
restart)
echo "Restarting Oracle"
echo "—————————————————-" >> /var/log/oracle
date +"! %T %a %D : Restarting Oracle Databases as part of system up." >> /var/log/oracle
echo "—————————————————-" >> /var/log/oracle
echo -n "Restarting Oracle Listeners: "
su - oracle -c "lsnrctl stop" >> /var/log/oracle
su - oracle -c "lsnrctl start" >> /var/log/oracle
echo "Done."
echo -n "Restarting Oracle Databases: "
su - oracle -c "dbshut $ORACLE_HOME">> /var/log/oracle
su - oracle -c "dbstart $ORACLE_HOME">> /var/log/oracle
echo "Done."
echo -n "Restarting Oracle Enterprise Manager: "
su - oracle -c "emctl stop dbconsole" >> /var/log/oracle
su - oracle -c "emctl start dbconsole" >> /var/log/oracle
echo "Done."
echo ""
echo "—————————————————-" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "—————————————————-" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
status)
if [ -f /var/lock/subsys/oracle ] ; then
echo " Oracle Enterprise Manager running"
else
echo " Oracle Enterprise Manager is not running"
fi
;;
*)
echo "Usage: oracle {start|stop|restart|status}"
exit 1
esac
------------------------------------------------------------------------------------------------------------------
Now to restart oracle database server fire this command as root user :-
# service oracle restart
to access enterprise manager open url as follows :-
https://oel11gr2.oraclehomenet.com:1158/em/
where "oel11gr2.oraclehomenet.com" is oracle database server FQDN( fully qualified domain name ).