Categories
Tutorial

Deploy Postgresql 9.1 and PostGis 2.1 on Cent OS 7 Server

What’s PostGIS ?

PostGIS is an open source software program that adds support for geographic objects to the PostgreSQL object-relational database. PostGIS follows the Simple Features for SQL specification from the Open Geospatial Consortium.

There are a lot of software products that can use PostGIS as a database backend, such as ArcGIS, QGIS, CartoDB, MapInfo, TerraLib…

For example, it’s used by OpenStreetMap, a collaborative project that create a free editable map of the world.

1) Install CentOS 7

First, we will start by downloading the last ISO image of Cent OS 7 on the official website.

We can choose the “Minimal ISO”, which contains every necessary things for a server, but nothing more.

Then, we can begin the installation process, typically a VMs with 2 vCores, 2 GB of memory and 40 Gb Hard Disk, which is enough for the moment.

centos-p-1

Installation wizard is graphical, no particular skills required:

centos-p-2

Don’t forget to set the root password!

centos-p-3

After a reboot, we should enable the Ethernet interface (which is disabled by default) and set IP parameters.

So we could connect as “root” in a terminal, and use the NetworkManager by running the command “nmtui” :

centos-p-4

centos-p-5

centos-p-6

Now we can go the next step!

2) Installation de PostgreSQL/PostGIS

PostgreSQL is available on Yum Default Repository for CentOS 7, but you cannot choose the version.

So, we need to add the “PostgreSQL 9.3” repository:

[root@vm-centos1 ~]# rpm -ivh http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-2.noarch.rpm

And then, you can run the installation:

[root@ vm-centos1 ~]# yum install postgresql93 postgresql93-server postgresql93-libs postgresql93-contrib postgresql93-devel

Then, we could install PostGIS, but PostGIS required dependences which are not available in the Default or PostgreSQL Repository, we need to add the EPEL .repo :

[root@ vm-centos1 ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

And now, we can run the installation:

[root@ vm-centos1 ~]# yum install postgis2_93

3) Configuration

We need to initialize the database in PGDATA (run once)

[root@ vm-centos1 ~]# /usr/pgsql-9.3/bin/postgresql93-setup initdb
Initializing database ... OK

If you want PostgreSQL to start automatically when the OS starts, you can run:

[root@ vm-centos1 ~]# systemctl enable postgresql-9.3
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.3.service to /usr/lib/systemd/system/postgresql-9.3.service.

If you want connect to the database from another PC, you must edit this 2 configuration files:

[root@ vm-centos1 ~]# vi /var/lib/pgsql/9.3/data/postgresql.conf
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*'
g
[root@ vm-centos1 ~]# vi /var/lib/pgsql/9.3/data/pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
#host    all             all             127.0.0.1/32            ident
host    all             all             all                     md5
# IPv6 local connections:
host    all             all             ::1/128                 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            ident
#host    replication     postgres        ::1/128                 ident

Then, we can start PostgreSQL service:

[root@ vm-centos1 ~]# systemctl start postgresql-9.3

4) Créer une base de test

Finally, we are going to create a test database.

We need to switch as “postgres” user:

[root@localhost ~]# su postgres
bash-4.2$

And then, create a user and a database:

[root@localhost /]# su postgres
bash-4.2$ createuser --pwprompt --encrypted gisuser
Enter password for new role:
Enter it again:
bash-4.2$ createdb --encoding=UTF8 --owner=gisuser gis.test
bash-4.2$ psql -d gis.test -f /usr/pgsql-9.3/share/contrib/postgis-2.1/postgis.sql
bash-4.2$ exit

Now, you can test the connection in the console:

centos-p-7

Or with graphical tools, such as “PgAdmin” :

centos-p-8

That’s All!

Categories
Ireland Trip

Northen Ireland – March 2015

After a road trip focused on South Ireland 2 years ago, this time we decided to visit Northern Ireland.

Also, we made a 4 days road-trip in order to visit most part of the land:

I appreciate being 25 not to pay any extra fees to rent a car.

Indeed we can now take plane instead of ferries, and enjoy the only 1:30 flight instead of 17:00 on a ferry.

irlande1Once in Dublin, we found the Hertz’s desk to rent our car for the week.

At that time, we had some fears, because the car was a right hand driver vehicle and we had never drive this kind of car (2 years ago, we took our own in the ferry).

By the way, we had a good surprise, because we booked a Ford Ka (A category) and we finally get  a Full Option Volkswagen Polo for the same price.

irlande2Let’s go for 300 Kms, we left “Republic Of Ireland”, drove toward “United Kingdom” and more precisely in Belfast, the capital and largest city of Northern Ireland, where was built the well-known RMS Titanic.

Finally, we finally get used to the left-hand driving, it was unusable and surprising the first day and that’s all.

Once we arrived, we left our bags at the B&B where we booked our first night, went to find a lunch and took a trip in the city.

Belfast is a big city: one of the interesting thing to see is the Titanic museum, situated within the heart of Titanic Quarter, where we spent lots of time in the afternoon.

irlande3

The tour explores the history of the famous barrel-vaulted Harland & Wolff Drawing Offices where Titanic and the rest of the mighty ‘Olympic’ class ships were designed, and provides an opportunity to walk in the footsteps of the men who built Titanic – the world’s most famous ship – in Belfast’s historic shipyard.

irlande4We topped off this day with a shopping tour and a quick dinner in the city centre, before we left the civilization on the next morning.

After eating a Cooked Breakfast (never say “English Breakfast” in Ireland/Scotland), we drove toward « Causeway Coastal Road ».

The route follows a majestic coastal road starting in Belfast and ending in Londonderry.  Hugging the coastline and dipping inland to rural glens and villages for approximately 200 Kms (120 Miles), the route may not cover huge distances, but each location is worth savouring.

First stop after drove 60 Kms and 2 Hours, the Carrick-a-Rede Rope Bridge.

Carrick-a-Rede Rope Bridge is a famous rope bridge near Ballintoy in County Antrim, the bridge links the mainland to the tiny island of Carrickarede. It is thought salmon fishermen have been building bridges to the island for over 350 years.

carrick-a-rede1The bridge is mainly a tourist attraction and is owned and maintained by the National Trust, in 2009 it had 247,000 visitors. A large car park is available 800 metres away.

Luckily, the weather was good, although the bridge was moving a lot because of the wind, and it was really impressive.

The good thing about “Cooked Breakfast”, it’s that you’re not hungry before at least 16:00 and just a sandwich is enough until dinnertime.

So, we took the road to Bushmills, where we booked a room in a Bed and Breakfast for the night.

We tried a first stop at the B&B at 15:30, but obviously it’s too early, no admittance before 17:00.

So, we decided to go to lunch and ate a sandwich in a typical little cafeteria, and then we went to the “The Old Bushmills Distillery”.

bushmills3 bushmills1The company that originally built the distillery was formed in 1784, although the date 1608 is printed on the label of the brand – referring to an earlier date when a royal licence was granted to a local landowner to distil whiskey in the area. After various periods of closure in its subsequent history, the distillery has been in continuous operation since it was rebuilt after a fire in 1885.

The distillery is a popular tourist attraction, with around 120,000 visitors per year.

The smell of the hot whisky will follow us during the trip, where we saw (use of cameras was strictly prohibited during the trip):

  • The transformation of malt grains: we learnt that the ovens, which are used in Ireland, are close to avoid a smoked taste (in Scotland, they use open ovens to feel this smoked taste).
  • The alembic: Irish whisky is usually distilled 3 times (only 2 times in Scotland)
  • The barreling and the storage during 15 years.
  • The bottling

At the end of the trip, we were invited to a little tasting experience.

bushmills2After this long and very full day, we went back to our Bed & Breakfast where we decided to spend a quiet evening.

The next day, after the traditional “Cooked Breakfast”, we took the road again, and drove toward “Giant’s Causeway”.

The Giant’s Causeway is an area of about 40,000 interlocking basalt columns, the result of an ancient volcanic eruption.

It is located in County Antrim on the northeast coast of Northern Ireland, about three miles (4.8 km) northeast of the town of Bushmills. The Department of the Environment for Northern Ireland declared it a World Heritage Site by UNESCO in 1986, and a national nature reserve in 1987.

Much of the Giant’s Causeway and Causeway Coast World Heritage Site is today owned and managed by the National Trust and it is one of the most popular tourist attractions in Northern Ireland.

Once arrived, you can find a large car park and a visitors’ information office, which provide souvenir shop, cafeteria, service area and toilets. Then the staff give you an audio guide and you can go the area which is 2-3 kms away, by 2 ways:

  • Walking (approximately 1 hour)
  • Take the bus (every 20 minutes)

Considering the weather conditions, we choose the second option.

causeway1According to the legend, the columns are the remain of a causeway built by a giant. The story goes that the Irish giant Fionn mac Cumhaill (Finn MacCool), from the Fenian Cycle of Gaelic mythology, was challenged to a fight by the Scottish giant Benandonner. Fionn accepted the challenge and built the causeway across the North Channel so that the two giants could meet. In one version of the story, Fionn defeats Benandonner. In another, Fionn hides from Benandonner when he realises that his foe is much bigger than he. Fionn’s wife, Oonagh, disguises Fionn as a baby and tucks him in a cradle. When Benandonner sees the size of the ‘baby’, he reckons that its father, Fionn, must be a giant among giants. He flees back to Scotland in fright, destroying the causeway behind him so that Fionn could not follow.

Then, we took the road again toward Londonderry, which was our final destination of the day and by the way the end of this “coastal road”.

dunlunce_castleTwo hours later, we arrived and immediately noticed the strange atmosphere that reigns here.

In fact, we were just at the border between the United Kingdom and Ireland, we saw many graffitis and flags, pro-Irish or pro-British.

londonderryThis city inspired the band “U2” for the song “Sunday Bloody sunday”, because it’s an event that took place here.

Bloody Sunday, sometimes called the Bogside Massacre, was an incident on 30 January 1972. British soldiers shot 26 unarmed civilians during a protest march against internment.

Thirteen people died: thirteen were killed outright, while the death of another man four months later was attributed to his injuries. Many of the victims were shot while fleeing from the soldiers and some were shot while trying to help the wounded. Other protesters were injured by rubber bullets or batons, and two were run down by army vehicles.

londonderry2So, Londonderry is a big city, we spent lots of time in the town centre, took a trip along the river and went shopping.

Then, we went to the B&B where we went to bed early, because we had a long road to do the next morning.

Indeed, after eating our usual Cooked Breakfast, we took the road to your final point, Dublin, where we left the car and took the plane for the return to France.

One thing is certain, we will come back again 🙂