Skip to content

Entries tagged "debian".

Oracle on Debian Lenny: ORA-01034: ORACLE not available

Today I installed (again) Oracle XE on Debian (Lenny) and got the following error:

ORA-01034: ORACLE not available
ORA-27123: unable to attach to shared memory segment
SVR4 Error: 13: Permission denied

I suspected problem was caused by errant ORACLE_HOME / ORACLE_SID values bug got the answer:

chmod 6751 $ORACLE_HOME/bin/oracle

That gives "-rwsr-s--x". Why permissions were not set properly on installation - have no idea. Any clues?

How to drop current postfix queue

How to drop selected emails from postfix queue (useful when many automated e-mails are blocking it):

# mailq | awk '/^[A-Z0-9].* {print "postsuper -d " $1} ' | sh

or simpler: purge all queue (warning: you can loose important, undelivered e-mails forever!):

# postsuper -d ALL

Aptitude vs apt-get memory usage on Debian

If you are administering small-memory VPS servers it's very easy to exceed all available memory. Typical memory hogs (apache mpm-prefork, rsyslogd) could be easily replaced by alternatives. It's not very easy to do with packaging system (you have to be up to date with security updates).

I compared memory usage of two APT interfaces: apt-get and (new, now prefferred) aptitude. Here are the results (top output when command shows list of packages to install):

# apt-get install munin
28800 root      20   0 15940  13m  10m T    0 10.3   0:00.44 apt-get
# aptitude install munin
28822 root      20   0 40936  33m  12m T    0 26.3   0:00.92 aptitude

As you can see aptitude uses almost 3x more memory than apt-get (VSZ and RSZ). If you are low on memory on low-end box it's noteworthly saving.

Note: tests were done on 32-bit OpenVZ-based VPS.


ORA-01722: invalid number

"ORA-01722: invalid number" is raised when a number was passed a query parameter, but another type (string) was expected.

The error message isn't very helpful, is it?

ORA-00600: internal error code

Interesting error found on Oracle XE installed for one of projects. After a run of test case that uses JDBC to perform some operations on database all tests started to fail with this exception:

Caused by: java.sql.SQLException: ORA-00600: internal error code, arguments:\
 [kdsgrp1], [], [], [], [], [], [], []
at oracle.jdbc.driver.DatabaseError.throwSqlException(
 at oracle.jdbc.driver.T4CTTIoer.processError(
 at oracle.jdbc.driver.T4CTTIoer.processError(
 at oracle.jdbc.driver.T4C8Oall.receive(
 at oracle.jdbc.driver.T4CPreparedStatement.doOall8(
 at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(
 at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(

Restart of Oracle database did not work. Seems table space was broken. I rebuit the database (DROP, then CREATE) and error dissapeared.

Interesting ...

Chrooting 32-bit Debian

Sometimes brand-new 64 bit architecture must be used for running 32-bit programs. You can preserve your 64-bit system and create so called "32 bit chroot" environment. I'll use Debian as guest operating system because it supports easy bootstrapping out-of-the-box.

I assume debootstrap program is already installed. First: create Debian tree:

# debootstrap --arch=i386 lenny /home/dccb/lenny

Then we can chroot to new env and customize:

# chroot /home/dccb/lenny /usr/bin/i386

Note that shell "/usr/bin/i386" is required for chrooted environment to see 32-bit architecture. If you want to jump directly into plain user account use this command:

# chroot /home/dccb/lenny /usr/bin/i386 su - $CHROOT_USER

Inside chroot you can do (almost) everything (install programs, run daemons, ...). Note that sometimes you will have to change services ports to not collide with services present on host (HTTP, SSH, ...) - it's not a virtualisation, just chroot jail.

Additional note: In order to get correct /dev and /proc tree you have to mount them before chrootting:

mount -o bind /proc /home/dccb/lenny/proc
mount -o bind /dev /home/dccb/lenny/dev

"No recommends" on Debian/Ubuntu by default

Sometimes you want to install some packages quickly and you know exactly what components you need. Then installing uneccessary 20 MB (recommended/suggested packages) when you need just 200 kB package is just waste of your time and disk space. Here's good news: you can easily tell apt not to install recommend (and/or suggested) packages to make installation faster:

echo 'APT::Install-Recommends "0"; APT::Install-Suggests "0";' \
    > /etc/apt/apt.conf.d/no-recommends

Show Incoming E-mails In System Notification Area in Gnome

For delivering e-mail locally I'm using fetchmail (POP3 based) + local SMTP daemon (for outgoing e-mail). I'd like to see when new e-mail arrives to my desk. It's pretty easy if you connect classic procmail with modern notification tools based on local message buses.

For GNOME command line interface to internal message is notify send. I'm adding call inside my ~/.procmailrc (after filtering out spam e-mail of course):

| grep "^From:\|^Subject:" > /tmp/mail.notify-send; DISPLAY=:0.0 notify-send "`cat /tmp/mail.notify-send`"

The result looks like this:

Building packages from sources using Debian/Ubuntu

Sometimes you want to install latest version of selected software package while keeping base system stable. Then installing from source is a safe option to proceed.

First, you have to include sources from fresh system version, below is example taken from Ubuntu, I selected natty (/etc/apt/sources.list):

deb-src natty main restricted

Then you should refresh package list:

sudo apt-get update

and install dependencies:

sudo apt-get build-dep ccache

and finally build the new version of a package (note that no root account is needed for that step):

apt-get -b source ccache

As a result there's a *.deb package, install it:

sudo dpkg -i ccache*.deb

That's all!

Configure locales under Ubuntu

If you used to Debian you probably know that "dpkg-reconfigure locales" brings you locale selection tool. It's not the case for Ubuntu. How to replace Debian's behavior? Read below:

# grep pl_PL.UTF-8 /usr/share/i18n/SUPPORTED > /var/lib/locales/supported.d/local
# dpkg-reconfigure locales
   Generating locales...
     pl_PL.UTF-8... done
   Generation complete.

Above example show how to add pl_PL.UTF-8 locale.

Downgrade Ubuntu/Debian using apt preferences

There are people who prefer bleeding-edge software versions, other prefer stability over new features. I'm an advanced Linux user, however I fall into the latter category of users. Recently I discovered my current mixed-version Ubuntu is not as stable as I would like and I decided to revert to older version of Ubuntu (lucid).

Debian apt system allows to set preferences for packages and this method can be used to downgrade packages. First of all you have to declare sources of software of desired distro (lucid) in my case:

$ grep ^deb /etc/apt/sources.list
deb lucid main restricted
deb lucid-updates main restricted
deb lucid universe
deb lucid-updates universe
deb lucid multiverse
deb lucid-updates multiverse
deb lucid-security main restricted
deb lucid-security universe
deb lucid-security multiverse

Then we can declare we prefer lucid even if current package in the system if newer:

$ cat /etc/apt/preferences.d/downgrade-to-lucid
Package: *
Pin: release a=lucid
Pin-Priority: 1010

Package: *
Pin: release a=lucid-updates
Pin-Priority: 1011

Package: *
Pin: release a=lucid-security
Pin-Priority: 1012

As you can see I added updates and security source pacages into account to have such updates already in my system.

Chrooted Debian / Ubuntu mini HOWTO

First question: why do you need local Debian-based install inside your Debian distro? Sometimes you want to check some experimental packages and don't want to break your base system or start some service in isolated environment without virtualisation effort. Then chroot comes as an effective solution for you!

First of all you have the debootstrap program that is used to do all the job you need: sudo apt-get install debootstrap

Then you select your favourite distro version and download URL: sudo debootstrap --arch i386 squeeze /home/debian-chroot

And you jump to your newly-installed system: sudo chroot /home/debian-chroot

And: voila! Done!

Secure PostgreSQL setup on Debian/Ubuntu

postgresqlPostgreSQL is an OpenSource database server that is sometimes slower, but more powerful when compared to MySQL for example. For typical MySQL user complicated authentication system of PostgreSQL may be a bit confusing (they expect just login/password) but it has some advantages over password-based mechanisms: security. I'll show you how to setup ident-based authentication for your applications (authentication method that uses underlying operating system mechanisms).

Installation, assuming version 8.4 is available for your OS (may be different):

$ sudo apt-get install postgresql-8.4

Switch to postgres operating system account for database management, all the following commands are executed from postgresql account:

$ sudo su - postgres

First, create database as a namespace for your tables:

postgres:$ createdb mydatabase

Secondly, create application PostgreSQL user. We do not want to grant too much permissions to this user:

postgres:$ createuser myuser --no-superuser --no-createdb --no-createrole

Right now we have to grant access to newly created database access to PostgreSQL user (just access to single database):

postgres:$ psql mydatabase -c 'GRANT ALL PRIVILEGES ON DATABASE mydatabase TO myuser'

Finally we have to allow connections from operating system account darek to PostgreSQL account myuser:

 mymap  darek   myuser
 local   all         all                               ident map=mymap

In order the changes to have effect you have to reload PSQL configuration files:

postgres:$ /etc/init.d/postgresql reload

What is happening here requires a bit of explanation:

  • A mapping is created from local Linux user (darek) to PostgreSQL account (myuser) called "mymap"
  • Local connections by socket allow to authenticate user darek using mapping "mymap"

As a result "darek" can login as myuser from his account, let's test this:

$ psql mydatabase myuser -c "CREATE TABLE mytable(x int)"

As you probably have noticed no passwords were set. Authentication is done by operating system. This is much safer than storing passwords in configuration files of application.