Category Archives: database postgresql

Install and configure Posgresql 9.3 in Linux ( Centos ) within VMWare – part II

After postgresql installer has executable access, then we can run it as an installer

Choose installation directory

Choose data directory ( Cluster )

Setup password for root, in this case root/ super user is a super user for database not in OS

Choose port where to listen

select locale

installation processing

just uncheck the stackbuilder installer, we don’t need it at this time. It will be usefull when we need additional tools/ services from Postgresql

Once the installation done, the next step is configuration and make an example to verify that our database has been installed as well. To make operation lighter, i’ll access the Linux(Centos)
through sshclient.

Terminal is on, start configuration

/*Go to installed PostgreSQL directory*/
[root@localhost /]# cd /opt/PostgreSQL/9.3/

/*open configuration file for Postgresql within pg_env.sh using VI editor*/
[root@localhost 9.3]# vi pg_env.sh 

/*copy the all lines that contain export command to setup environment variables*/
#!/bin/sh
# The script sets environment variables helpful for PostgreSQL

export PATH=/opt/PostgreSQL/9.3/bin:$PATH
export PGDATA=/opt/PostgreSQL/9.3/data
export PGDATABASE=postgres
export PGUSER=postgres
export PGPORT=5432
export PGLOCALEDIR=/opt/PostgreSQL/9.3/share/locale
export MANPATH=$MANPATH:/opt/PostgreSQL/9.3/share/man

/*Login as postgres user*/
[root@localhost 9.3]# su - postgres 
Last login: Sat Nov  8 09:45:22 EST 2014 on pts/1
-bash-4.2$ 

/*Open file ~/.bash_profile
paste the command that we've copied before, and this will be environment variables for postgresql within OS/*

[ -f /etc/profile ] && source /etc/profile

export PATH=/opt/PostgreSQL/9.3/bin:$PATH
export PGDATA=/opt/PostgreSQL/9.3/data
export PGDATABASE=postgres
export PGUSER=postgres
export PGPORT=5432
export PGLOCALEDIR=/opt/PostgreSQL/9.3/share/locale
export MANPATH=$MANPATH:/opt/PostgreSQL/9.3/share/man

/*save and logout from the postgres user session
then login again as postgres user/*

[root@localhost 9.3]# su - postgres 

/*let's try to connect to postgresql
-bash-4.2$ psql
Password: 
psql.bin (9.3.5)
Type "help" for help.

postgres=# 
/*postgresql connected already*/

/*show all database using meta data command*/

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

Advertisements

Install and configure Posgresql 9.3 in Linux ( Centos ) within VMWare – part I

In this chance i’d like to share with you guys about installing and configuring Postgresql 9.3 in Linux. In this post i’ll use VMWare to simulate that. The distribution of Linux that i’m going to use is Centos or we can use Red Hat. So, let’s start it.
1. Create a new virtual machine

specify linux distribution that we are going to use

Input the name of machine and location of virtual machine files

Specify disk capacity

Click customize hardware

Change the memory for virtual machine into 2GB minimum

Specify ISO file for the Operating system that will be installed

Once setup is done, click Play virtual machine

Process to instal Centos

Setup input language

Click on software selection to add standard Desktop environment

Check server with GUI and select all packages

when done, click installation destination, just check the disk to instal the OS

Start installation by clicking begin installation

On installation progress click root password to add password for root in installed OS

also create a user for the os

when done, wait installation until finished

after installation, click license information

Check accept terms

Once installation is done, login as root user then open terminal, to check IP Address

use sshclient from windows to connect with the virtual machine then upload Postgresql installer for Linux

upload done, then go to terminal again to access the uploaded file. and change the permission to be executable, and run it.