Advertisements

Archive

Archive for the ‘Software’ Category

How to Solve Connection Error on Oracle Listener Control

September 20, 2017 1 comment

This is an error that occurs from using Oracle’s lsrnctl start command to enable the Oracle database connection listener. Upon using that command, here’s the output of the error:

lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 30-APR-2010 10:42:24
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/wrath/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PACT)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12547: TNS:lost contact
 TNS-12560: TNS:protocol adapter error
  TNS-00517: Lost contact
   Linux Error: 104: Connection reset by peer
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PACT)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
This is probably caused by an incorrect configuration in the /etc/hosts file. So, make sure that inside this config file there is an entry for the loopback address like so:
127.0.0.1 PACT localhost
::1 PACT localhost
Note: The PACT value on the configuration file is due to the setup I use during my Oracle database installation. I use PACT as my hostname and have to put PACT as one of the entry in the /etc/hosts. But the point is, you have to have a localhost entry on the 127.0.0.1 and ::1. If done, save the file and start the lsnrctl service once again.
lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 30-APR-2010 10:55:27
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/wrath/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PACT)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                30-APR-2010 10:55:29
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/wrath/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PACT)(PORT=1521)))
The listener supports no services
The command completed successfully
Advertisements

How to Fix ORA-65093: multitenant container database not set up properly on Oracle 12c

August 11, 2017 Leave a comment

This issue often occurs in a Oracle database 12c installation on Linux. The error stated that multitenant container database not set up properly, which means we have to set the enable_pluggable_database to True. This error occurs whenever we want to mount the database but the multitenant container database was not set up properly. To fix this, connect to your Oracle 12c using the sysdba user:

sqlplus / as sysdba

Next, do a startup nomount command on the SQLPlus command line interface:

startup nomount

Change the value of the enable_pluggable_database system parameter by typing:

ALTER SYSTEM SET “enable_pluggable_database”= TRUE SCOPE = SPFILE;

COMMIT;

Now, do a shutdown command on the database and do a startup command again to show that now you can mount the database:

shutdown immediate

startup

How to Install Instant Client for Oracle Database

August 3, 2017 Leave a comment

Instant Client is an Oracle database auxiliary application that contains libraries such as OCI or JDBC to connect to a remote database server. To install Instant Client, it is available in the following link: http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Select the Instant Client product that has the same as your Oracle database version. In this tutorial, we are using Oracle database 11g so we will use instant client 11.2.0.4. After you have downloaded the instant client, unpack the zip file and put it under the directory /opt/oracle/instantclient/. After that, make a symbolic link to the libclntsh.so.11.1 file by typing:

ln -s libclntsh.so.11.1 libclntsh.so

Also, set file permission to libclintsh.so and libnnz11.so by typing:

chmod 755 libclntsh.so
chmod 755 libnnz11.so

Change to the oracle user that you use to install your Oracle by typing su – oracle. Next, set your system environment accordingly for the instant client directory:

export D_LIBRARY_PATH=/opt/oracle/instantclient/
export ORACLE_HOME=$ORACLE_HOME:/opt/oracle/instantclient/
export PATH=$PATH:/opt/oracle/instantclient/

Troubleshooting Oracle: Unable to Mount Database Due to Invalid PFILE

August 1, 2017 Leave a comment

Recently in Oracle, I encountered an issue regarding the configuration of Oracle Database. Whenever I try to execute a startup command on the database console, the Oracle database gives me the init<SID>.ora can’t be found. So, the very first I do is to check for that particular ORA file, whether it existed or not. You can find your ORA file resides in the <ORACLE_HOME>/dbs folder. Upon inspection of the folder, there is no init<SID>.ora file which is a little bit weird.

So, I decided to clone the existing init.ora file and give the file name init<SID>.ora (Note: The <SID> refers to the SID name you given during the Oracle database installation. If you are not sure what SID you have set on the installation, you can check the tnsname.ora under the directory <ORACLE_HOME>/network/admin and check the SERVICE_NAME variable). Now, check the content of your ORA file that you have cloned:

Few things that need to be verified in this file:

  • The variable db_name has to refer to the Global database name that we have set during the Oracle database installation. I encountered that the db_name is ORCL while during the installation I set it to ACI. So I have to adjust my db_name value to ACI.
  • Make sure your audit_file_dest refers to a valid location. Initially in this file, the variable goes to /ora01/app/oracle/admin/orcl/adump while the valid location is /ora01/app/oracle/admin/aci/adump. Thus, I changed the value into a valid location.
  • Make sure the db_recovery_file_dest is pointing to a valid location. This is no issue for me since it already is pointing to a valid directory.
  • Make sure the control_files variable is pointing to a present control file. The control file is identified by a .ctl extension. In my case, it resides in the directory /ora01/app/oracle/oradata/aci/control01.ctl.

If you are sure with your configuration, don’t forget to save the file. On the command line, login to the Oracle database as sysdba by typing:

sqlplus / as sysdba

Once you are in the Sqlplus console, type as follow to start your database:

STARTUP PFILE=’/ora01/app/oracle/product/11.2.0/db_1/dbs/init<SID>.ora’

If your ORA file configuration is correct, then the Oracle database should successfully mounted the database.

How to Install Oracle Database in Linux Centos

August 1, 2017 Leave a comment

This installation tutorial is made using Oracle database 11g on a Linux Centos 6 – 64 bit machine. For installation of Oracle database on a Linux Centos 7, I recommend using Oracle 12g because in my experience installing Oracle database 11g on Centos 7, there is a graphical issue where the popup dialog on the installation interface will not be shown.

This tutorial assumes the user has already have a Linux Centos installed on their local machine and also has a basic knowledge of Linux command line application. First of all, obtain a copy of Oracle database on this link: http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

Since this tutorial is using a Linux Centos 6 – 64 bit machine, we will be using Oracle 11.2.0.1.0 for Linux x86-64. Download all the files that are provided on the link (File 1 and File 2), and after you have finished the download, you will have these files:

Installation Prerequisites

Before we begin to install Oracle 11g to our Linux Centos machine, we have to do some prerequisites task. Open up a terminal application on the Linux Centos machine, and change to root user by typing the command:

su – root

Next, we need to setup a user and usergroup that will have the authority to execute and manage the Oracle database. You can actually use root user to do this but as a best practice, always use different user for different functionality. Therefore, we want to create a user named oracle which will have the privilege to execute and manage oracle database function. On the terminal as root user, do the following command:

/usr/sbin/groupadd -g 501 oinstall
/usr/sbin/groupadd -g 502 dba
/usr/sbin/groupadd -g 503 oper
/usr/sbin/useradd -u 502 -g oinstall -G dba,oper oracle

After we have successfully created the user oracle for our Oracle database system, set the password for user oracle by typing:

passwd oracle

After we have successfully create an oracle user for our oracle database installation, we need to tune the Linux kernel’s parameter. Edit the sysctl.conf file by typing vi /etc/sysctl.conf (or you can use any text editor application to your preference) and insert the following line into the file:

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

Note: Inside the existing sysctl.conf, there are already kernel.shmmax and kernel.shmall variables defined. So, make sure to comment those out so there wouldn’t be any variables duplication. After you have save the changes you made on sysctl.conf, apply the kernel parameter by executing /sbin/sysctl -p.

Next part is to set shell limits to the oracle user. The shell limits configuration is stored in the /etc/security/limits.conf directory, so open the file on a text editor application and insert the following line:

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

Now, we need to set-up a valid hostname for the Linux machine. You can change the hostname configuration inside the /etc/hosts file. Insert a valid IP of your local machine and the hostname it will have. In this installation, we don’t change the configuration and decided the hostname will be localhost.

As a side note, you can verify whether your hostname configuration is correct by doing a ping command in the Linux command line application. The next step now is to modify the .bash_profile file for user Oracle. The .bash_profile file is an automated file script that is executed whenever we login as a user, so the objective of modifying the .bash_profile file for user Oracle is to set up the necessary environment setting for oracle database to operate.  Go to oracle user home directory (/home/oracle) and modify the .bash_profile file by inserting:

# Oracle Settings
export TMP=/tmp

export ORACLE_HOSTNAME=localhost
export ORACLE_UNQNAME=aci
export ORACLE_BASE=/ora01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=aci

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

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

alias cdob=’cd $ORACLE_BASE’
alias cdoh=’cd $ORACLE_HOME’
alias tns=’cd $ORACLE_HOME/network/admin’
alias envo=’env | grep ORACLE’

umask 022

Take note on the value of ORACLE_HOSTNAME, ORACLE_UNQNAME, ORACLE_BASE, ORACLE_HOME, and ORACLE_SID on this .bash_profile file we modify.

  • ORACLE_HOSTNAME: Refers to the hostname of the machine that the oracle database is installed. If you are not sure what hostname your machine is set, you can type hostname on the command line.
  • ORACLE_UNQNAME: Refers to the unique id that will identify your oracle database installation.
  • ORACLE_BASE: The installation directory of the oracle that we will install later on.
  • ORACLE_HOME: The installation directory which we will extract the oracle installation to.
  • ORACLE_SID: The service name of the Oracle database to connect to later on.

Oracle database needs some packages to function, so do a package check on the command line by typing:

rpm -q –qf ‘%{NAME}-%{VERSION}-%{RELEASE}(%{ARCH})\n’ 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

In this tutorial case, the command line responded with:

Therefore, try to install the missing packages that the Oracle database needs. You can install packages in Linux by typing yum install <package name>. In this particular tutorial case, we install the missing packages as follows:

yum install elfutils-libelf-devel gcc gcc-c++ ksh libaio-devel libstdc++-devel unixODBC unixODBC-devel

The next step now is to make the corresponding directory based on the ORACLE_HOME and ORACLE_BASE value that we have set in the .bash_profile for oracle user. In this tutorial case, the directory that we need to create is /ora01/app/oracle/product/11.2.0/db_1. You can create directory using the command line by inputting:

mkdir -p /ora01/app/oracle/product/11.2.0/db_1

Don forget to set write and read access to all user in this folder so we can extract the oracle installation file in this directory:

chmod 777 -R /ora01

After that, unzip the oracle database installation file by typing:

unzip linux.x64_11gR2_database_1of2.zip

unzip linux.x64_11gR2_database_2of2.zip

Move the extracted files (don’t copy the database folder but go into the database folder then copy all the files inside it) to the ORACLE_HOME directory (/ora01/app/oracle/product/11.2.0/db_1). So, in the end, you will have this kind of arrangement in your ORACLE_HOME folder:

Now, set the owner and permission for this folder so only oracle and dba group can manage the folder (Not a must but consider a good practice):

chown oracle:oinstall /ora01/app
chmod 775 /ora01/app
chown oracle:oinstall /ora01/app/oracle
chmod 775 /ora01/app/oracle
chown oracle:oinstall -R /ora01/app/oracle

The next step is to disable secure Linux. The configuration can be found in etc/selinux/config. Edit the file using a text editor and edit the following variable inside the file:

SELINUX=permissive

Now that we have finished our prerequisites setup, we are ready to install Oracle database to our Linux machine.

Installing Oracle Database

First of all, you have to change to user oracle to start the Oracle database installation:

su – oracle

After that, type cdoh on the command line, this should automatically change to the ORACLE_HOME directory. To start the installation, type ./runInstaller in the command line and it will show the Oracle database graphical installation interface.

Troubleshooting: There are some cases where we type ./runInstaller, the checks will fail to check the graphic module by stating the system can’t open display. If this issue occurs, please refer to this link to apply for the fix: https://knowledgejunk.net/2017/07/27/how-to-solve-cant-open-display-error-on-installing-oracle-on-linux/

Now, uncheck the checkbox and click next to proceed. Select the Create and configure a database option and click next.

Now, in the System Class part, choose Server Class and click next.

Choose Single instance database installation option and click next.

In the Install Type section, choose Typical Install and click next.

Set your database name and your administrative password and press next.

Don’t change anything in the Create Inventory section and click next.

Check the Ignore All check box if there is a failed check item and press next.

Click Finish.

Wait until the Oracle database installation is finished.

After the installation has reached 100%, you will be prompted to execute two scripts that are displayed on the Oracle database installation. Therefore in the command line as a root user, execute both scripts provided.

How to Solve Can’t Open Display Error on Installing Oracle on Linux

July 27, 2017 1 comment

This error occurs during my attempt on installing oracle 11g on a Linux machine (I used Centos 7). When I run the runInstaller script using a non-root user (which is oracle in this case), the error displays:

No protocol specified.

Error: Can’t open display:

So, what I think is happening is that there is a GUI library that is using an X library where this library by default can only be used by a root user. To tackle that problem, here’s what you have to do:

  1. Change to a root user.

    su

  2. Add xhost authorization list so a non-root user can access the library (in this case, we want user oracle to be included in the shost authorization list).

    xhost local:oracle

  3. Change to the non-root user you have authorized in the xhost (in this case, oracle).

    su – oracle

  4. Set the DISPLAY environment value to 0.0.

    export DISPLAY=:0.0

After that, you should be able to install the Oracle application and the GUI installation interface will show.

NXT Project: Light Following Robot

February 10, 2013 Leave a comment

One of Indonesian students in Germany has been involved in the construction of a Light Following Robot. That particular guy called Bawono Langgeng who happened to be my friend. This robot is mounted with two sensors, left and right, to detect the presence of an incoming light. Once the robot has determined the position of the light, it will move towards it until it is close enough to the light. If you are wondering what he looks like, he is the person on the furthest right at the end of the clip.

Source code snippet:

#define LOWERLIGHT 15
#define MOTOR_POWER 40
#define ROTATE_SPEED 25
#define DISTANCE 20

int light_intensity_1;
int light_intensity_2;

sub check_light_sensor()
{

SetSensorType(IN_3, IN_TYPE_LIGHT_INACTIVE);
SetSensorMode(IN_3, IN_MODE_PCTFULLSCALE);
ResetSensor(IN_3);
SetSensorType(IN_4, IN_TYPE_LIGHT_INACTIVE);
SetSensorMode(IN_4, IN_MODE_PCTFULLSCALE);
ResetSensor(IN_4);

}

sub search_for_light()
{

while(true)
{

light_intensity_1 = Sensor(IN_3);
light_intensity_2 = Sensor(IN_4);
OnFwdSync(OUT_BC, ROTATE_SPEED, 100);
if ((light_intensity_1 == light_intensity_2) && (light_intensity_1 >= LOWERLIGHT))
{

PlayToneEx(200,500,0.5,FALSE);
break;

}

}

}

sub light_go_right()
{

do
{

light_intensity_1 = Sensor(IN_3);
light_intensity_2 = Sensor(IN_4);
OnFwdSync(OUT_BC, ROTATE_SPEED, 100);
if ((light_intensity_1 == light_intensity_2) && (light_intensity_1 >= LOWERLIGHT))
{

break;

}

} while(true);

}

sub light_go_left()
{

do
{

light_intensity_1 = Sensor(IN_3);
light_intensity_2 = Sensor(IN_4);
OnFwdSync(OUT_BC, ROTATE_SPEED, -100);
if ((light_intensity_1 == light_intensity_2) && (light_intensity_1 >= LOWERLIGHT))
{

break;

}

} while(true);

}

sub follow_light()
{

do
{

check_light_sensor();
light_intensity_1 = Sensor(IN_3);
light_intensity_2 = Sensor(IN_4);
OnFwd(OUT_BC, MOTOR_POWER);
while (SensorUS(IN_2) < DISTANCE)
{

Off(OUT_BC);
check_light_sensor();
light_intensity_1 = Sensor(IN_3);
light_intensity_2 = Sensor(IN_4);
if ((light_intensity_1 < LOWERLIGHT) && (light_intensity_2 < LOWERLIGHT))
{

search_for_light();
break;

}
else if ((light_intensity_1 > (light_intensity_2 + 10)) || (light_intensity_1 < (light_intensity_2 – 10)))
{

break;

}

}
if (light_intensity_1 > (light_intensity_2 + 10))
{

light_go_right();

}
else if (light_intensity_1 < (light_intensity_2 – 10))
{

light_go_left();

}
else if ((light_intensity_1 < LOWERLIGHT) && (light_intensity_2 < LOWERLIGHT))
{

Off(OUT_BC);
PlayToneEx(200,200,1,FALSE);
break;

}

} while (true);

}

task main()
{

do
{

SetSensorUltrasonic(IN_2);
Wait(1000);
check_light_sensor();
search_for_light();
follow_light();

} while(true);

}