Installing Postgres on a Raspberry PI
description
Transcript of Installing Postgres on a Raspberry PI
![Page 1: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/1.jpg)
By: Lloyd Albin9/28/2012
Installing Postgres on aRaspberry PI
![Page 2: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/2.jpg)
We are not talking about a Raspberry Pie
Raspberry Pie
![Page 3: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/3.jpg)
A raspberry PI is a credit card sized computer for $35.
Raspberry PI
![Page 4: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/4.jpg)
Rev 1: 700 MHz CPU, can be 10% overclocked.
What does it have?
![Page 5: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/5.jpg)
700 MHz CPU, May be overclocked to 1.0 GHz.
Revision 2
![Page 6: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/6.jpg)
The easiest way to install an OS is with one of their image files.
http://www.raspberrypi.org/downloads
I downloaded the Raspbian “wheezy’ version. The latest is the 2012-09-18 edition.
You will also need Win32DiskImager (Windows) or dd (Unix) to write the image to your SD card.
Preparing to Install the OS
![Page 7: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/7.jpg)
Run Win32DiskImager, select the image, and then click the <Write> button.
Installing the Raspbian OS
![Page 8: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/8.jpg)
Upon first bootup, you need to do some configuration. Expand the root partition. Optional: enable ssh, startx, change password.
First Bootup
![Page 9: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/9.jpg)
For any version of Postgres or PG Admin III, we need to update the OS packages first.
sudo apt-get updatesudo apt-get upgrade
Updating the OS
![Page 10: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/10.jpg)
Postgres 9.1 is easy to install. On 10/1/2012 this is Postgres 9.1.5
sudo apt-get install postgresql
Installing Postgres 9.1
![Page 11: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/11.jpg)
sudo apt-get install libperl-devsudo apt-get install python-devsudo apt-get install libreadline-devsudo apt-get install comerr-devsudo apt-get install libkrb5-devsudo apt-get install libxml2-devsudo apt-get install libxslt1-devsudo apt-get install libldap-devsudo apt-get install gettextsudo apt-get install tcl-dev
Pre-Requisites for Compiling Postgres
![Page 12: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/12.jpg)
Bison and flex are only needed for compiling Postgres 9.3 or any HEAD release from the git source repository.
sudo apt-get install bisonsudo apt-get install flex
Additional Pre-Requisites
![Page 13: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/13.jpg)
We can download any of the current versions of source code from:http://www.postgresql.org/ftp/source/
wget http://ftp.postgresql.org/pub/source/v9.2.1/postgresql-9.2.1.tar.gztar -zxf postgresql-9.2.1.tar.gzcd postgresql-9.2.1
Downloading Source Code
![Page 14: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/14.jpg)
Install git
sudo apt-get install git-core
Download the Postgresql git.
git clone git://git.postgresql.org/git/postgresql.git
cd postgresql
Development Source Code Install
![Page 15: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/15.jpg)
./configure \--enable-cassert \--enable-debug \--enable-nls \--enable-integer-datetimes \--with-perl \--with-python \--with-tcl \--with-krb5 \--with-includes=/usr/include/et \--with-openssl \--with-ldap \--with-libxml \--with-libxslt
Configuring from source code
![Page 16: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/16.jpg)
To start the build, type:
make
If you want to build everything that can be built, including the documentation (HTML and man pages), and the additional modules (contrib), type instead: (Not valid for git HEAD edition aka 9.3)
make world
It is optional but you can do regression testing of the database before installing it.
make check
Compiling Postgres
![Page 17: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/17.jpg)
To install PostgreSQL enter:sudo make install
To install the documentation (HTML and man pages), enter:sudo make install-docs
If you built the world above, type insteadsudo make install-world
Installing Postgres
![Page 18: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/18.jpg)
Create the Postgres Usersudo adduser postgres
Create the Data directory and assign the correct permissionssudo mkdir /usr/local/pgsql/datasudo chown postgres /usr/local/pgsql/data
Change to the Postgres Usersu – postgres
Initialize the database/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
Initializing the Database
![Page 19: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/19.jpg)
Success. You can now start the database server using:
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
Note: The above logfile is located in the Postgres home directory.
To Stop the database server:
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data stop
Starting the Postgres Server
![Page 20: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/20.jpg)
Setup postgres, role, password in PostgresStart up and shutdown scriptsModify postgresql.conf
True logging instead of –l logfileSetup to listen on more than localhost
Modify pg_hba.confAllow other computers to access
Other things to do
![Page 21: Installing Postgres on a Raspberry PI](https://reader033.fdocuments.us/reader033/viewer/2022052704/5681677c550346895ddc7ee2/html5/thumbnails/21.jpg)
sudo apt-get install pgadmin3
You will need to either make a desktop icon for it or launch it from the terminal window within x-windows.
pgadmin3 &
Installing PG Admin III