[Solved] My Java application fails to connect to my Oracle database

Yesterday we debugged with Pepe some random connection reset exceptions in our application when trying to connect to the Oracle database. He wrote this nice post about it.

Goldfish tips

Problem

Yesterday we faced a very weird issue: we have a Java application connecting to an Oracle DB via ojdbc6.

In these days it stopped working, magically: no relevant changes in the system configuration or source code.

The application couldn’t connect to the database: on client side, debugging the stack traces shown it was stuck in the logon process; on server side, Oracle was killing the connection for a timeout waiting for the client:

(alert.log)

What’s weird is that we could successfully connect to the same DB using the same credentials of our application via SqlPlus, SQL Developer. And even the same application worked fine from another machine using the same JDK.

To make sure it wasn’t our application, we tested with the following small java class (please forgive the style):

This class shown the same problems of our application but it turned out to be very convenient because…

View original post 130 more words

Advertisements
Posted in java, linux | Leave a comment

Install or upgrade to docker 1.8.x on ubuntu 15.04

Ubuntu 15.04 repositories only contain docker 1.5, therefore, this is the version you get if you apt-get install docker on ubuntu.
If you need (and you should) latest version of docker (here 1.8.3), these are the steps you need to perform (as root):

Update the apt-get source

 vi /etc/apt/sources.list
 #Append this line:  
 deb https://apt.dockerproject.org/repo ubuntu-vivid main

Then type this at command prompt

apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

install/upgrade docker

apt-get update
apt-get install docker-engine

Note: If you are upgrading, accept all default options (for configuration override) when prompted.

configure docker
For some reason, the file /etc/default/docker which used to contain the docker options is not read anymore. You can add docker option by editing the file /lib/systemd/system/docker.service and add the options at the end of the line

ExecStart=/usr/bin/docker daemon -H fd://

For instance, mine looks like this

/usr/bin/docker daemon -H fd:// --insecure-registry my.private.domain:5000 -g /docker

Restart the docker service

   systemctl daemon-reload
   service docker stop
   service docker start

Resources:

https://blog.docker.com/2015/07/new-apt-and-yum-repos/

http://nknu.net/how-to-configure-docker-on-ubuntu-15-04

Posted in docker | Leave a comment

Clean files on oracle server to free up disk space

I’m an oracle newbie .  Today I had to free up some disk space on our oracle server.

I had to:

  • Step1. delete old databases not used anymore
  • Step2. clean-up the database logs

Step1. delete old databases not used anymore 

  • ssh to the db sever with -X and run dbca
ssh -X oracle@myOracleServer
dbca

When dbca window opens, select “Delete Database”, then delete your databases.

Step2. Delete old logs

  • run adrci
adrci
  • show homes
adrci> show homes
ADR Homes
diag/tnslsnr/dbname/listener
diag/rdbms/mydb1/mydb1
  • For each home delete all logs older than one day
adrci>  set homepath diag/tnslsnr/targaryen/listener
adrci> PURGE -age 1440 -type ALERT
Posted in Cracking the coding interview - a python experience | Leave a comment

Increase disk size of docker containers when using device mapper

Hi. If you you are using docker with device mapper (for instance, the default config on a fedora system) you might want to change 2 things:

* Increase the storage disk for one container which defaults to 10G
* Increase the total data space used by docker on your platform, which defaults to (type ‘docker info’): Data Space Total: 107.4 GB

Important notice: If you perform the following operations, you will lose all images and containers.

Before performing these operations, stop the docker service.

docker service stop

Increase the data storage used by a container

Edit the docker config file, usually /etc/sysconfig/docker. Modify the options line and add –storage-opt dm.basesize=400G. For me, it looks like this:

-g /DATA/docker --storage-opt dm.basesize=90G --storage-driver=devicemapper 

The -g option specify the docker hoe folder. Device mapper will create files in this folder.
I set the max disk size of a container to 90G. Of course this is a boundary, my containers will not take as much, but they are bounded to that.

Increase the total data storage used by your docker installation
I took the solution from this post.
My docker home folder is in /DATA/docker. If you use the default config, replace /DATA/docker with /var/lib/docker in the following operations.

* Remove the docker folder

  rm -rf /DATA/docker

* Create the storage folder

mkdir -p /DATA/docker/devicemapper/devicemapper

* Create your pool. Let’s create a 250G file

dd if=/dev/zero of=/DATA/docker/devicemapper/devicemapper/data bs=1G count=0 seek=250 

This is it. You can now start docker service:

docker service start

Type docker info to see the ‘Data Space Total’ property value.
Download your images and start your containers. Inside a container type ‘df -h’. You should now see 90G of disk storage.

Posted in docker, linux | 1 Comment

Remove docker unneeded containers and images

Docker does not remove your old containers or images. This is your job, not docker’s.  But, at some point, some cleanup needs to be performed.

It is up to you to decide what to remove.  I show here an example of how I clean my docker containers and images.

How to I do it

List all containers and select, with grep, only containers  that needs to be deleted.

We list containers with docker ps. This command lists  one container per line, with these attributes: CONTAINER ID,   IMAGE,  COMMAND,  CREATED, STATUS, PORTS, CONTAINER NAME :

fc9f4ab5c23c registry:latest "docker-registry" 4 days ago Up 17 hours 0.0.0.0:5000-5000/tcp my_registry 

Deleting not needed containers

These are my rules to delete containers:

  • Do not delete any containers that contain any of these keywords in their name: registry:latest,nexus,keep
  • Only delete Exited containers (not running). In any case, docker will refuse to delete running containers
containers_to_keep=$(docker ps -a | grep 'keep\|registry:latest\|nexus' | awk '{ print $1 }')
containers_to_delete=$(docker ps -a | grep Exited | grep -Fv "$containers_to_keep" | awk '{ print $1 }')
docker rm $containers_to_delete || echo "Could not remove some containers"

Deleting not needed images

For images, I want to keep all latest versions and all images having any of these keywords in their name: keep,nexus.

images_to_keep=$(docker images | grep  'latest\|keep\|nexus' | awk '{ print $3 }')
images_to_delete=$(docker images | grep -Fv "$images_to_keep" | awk '{ print $3 }')
docker rmi $images_to_delete || echo "Could not remove some images"

This is it.

Posted in Cracking the coding interview - a python experience | Leave a comment

How To Install and Configure Munin Monitoring on a single fedora machine

I needed a simple to install tool to monitor a fedora 20 machine.  I chose Munin.

It has very nice graphs for the performance of the machine, like this one I found on the web:

Munin Graph Example

Here are the steps I performed to set-up munin on a single fedora machine.

Continue reading

Posted in linux | Tagged , , , | Leave a comment

Robot Framework – quit writing ugly robot code, just write proper python

Robotframework is not a programming language. As soon as the test logic is not trivial, writing robot code becomes a nightmare. Robot does not have the  proper structures of a very basic programming language. Just try to write an if-else statement or a while loop and you’ll see.
But Robotframework does something very good: it presents the test in a human friendly form, very usefull for non programmer.

A robot test could be presented either as an HTML table, or under the form of a txt file (.txt or .robot) with tests written in robot language. When the test is presented as an HTML table, each row is nothing but the call to a keyword, usually written in robot language, in some text file.

The approach I propose is the following: Always use the HTML format for the test presentation. Business people can understand the tables, test and documentation are described in a single document, blah blah blah.  Then, for each single keyword, you implement it directly in python. No need to implement the keywords in the textual robot language which can only make your life difficult. In the html file, import your python files as Libraries:

Library     my_keywords.py 

There are some things that will make your life easy when implementing keywords in python.

  • In the python implementation of a keyword, you can access all variables available in your robot test

Continue reading

Posted in robot framework, testing | Leave a comment