Selasa, 15 September 2020

ORACLE-ubuntu 14.04 OK

 


INSTALL ORACLE 11GR2 EXPRESS EDITION ON UBUNTU 14.04 (64-BIT)

Since I want to give as many as possible examples in my blog I needed to install a Oracle database on my Ubuntu 14.04 operating system first. This seems to be a very good starting point for one of my first posts.

Although Linux users are used to very handy install processes by just typing sudo apt-get … commands the installation of an Oracle database is not as simple as that. The reason for this is that the Oracle database as an proprietary product is not provided in the public software repositories which the apt-get commands query.

Only for Testing and Developing!
Please, bear in mind that the described installation is intended for use in testing respectively developing stages. Itˋs not for production environments! Even the express edition is a limited version!

Prerequisites

  • you need to be a sudo
  • ubuntu libraries/packages need to be in place alienlibaio1unixodbc

Installation

Before we can start with installation of the Oracle database, we need to ensure that a couple of additional Linux packages are installed. Prepare your system by installing the following package:

1
sudo apt-get install alien libaio1 unixodbc

Next, you need to download the Linux x64 version of the Oracle Database 11g R2 Express Edition (link)

Unzipping

Navigate to your download folder and unzip the downloaded Oracle files. In my case this can be done by executing the following commands in your terminal.

1
cd ~/Downloads

and

1
unzip oracle-xe-*.x86_64.rpm.zip

A new directory Disk1 is added to the Download folder. You can jump into this folder by typing:

1
cd Disk1

Convert the *.rpm Binary

Since Oracle does not support officially Ubuntu as a target platform the installation scripts are not compatible with the operating system (core Debian). But the good thing is, there are commands we can use to make from the rpm package a dep package which fits our operating system’s requirements.

Alien is such a tool which can be used to convert a package format into another. The command generates from the rpm package a dep one:

1
sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm

Depending on your system’s performance the conversation can take a while. After several minutes (please, do not interrupt the process) you will find the oracle-xe-11.2.0-1.0.x86_64.dep package in the Disk1 folder.

You might think that you are able to install the Oracle databases now, but you would get problems by just executing the *.dep installation routine. Why? Because a common Red Hat package, the package format Oracle provides, demands the /sbin/chkconfig file which is not required by Ubuntu.

Ubuntu does not use /sbin/chkconfig for installation
In order to install a converted *.dep from a *.rpm package you must probably adjust or create the /sbin/chkconfig file.

Ubuntu does not use /sbin/chkconfig for installation.

In order to install a converted *.dep from a *.rpm package you must probably adjust or create the /sbin/chkconfig file.

We create and edit the chkconfig with the following commands:

1
2
3
sudo touch /sbin/chkconfig
# .. you may chose your favorite editor (vi, leafpad, ...)
sudo gedit /sbin/chkconfig

Copy and paste the following lines into the editor save and close:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
# Oracle 11gR2 XE installer chkconfig hack for Ubuntu
file=/etc/init.d/oracle-xe
if [[ ! `tail -n1 $file | grep INIT` ]]; then
echo >> $file
echo '### BEGIN INIT INFO' >> $file
echo '# Provides: OracleXE' >> $file
echo '# Required-Start: $remote_fs $syslog' >> $file
echo '# Required-Stop: $remote_fs $syslog' >> $file
echo '# Default-Start: 2 3 4 5' >> $file
echo '# Default-Stop: 0 1 6' >> $file
echo '# Short-Description: Oracle 11g Express Edition' >> $file
echo '### END INIT INFO' >> $file
fi
update-rc.d oracle-xe defaults 80 01
#EOF

This “Ubuntu hack” defines how the Oracle database can be started or stopped. It declares how the service can be used and which parameters it requires. Now we have to give the file some execution privileges.

1
sudo chmod 755 /sbin/chkconfig

You can test whether you have set the privileges correctly by listing the altered file (notice the x for usergroup and others).

1
2
ll /sbin/ch*
-rwxr-xr-x 1 root root 553 Jul 30 12:38 /sbin/chkconfig*

System Preconfigurations

There are several minor adjustments required before the installation/configuration of the Oracle database.

Adjust Kernel Parameters

The Oracle database requires a set of kernel parameters. Especially the maximum use of RAM, etc. These parameters will be configured in the 60-oracle.conf file. These files will be loaded during service startup. In this case when the Oracle database service starts.

1
2
sudo touch /etc/sysctl.d/60-oracle.conf
sudo gedit /etc/sysctl.d/60-oracle.conf

Add the following lines:

1
2
3
4
5
# Oracle 11g XE kernel parameters 
fs.file-max=6815744 
net.ipv4.ip_local_port_range=9000 65000 
kernel.sem=250 32000 100 128
kernel.shmmax=536870912

Save and close the editor. Run the following command to apply the parameters:

1
sudo service procps start

Adjust Path to Pattern Scanning and Text Processing Language (awk)

Although the awk command is installed in each default Ubuntu installation the configuration util of the Oracle database does not search in the correct directories for it. This will lead to some warnings/errors during the configure phase. It is not a big problem since we have only to point to the already installed binary by just creating a link.

1
sudo ln -s /usr/bin/awk /bin/awk

That’s it!

You might ask yourself why you will be faced this problem? Well, it is far easier than you think, Red Hat keeps the awk command under /bin and Ubuntu puts it under /usr/bin.

Adjustment in Mount Point

The Oracle database requires a separate mounting point which we can create with the following commands:

1
2
3
sudo rm -rf /dev/shm
sudo mkdir /dev/shm
sudo mount -t tmpfs shmfs -o size=2048m /dev/shm

ORA-00845: MEMORY_TARGET
You will run into this issue when you do not configure a separate mount point for the Oracle database prior configuration phase.

Since the changes are only temporary for the current session they will be lost after system reboot. In order to make them permanent you can create a startup script for a specific run level. Lets add the prior steps to a file, make them executable and start them automatically while our system boots. This will ensure that the required mount point is accessible whenever we start the database manually.

We create first the file and open it with our favorite editor

1
2
sudo touch /etc/rc2.d/S10oracle-mount
sudo gedit /etc/rc2.d/S10oracle-mount

Add the following lines:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /bin/sh
### BEGIN INIT INFO
# Provides:          Creates Oracle mount point
# Required-Start:   
# Required-Stop:    
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Used for Oracle installation
# Description:       Used for Oracle installation
### END INIT INFO
 
# Aktionen
case "$1" in
    start)
        mkdir /var/lock/subsys 2>/dev/null
        touch /var/lock/subsys/listener
        rm /dev/shm 2>/dev/null
        mkdir /dev/shm 2>/dev/null
        mount -t tmpfs shmfs -o size=2048m /dev/shm
        ;;
    stop)
        ;;
    restart)
        ;;
esac
exit 0

Save the file and make it executable:

1
sudo chmod 755 /etc/rc2.d/S10oracle-mount

Additional Adjustments

Please, create the following directories/files

1
2
sudo mkdir /var/lock/subsys
sudo touch /var/lock/subsys/listener

Package Installation and init

Now we are ready to start the installation of the generated oracle-xe_11.2.0-2_amd64.deb with the following commands:

1
2
cd ~/Downloads/Disk1
sudo dpkg -i oracle-xe_11.2.0-2_amd64.deb

The system will show you the following output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Selecting previously unselected package oracle-xe.
(Reading database ... 373958 files and directories currently installed.)
Preparing to unpack oracle-xe_11.2.0-2_amd64.deb ...
Unpacking oracle-xe (11.2.0-2) ...
Setting up oracle-xe (11.2.0-2) ...
Executing post-install steps...
 Adding system startup for /etc/init.d/oracle-xe ...
   /etc/rc0.d/K01oracle-xe -> ../init.d/oracle-xe
   /etc/rc1.d/K01oracle-xe -> ../init.d/oracle-xe
   /etc/rc6.d/K01oracle-xe -> ../init.d/oracle-xe
   /etc/rc2.d/S80oracle-xe -> ../init.d/oracle-xe
   /etc/rc3.d/S80oracle-xe -> ../init.d/oracle-xe
   /etc/rc4.d/S80oracle-xe -> ../init.d/oracle-xe
   /etc/rc5.d/S80oracle-xe -> ../init.d/oracle-xe
You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
 
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...
Processing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for mime-support (3.54ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...

The installation routine prompts you to run the following command to initiate/configure the database:

1
sudo /etc/init.d/oracle-xe configure

You can confirm all default port settings. In so far as the database is only for demonstration purposes I do not want to start it automatically on system startup. I answered the last question with N.

System Variables

Everyone who worked with Oracle products knows that Oracle uses a set of system/environment variables in order to configure or reference their software products. It is recommended to set the system variables for the user session. Since I do not want to configure this variables for all users who may work with my machine separately I want to define them on system-level and make them so accessible for everyone [bib]UbuntuHelpEnvornmentVariables[/bib].

We edit the sudo gedit /etc/environment and replace the content by the following lines:

Rstrictions in /etc/environment
Please, consider that you are not able to use any variable expansion in the /etc/environment.

Although, many developers uses the /etc/bash.bashrc I decided not to use this but the more appropriated /etc/environment. The reason for this decision was that variables defined in the bash.bashrc are only visible to programs started by shell. This seems to be a restriction I do not want to accept.

1
2
3
4
5
6
7
8
9
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/ local/games"
 
# .. oracle binaries added to the PATH!
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/u01/app/oracle/product/11.2.0/xe/bin"
 
ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
ORACLE_SID=XE
ORACLE_BASE=/u01/app/oracle
LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/xe/lib

Save the adjusted /etc/environment and close gedit.

Presence of System Variables
The /etc/environment will be executed automatically by the system during the start-up of the desktop. This means that even we have configured the environment variables they are not present, yet!

To solve this issue we must reboot to load our environment definitions. You can check if the system variables are present after reboot:

printenv | grep ORAC*
ORACLE_SID=XE
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe

Now, we should have everything in place. The installation is completed!

Testing the Database

Lets see if we can start and connect to the database. We can start the database with:

1
2
3
sudo service oracle-xe start
Starting Oracle Net Listener.
Starting Oracle Database 11g Express Edition instance.

Now lets try to login with the SYS and our entered password during configuration phase.

1
2
3
4
5
6
7
8
9
10
11
adam@adam-desktop:~$ sqlplus
 
SQL*Plus: Release 11.2.0.2.0 Production on Wed Jul 30 17:30:30 2014
 
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
 
Enter user-name: system
Enter password:
 
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

Now we can try to query a standard table of the database:

1
2
3
4
5
6
7
8
9
SQL> select * from v$version;
 
BANNER
-----------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0    Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

When you get an output you have got a working Oracle Express database on your system. Congratulation!

------------------------------------------

Install and Configure Oracle-11g on Ubuntu-14.10

Intro :

Well as luck would have it, we were having our Database labs in ORACLE 11g as part of the coursework. And I must admit, I still have my love for mysql.

I installed it on my system(after a lot of trials!) this way.

Next part of this article

Pre-requisites:

JAVA should be installed and the environment variable for it should be set. Check it by doing

tasdik@Acer:~$ java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.10.2)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
tasdik@Acer:~$ echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64
tasdik@Acer:~$ 

If not you can set it by placing the installed jvm to /etc/environment

Mine looks like this

1
2
3
4
5
6
7
8
tasdik@Acer:~$ cat /etc/environment 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
http_proxy="http://172.16.0.16:8080/"
https_proxy="https://172.16.0.16:8080/"
ftp_proxy="ftp://172.16.0.16:8080/"
socks_proxy="socks://172.16.0.16:8080/"
JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
tasdik@Acer:~$ 

Installing Oracle 11g R2 Express Edition

A couple of extra things are needed

tasdik@Acer:~$ sudo apt-get install alien libaio1 unixodbc

Download Oracle 11g, you need to make an account for that(Yeah, I know!)

Link : http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html

Place annd Unzip the zip file to the Directory of your choice. I did mine to ‘Documents’

tasdik@Acer:~$ cd Documents/
tasdik@Acer:~/Documents$ unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip

## A new directory was added

tasdik@Acer:~$ cd Documents/Disk1/

Now we need to convert the rpm (A red hat package to .deb) package

tasdik@Acer:~/Documents/Disk1$ sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm

This will take a while, so open another terminal window

tasdik@Acer:~/Documents/Disk1$ sudo nano /sbin/chkconfig

And then add the following to it

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
# Oracle 11gR2 XE installer chkconfig hack for Ubuntu
file=/etc/init.d/oracle-xe
if [[ ! `tail -n1 $file | grep INIT` ]]; then
echo >> $file
echo '### BEGIN INIT INFO' >> $file
echo '# Provides: OracleXE' >> $file
echo '# Required-Start: $remote_fs $syslog' >> $file
echo '# Required-Stop: $remote_fs $syslog' >> $file
echo '# Default-Start: 2 3 4 5' >> $file
echo '# Default-Stop: 0 1 6' >> $file
echo '# Short-Description: Oracle 11g Express Edition' >> $file
echo '### END INIT INFO' >> $file
fi
update-rc.d oracle-xe defaults 80 01
#EOF

Save it and give the required execution privileges

tasdik@Acer:~$ sudo chmod 755 /sbin/chkconfig

After this, we have to create the file /etc/sysctl.d/60-oracle.conf to set the additional kernel parameters. Open the file by executing the following statement.

tasdik@Acer:~/Documents/Disk1$ sudo nano /etc/sysctl.d/60-oracle.conf

Copy and paste the following into the file. Kernel.shmmax is the maximum possible value of physical RAM in bytes. 536870912 / 1024 /1024 = 512 MB.

1
2
3
4
5
# Oracle 11g XE kernel parameters
fs.file-max=6815744
net.ipv4.ip_local_port_range=9000 65000
kernel.sem=250 32000 100 128
kernel.shmmax=536870912

Load the kernel parameters:

tasdik@Acer:~/Documents/Disk1$ sudo service procps start

The changes may be verified again by executing:

tasdik@Acer:~/Documents/Disk1$ sudo sysctl -q fs.file-max
fs.file-max = 6815744
tasdik@Acer:~/Documents/Disk1$ 

After this, execute the following statements to make some more required changes:

tasdik@Acer:~/Documents/Disk1$ sudo ln -s /usr/bin/awk /bin/awk
tasdik@Acer:~/Documents/Disk1$ mkdir /var/lock/subsys
tasdik@Acer:~/Documents/Disk1$ touch /var/lock/subsys/listener

Install the .deb file

tasdik@Acer:~/Documents/Disk1$ sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb

After that, Execute the following to avoid getting a ORA-00845: MEMORY_TARGET error. Note: replace “size=3804m” with the size of your (virtual) machine’s RAM in MBs.

Note : Close Chrome before executing the following three lines as it crashes when doing so

To check your system RAM (allated), do a

tasdik@Acer:~$ free -tom
             total       used       free     shared    buffers     cached
Mem:          3804       3465        338        910         81       1642
Swap:         3943         30       3913
Total:        7748       3496       4252
tasdik@Acer:~$ 

My RAM is 3804 here Then do the following

tasdik@Acer:~$ sudo rm -rf /dev/shm
tasdik@Acer:~$ sudo mkdir /dev/shm
tasdik@Acer:~$ sudo mount -t tmpfs shmfs -o size=3804m /dev/shm

Create the file /etc/rc2.d/S01shm_load.

tasdik@Acer:~$ sudo nano /etc/rc2.d/S01shm_load

And then add the following

1
2
3
4
5
6
7
8
9
10
#!/bin/sh
case "$1" in
start) mkdir /var/lock/subsys 2>/dev/null
touch /var/lock/subsys/listener
rm /dev/shm 2>/dev/null
mkdir /dev/shm 2>/dev/null
mount -t tmpfs shmfs -o size=3804m /dev/shm ;;
*) echo error
exit 1 ;;
esac

Give permissions to it

tasdik@Acer:~$ sudo chmod 755 /etc/rc2.d/S01shm_load

Configuring Oracle 11g R2 Express Edition

tasdik@Acer:~$ sudo /etc/init.d/oracle-xe configure

Go on choosing the defaults. I chose, not to start Oracle on startup. So do accordingly.

Setting the environment vars

tasdik@Acer:~$ sudo gedit /etc/bash.bashrc

And add the following

1
2
3
4
5
6
7
#### for oracle 11g
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export ORACLE_BASE=/u01/app/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH

Save it and source it

tasdik@Acer:~$ source /etc/bash.bashrc
## check the environment variables
tasdik@Acer:~$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/xe
tasdik@Acer:~$ 

I recommend rebooting the system at this point of time

After a System Reboot

tasdik@Acer:~$ sudo service oracle-xe start

A file named oraclexe-gettingstarted.desktop is placed on your desktop. To make this file executable, navigate to you desktop.

tasdik@Acer:~$ cd ~/Desktop
tasdik@Acer:~/Desktop$ sudo chmod a+x oraclexe-gettingstarted.desktop

Running SQlplus

You have to Unset http_proxy and no_proxy.

To do that

tasdik@Acer:~$ unset http_proxy
tasdik@Acer:~$ unset no_proxy
tasdik@Acer:~$ sqlplus

SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 26 11:34:06 2015

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter user-name: SYSTEM
Enter password: 

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> 

There you go!

Ending notes:

Remember to do a

tasdik@Acer:~$ sudo service oracle-xe start

at startup, if you chose not to Start Oracle 11 g at system startup

Tidak ada komentar:

Posting Komentar