Configure/Add Postgres Repo
- Download the Centos 6 Repo RPM from HERE
- Install the Repo RPM
Install Postgresql Server
Now that you have the repo install you can use YUM to install Postgresql from the PG repo
Initialize & Start Postgresql Server
You’ll first need to initalize the database for postgresql. If you attempt to start the service before initializing that database you’ll get an error like this….
1 2 3
To initialize the database you can call initdb the init script
Once the initialization is sucessfull you’ll configuration database files created in /var/lib/pgsql/9.1/data
1 2 3
Now you will be able to successfully start the database with the init script
To veryify that the service is running you can by issing status from the init script
Configure Postgresql Access Permissions
Set the authentication method
When you called the initdb command above from RedHat’s init script it configured permissions on the database. These configuration settings are pg_hba.conf
RedHat calls the initdb like this:
This uses the not so popular ident scheme to determine if a user is allow to connect to the database.
ident: An authentication schema that relies on the currently logged in user. If you’ve su -s to postgres and then try to login as another user, ident will fail (as it’s not the currently logged in user).
This can be a sore spot if your not aware how it was configured and will give an error if trying to create a database with a user that is not currently logged into the system.
To get around this issue you can modify the pg_hba.conf file to to move from the ident scheme to the md5 scheme
1 2 3 4
1 2 3 4
Create “Super User”
By default only the postgres user on the system can create databases and manage the server. This user is granted superuser privilegdges to the postgres database(s) and server.
To work around this we will create an additional userser with superuser priviledges for management.
Its advised NOT to grant an application user superuser priviledges for security
Only superusers and users with CREATEROLE privilege can create new users, so creating the initial user must be done from the postgres account.
- Become the postgres user
- Invoke the createuser script with -p option. -p will issue a prompt for the password of the new user
- Enter a username for the new user. We are entering root here.
- When prompted grant the user superuser priviledges
1 2 3 4 5 6 7