Sunteți pe pagina 1din 5

Global Open Versity Labs Install Guide PostgreSQL Server on Linux v1.

Global Open Versity


IT Systems Integration Hands-on Labs Training Manual

Install Guide PostgreSQL Server on Linux CentOS5


Kefa Rabah
Global Open Versity, Vancouver Canada
krabah@globalopenversity.org
www.globalopenversity.org

Table of Contents Page No.

INSTALL GUIDE POSTGRESQL SERVER ON LINUX CENTOS5 2


Introduction 2

Part 1: Install PostgreSQL 3

Part 2: Create Your Own Database 6


Step 1: Decide the location of the database setup 7
Step 2: Modify /etc/profile file 9
Step 3: Modify "pg_hba.conf" file 9
Step 4: Securing connections. 10

Part 4: Hands-on Labs Training Assignments 10

Hint: Installing Moodle LMS using PostgreSQL database 10


Step 1: Create Moodle data-store 10
Step 2: Create Moodle database using PostgreSQL 11
Step 3: Configure Moodle Website 12

Part 5: Need More Training 12

A GOV Open Knowledge Access Technical Academic Publications License


Enhancing education & empowering people worldwide through eLearning in the 21st Century
1
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada

www.globalopenversity.org ICT202 - Linux Enterprise Infrastructure Engineering Diploma


Global Open Versity Labs Install Guide PostgreSQL Server on Linux v1.0

Global Open Versity


IT Systems Integration Hands-on Labs Training Manual

Install Guide PostgreSQL Server on Linux CentOS5


By Kefa Rabah, krabah@globalopenversity.org Feb 18, 2010 GTSI Institute

Introduction
CentOS is a community-supported, free and open source operating system based on Red Hat Enterprise
Linux. It exists to provide a free enterprise class computing platform and strives to maintain 100% binary
compatibility with its upstream distribution .CentOS stands for "Community ENTerprise Operating
System". CentOS is the perfect server for people who need an enterprise class operating system stability
without the cost of certification and support and pocket burning baggage that comes with proprietary
software. And the beauty is CentOS is free.

CentOS is an Enterprise-class Linux Distribution derived from sources freely provided to the public by a
prominent North American Enterprise Linux vendor. CentOS conforms fully with the upstream vendors
redistribution policy and aims to be 100% binary compatible. (CentOS mainly changes packages to
remove upstream vendor branding and artwork.).

CentOS Structure - CentOS developers use Red Hat's source code to create a final product very similar
to Red Hat Enterprise Linux. CentOS is available free of charge. Technical support is primarily provided
by the community via official mailing lists, web forums, and chat rooms. The project is not affiliated with
Red Hat and thus receives no financial or logistical support from the company; instead, the CentOS
Project relies on donations from users and organizational sponsors.

PostgreSQL, often simply Postgres, is an object-relational database management system (ORDBMS). It


is released under an MIT-style license and is thus free and open source software. As with many other
open source programs, PostgreSQL is not controlled by any single company, but has a global community
of developers and companies to develop it.

MySQL vs PostgreSQL is a decision many must make when approaching open-source relational
databases management systems. Both are time-proven solutions that compete strongly with proprietary
database software. MySQL has long been assumed to be the faster but less full-featured of the two
database systems, while PostgreSQL was assumed to be a more densely featured database system often
described as an open-source version of Oracle. MySQL has been popular among various software
projects because of its speed and ease of use, while PostgreSQL has had a close following from
developers who come from an Oracle or SQL Server background.

Assumptions:
It’s assumed that you have a good understanding of Linux operating system and its working environment.
It’s also assumed that you know how to install and configure Linux CentOS5, if not go ahead and pop over
to scribd.com and check out a good HowTo entitled “Install Configure and Upgrade Linux CentOS5 Server
v1.1” to get you started.

2
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada

www.globalopenversity.org ICT202 - Linux Enterprise Infrastructure Engineering Diploma


Global Open Versity Labs Install Guide PostgreSQL Server on Linux v1.0

Solution:
In this Lab session, you’ll learn how to setup virtual network on VMware (you may also use any other
virtual machines like MS VirtualPC, Linux Xen, or VirtualBox from Sun). Next you will learn how to install
and setup Sun JDK6. You’ll also learn how to install & setup PostgreSQL server. You’ll also learn how to
initialize PostgreSQL, and how to create database. You will also learn how to setup database for installing
Moodle LMS. Finally you’ll have an opportunity to do the Hands-on Labs home assignment labs to test
what you have learned in this lesson. In the Hands-on Assignment you’ll have an opportunity to test your
skills by setting up Moodle database and installing it on Linux. Once you’re done with this labs session
you should have gained an experience and capability to enable you to plan design implement and deploy
PostgreSQL for small to medium business infrastructure.

Part 1: Install PostgreSQL


In this section we’ll install the PostgreSQL database server and the component required to write PHP
scripts that communicate with postgresql. We use yum to handle dependencies and gather all of the
required packages. For more information on PostgreSQL, see http://www.postgresql.org

1. Install PostgreSQL and the component that allows PHP to talk to PostgreSQL.

# yum install postgresql postgresql-server php-pgsql -y

2. Configure the new service to start automatically on boot

# /sbin/chkconfig –level 345 postgresql on


# /sbin/service postgresql start

Note: when you start postgresql for the first time, it’ll initialize the database.

3. Start the postgresql interactive shell and create your first user and database.

# su - postgres \\The dash "-" is important!

4. Next, issued the command, "psql template1", to enter the default postgresql database

-bash-3.2$ psql template1


Welcome to psql 8.1.11, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
template1=#

Note: "template1"is the database that is included by default with PostgreSQL.

3
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada

www.globalopenversity.org ICT202 - Linux Enterprise Infrastructure Engineering Diploma


Global Open Versity Labs Install Guide PostgreSQL Server on Linux v1.0

5. Check the version of your postgresql:

template1=# select version();


version
--------------------------------------------------------------------
PostgreSQL 8.1.18 on i686-redhat-linux-gnu, compiled by
GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
(1 row)
template1=# \q
-bash-3.2$

6. Now let’s change the default postgres password, as follows:

template1=# ALTER USER postgres WITH PASSWORD 'password'

Note: the default postgres password can only be changed if the "pg_hba.config" file is in default
form. Also ensure that the password has strong password complexity!

7. Now create dbase user "dbuser" and make him a superuser:

-bash-3.2$ createuser -P dbuser


Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) y
CREATE ROLE
-bash-3.2$

1. Follow the link below to access the full document.

The full document has moved to Docstoc.com. You can access and download it from
here:

http://www.docstoc.com/docs/32187317/Install-Guide-PostgreSQL-Server-on-Linux

-----------------------------------------------

Kefa Rabah is the Founder of Global Technology Solutions Institute. Kefa is knowledgeable in several
fields of Science & Technology, Information Security Compliance and Project Management, and
Renewable Energy Systems. He is also the founder of Global Open Versity, a place to enhance your
educating and career goals using the latest innovations and technologies.

4
April 2007, Kefa Rabah, Global Open Versity, Vancouver Canada

www.globalopenversity.org ICT202 - Linux Enterprise Infrastructure Engineering Diploma

S-ar putea să vă placă și