How to install PostgreSQL 9.4 on Raspberry Pi, Radxa or other similar microcomputers running Lubuntu

    I know that this is a little absurd, but sometimes, you may have tasks where the use of microcomputers is one of the best options.

    In total, I had three microcomputers at my disposal: Radxa, Cubieboard A20 and Raspberry Pi. Radxa was chosen as a test subject. It has a 4-core ARM Cortex-A9, 2GB of RAM, 8GB of ROM and an integrated Wi-Fi module. Raspberry Pi can also be used, of course, but it wasn’t suitable for my tasks in performance. The Cubieboard A20 is weaker than Radxa, but its main advantage is the presence of a SATA controller on board.

    Ubuntu Server 14.04 (Linaro for ARM processors) is installed on all microcomputers:

    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Linaro
    Description: Linaro 14.04
    Release: 14.04
    Codename: trusty
    $ uname -a
    Linux radxa 3.0.36+ #7 SMP PREEMPT Wed Aug 20 10:35:50 CST 2014 armv7l armv7l armv7l GNU/Linux

    So, let's start:

    1. Create the file /etc/apt/sources.list.d/pgdg.list and add the following repositories to it:
    deb trusty-pgdg main 9.4
    deb-src trusty-pgdg main 9.4

    If you have a different version of the distribution, then replace trusty with the name of the distribution you are using.

    2. Add a new key for apt:
    wget --quiet -O - | sudo apt-key add -

    3. Update the package list:
    sudo aptitude update

    4. Install the dependencies for PostgreSQL 9.4:
    sudo apt-get install fakeroot
    sudo apt-get build-dep postgresql-9.4

    5. Download and build PostgreSQL 9.4 from source. Attention ( do not execute these commands from under the root ):
    cd /tmp
    apt-get source --compile postgresql-9.4

    The build process on Radxa took about an hour and during operation flew by unnoticed. On a Raspberry Pi, it’s better to run such commands before bedtime.
    After a successful build, you will receive 16 deb packages.

    6. Create a local repository and transfer deb packages to it:
    sudo mkdir /var/local/repository
    sudo mv *.deb /var/local/repository/
    cd /var/local/repository
    sudo dpkg-scanpackages ./ > Packages && gzip -f Packages

    7. Add the local repository to /etc/apt/sources.list.d/pgdg.list :
    deb [ trusted=yes ] file:///var/local/repository ./

    8. We update the list of available packages:
    sudo aptitude update

    9. Now we can install PostgreSQL 9.4:
    sudo aptitude install postgresql-9.4

    10. Check the work:
    afedorov@radxa:~$ sudo su - postgres
    postgres@radxa:~$ psql
    psql (9.4beta3)
    Type "help" for help.

    Also popular now: