Oracle DB – Quick Reference

December 12, 2014 Leave a comment

A quick reference for us Novices

View current database select * from global_name;
Create a new user create user “username” identified by “password”;
eg create user felix identified by felix
Grant connect and resource privileges grant connect, resource to felix;
Allow user to create new tables grant dba to felix;
Change the default number of lines per page(14) set pagesize 60;
Change the default number of characters per line (80) set linesize 100;
Clear formatting clear column;
Run previous command /

Now I can connect to database as

vagrant-ubuntu-oracle-xe$ rlwrap sqlplus64 felix/felix@//localhost:1521/XE



Categories: oracle

vagrant-ubuntu-oracle-xe – ERROR ORA-12162; ORA-12547;

December 11, 2014 Leave a comment

When I tried to connect to vagrant-ubuntu-oracle-xe box I got the following errors

vagrant-ubuntu-oracle-xe$ vagrant up

vagrant-ubuntu-oracle-xe$ sqlplus64 system/manager@//localhost:1521/XE

SQL*Plus: Release Production on Thu Dec 11 21:50:08 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ORA-12547: TNS:lost contact
Enter user-name: 
Enter password: 
ORA-12162: TNS:net service name is incorrectly specified


vagrant-ubuntu-oracle-xe$ vagrant halt
==> default: Attempting graceful shutdown of VM...

vagrant-ubuntu-oracle-xe$ vagrant up

vagrant-ubuntu-oracle-xe$ vagrant ssh

Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 02:23:18 2012 from
vagrant@oracle:~$ cat /u01/app/oracle/product/11.2.0/xe/network/admin/tnsnames.ora 
# tnsnames.ora Network Configuration File:

XE =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))

Added the following to the tnsnames.ora file above (So now I have two entries)
XE =
    (ADDRESS = (PROTOCOL = TCP)(HOST = = 1521))
vagrant@oracle:~$ sqlplus system/manager@//oracle:1521/XE

SQL*Plus: Release Production on Thu Dec 11 14:11:37 2014
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release - 64bit Production
SQL> quit

vagrant@oracle:~$ exit
Connection to closed.

vagrant-ubuntu-oracle-xe$ sqlplus64 system/manager@//localhost:1521/XE

SQL*Plus: Release Production on Thu Dec 11 22:11:00 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release - 64bit Production
SQL> quit
Disconnected from Oracle Database 11g Express Edition Release - 64bit Production


Fluxbox changing focus

December 8, 2014 Leave a comment

I reinstalled debian and fluxbox. I have a monitor attached to my laptop, but every time I clicked on any window on the second screen, it would get moved to the first screen. Right clicking to bring up the main menu on the second screen also did not work.

Apparently, under main menu, configuration there is an option to change the Focus Model. That was my problem. I changed it to “Mouse Focus” then back to “Click to Focus” and my fluxbox is now working as normal.

So that was not the fix. The issue was that when fluxbox starts, my Toolbar width is only on one screen. When I right click on the second screen that does not have the toolbar, the menu only appears on the first screen. So to fix, I need to restart fluxbox so that the Toolbar appears on both. (I need to change the init settings for this). Earlier, when changing focus I restarted it but attributed the fix to the changing of focus which was incorrect.

The upside of this struggle, was that I learnt quite a bit about the keys file. For more on keys

Working with “Vagrant and Oracle database 11g”

December 6, 2014 Leave a comment

This is a follow up to my earlier post here.

I. Some changes made to Vagrantfile

1. Changed the host port to 1234 as it complained that 1521 was already in use. (This is the one to connect to via sqlplus64) :forwarded_port, guest: 1521, host: 1234
2. Changed the amount of memory database should use from 512 to 2048
i. In the VagrantFile
# Oracle claims to need 512MB of memory available minimum
"--memory", "2048",

ii. In /modules/oracle/manifests/init.pp file, changed from 1024 to 4096
"/bin/dd if=/dev/zero of=/swapfile bs=1M count=4096",

II. Bring up Oracle 11g database on virtual instance of Ubuntu

$ cd vagrant-ubuntu-oracle-xe/
:~/vagrant-ubuntu-oracle-xe$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 1521 => 1234 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
... <deleted a bit of output>
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.
:~/vagrant-ubuntu-oracle-xe$ vagrant provision
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: stdin: is not a tty
... <deleted a bit of output>
==> default: notice: /Stage[main]/Oracle::Server/Exec[apt-update]/returns: executed successfully
==> default: notice: /Stage[main]/Oracle::Xe/File[/tmp/]/ensure: defined content as '{md5}c874e5a7a4cc6b15ff68055335c136fb'
==> default: notice: /Stage[main]/Oracle::Xe/File[/tmp/xe.rsp.orig]/ensure: defined content as '{md5}b79c95d12321f3eb55d855082d1d6831'
==> default: notice: /Stage[main]/Oracle::Server/File[/tmp/60-oracle.conf]/ensure: defined content as '{md5}61b22d59fdc07f9fa6929ab74f5b6e99'
==> default: info: /Stage[main]/Oracle::Server/File[/tmp/60-oracle.conf]: Scheduling refresh of Exec[procps]

III. Install sqlplus
Download oracle-instantclient11.2-sqlplus- from Oracle site.

1. Install alien
# apt-get install alien
2. Convert rpm to deb
# alien -k --scripts oracle-instantclient11.2-sqlplus-
3. Install deb
# dpkg -i oracle-instantclient11.2-sqlplus_11.

IV. Connect to Oracle 11g database

$ sqlplus64 system/manager@//localhost:1234/XE

SQL*Plus: Release Production on Sat Dec 6 13:44:32 2014

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

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

If you have an issues with sqlplus64, try to follow instructions in this post. YMMV.

V. Adding History
# apt-get install rlwrap

As a normal user
$ rlwrap sqlplus64 system/manager@//localhost:1234/XE


Using Oracle with Vagrant

December 6, 2014 Leave a comment

This was a major issue for me. I needed Oracle 11g Database on my laptop.

One of the possible solutions I took was to use vagrant. (I am pretty much just going to repeat the same steps as per what I got from the website listed in the Sources section below.)

1. Download and install Vagrant
2. Download and install VirtualBox
3. Download the Oracle 11g zip file for Linux x64
NB. Always download the Linux x64 zip file, even if you are on Windows or Mac OSX.
4. Clone the vagrant-ubuntu-oracle-xe repository from GitHub
git clone git://
5. Copy the Oracle 11g zip file to the directory vagrant-ubuntu-oracle-xe expects to find it in
cp ~/Downloads/ ~/vagrant-ubuntu-oracle-xe/modules/oracle/files
6. Install vbguest
vagrant plugin install vagrant-vbguest
7. Invoke Vagrant to install and configure Oracle 11g
cd ~/vagrant-ubuntu-oracle-xe
vagrant up

After a few minutes your local machine will be running an Oracle 11g server on a virtual instance of Ubuntu 12.04

Well… not exactly.
1. I had run out of space on my / partition. I couldn’t install the new linux header files that were needed. The quickest thing for me was to format my machine. This time round I gave a bit more GBs to / partition.
2. Added some mirrors to /etc/apt/sources.list
3. root> apt-get update
4. First mistake I made was not to do apt-get dist-upgrade
5. So, oblivious of that, I followed steps 1 to 7, but vagrant up brought more errors
6. The kernel version on my machine and the latest linux-headers- being seen by virtual box were not the same. I was getting an error similar to this. (It was late and I did not have the presence of mind to save the errors. Sorry.)
$ VBoxManage --version
WARNING: The character device /dev/vboxdrv does not exist.
Please install the virtualbox-ose-dkms package and the appropriate
headers, most likely linux-headers-generic

You will not be able to start VMs until this problem is fixed.

7. Googled a bit. All references to above error were advising the OPs to do the following
apt-get install linux-headers-$(uname -r)
8. But above did not work since I could not find the linux-headers for the current system version that I had.
9. After 2 or 4 hours, I realised that I needed to get my kernel (3.14) to the same version as what was installed (3.16), so read about configuring kernels but the steps were too hard for my already fried brain. At this point I stumbled accross an page explaining what apt-get does. And thus I tried dist-upgrade with the hope that it would upgrade my kernel.
10. Ran the below command
root> apt-get dist-upgrade
11. Once that was done, I rebooted and sure enough my kernel was now 3.16
12. vagrant up now runs
13. So this install would have gone a whole lot more smoothly if I had updgraded my machine before I started this exercise. I’m much older and wiser :-)


Introduction to AMQP

November 26, 2014 Leave a comment

AMQP is the Advanced Message Queuing Protocol, an open standard protocol for message orientation, queuing, routing, reliability and security, for which the RabbitMQ messaging server is the most popular implementation.



Learning Python

November 20, 2014 Leave a comment

Found some pretty interesting sites for learning python.

I normally get really bored doing exercises in books. So working with games and/or tasks is much more involving and interesting to me.

Program Arcade Games

Small issue with Program Arcade Games site. Registration is pretty simple, just type in your email address and a password. Use numbers and text. Changing your password was not working when I tried.

Categories: Interesting, python

Get every new post delivered to your Inbox.

Join 41 other followers