Search This Blog

Friday, May 29, 2015

howto install postgress on centos7 for work with "7 databases in 7 weeks"

I'm finally approaching the end of my writing project  (much later than originally anticipated, and now, as I'm finally through with writing and at the stage of advanced editing, with the end (hopefully a good one) seen in the horizon, I can finally start to focus on the matter for which we have gathered here. 

Curiosity brought me to start reading "7 databases in 7 weeks" and sadly, the book, as interesting as it appears in this early stage of reading, does not guide the reader in the process of installing the databases it teaches... 



and thus I found myself having to install PostgressDB, and this seemed like a great opportunity to fulfill another wish of mine - to install a product from the O/S repositories (instead of downloading the latest product from the maker's website and following the instructions with zeal). 

This is the summary 'howto' of my ordeal

install the server
yum install postgresql-server.x86_64
(it has several dependencies (which you can see later thru yum deplist; the two interesting ones to know are - the postgresql.x86_64, postgresql-libs.x86_64 packages) 

install the contributed packages
yum install posgresql-contrib
(to get the contributed packages, which are only a small part of the variety and they all shall arrive to 
/usr/share/pgsql/extension)

initialize the database 
postgresql-setup initdb 

set database to startup while machine boots up 
chkconfig postgresql on 

start the db
service postgresql start

(how to stop, or restart? 
service postgresql stop
service postgresql restart )

now lets add the extensions to the template db "template1" 
su - postgres 
psql 
create extension tablefunc;
create extension dict_xsyn; 
create extension fuzzystrmatch;
create extension pg_trgm; 
create extension cube; 
(if successful, each sentence shall be responded by 
"CREATE EXTENSION") 

exit psql, using "\q" (without the quotation marks..) 

now lets create a working user
su - postgres [which is the default superuser of postgresql]
createuser --interactive 
(easiest in my mind)
provide name of user ('role' in postgres lingo) 
y/n to shall new role be superuser (recommend against, even though this is a development environment)

y/n to shall new role be allowed to create new databases ? (recommend y. this is a development environment after all)

y/n shall new role be allowed to cereate new roles?
(can't make up my mind yet; don't know enough of postgres; oracle background says no; development says what the heck)

and last - lets create the working db, in this case, the 7 dbs in 7 weeks, "book" db...
run from the shell :
createdb book (you can drop it using dropdb name-db]

enter plsql:
psql book 

the end:
now you can run the book's samples and carry on with your postgress studies... 
(to be on the safe side, first run the book's initial sample to see the extensions are working)

further reading



No comments:

Post a Comment