The process of installing PostgreSQL 9 could be described in several steps. After successfull installing it will be possible to connect to the database with pgAdmin tool for further configuration.
Change the root password and login as root
1. Initiate SSH session (as 'ec2-user') and connect to the Amazon Linux instance by it public DNS name.2. Change the root password:
sudo passwd root
3. Login as root: su root
Install PostgreSQL 9
1. Create new user postgres: useradd postgres
2. Set the postgres password: passwd postgres
3. Install PostgreSQL 9 server: yum install postgresql90 postgresql90-contrib postgresql90-devel postgresql90-server
4. Set owner permissions: chown -hR postgres:postgres /var/lib/pgsql
5. Initialize data base: service postgresql-9.0 initdb
6. Start/Stop/Restart PostgreSQL 9 as a service.start:
service postgresql-9.0 start
stop: service postgresql-9.0 stop
restart: service postgresql-9.0 restart
7. Add PostgreSQL 9 service to the autostart: chkconfig postgresql-9.0 on
The default path of PostgreSQL 9 is: /var/lib/pgsqlUpdate PostgreSQL 9 configuration files
1. Add 5432 port to the security group associated with Amazon Linux instance using AWS Management Console.2. Update /var/lib/pgsql/9.0/data/pg_hba.conf configuration file (the bottom of the file) to read:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::1/128 ident
3. Update /var/lib/pgsql/9.0/data/postgresql.conf configuration file to read: listen_addresses = '*'
port = 5432
Connect with pgAdmin
1. Download and install latest version of pgAdmin from the official site.2. Add new connection to the database server.
3. Fill the New Server Registration form (for the Host name use Public DNS name of Amazon Linux instance) and press OK button.
4. New server appeared in the Object browser section.
You shouldn't use trust METHOD for every connection because anyone can access PostgreSQL with any password.
ReplyDeletePersonally, I'm using such configuration in pg_hba.conf file:
local all postgres md5
host all postgres 0.0.0.0/0 md5
Thanks for the very helpful tutorial!
ReplyDeleteI found that the package names and directory paths were slightly different, but otherwise this is the best PostgreSQL on AWS tutorial that I found.
i.e.
"yum install postgresql9"
instead of
"yum install postgresql90"
and
"/var/lib/pgsql9/data/pg_hba.conf"
instead of
"/var/lib/pgsql/9.0/data/pg_hba.conf"
Not so far I have found new cool tool to work with postgresql on linux – Valentina Studio. Its free edition can do things more than many commercial tools!!
ReplyDeleteI very recommend check it. http://www.valentina-db.com/en/valentina-studio-overview
Cant thank you enough for this post. I would have been scrambling for changes to get things working, had I not found this. Agree with the edits proposed by 'MNuthsch' above. Once you get those edits in place, everything works like breeze. Thank you!
ReplyDeleteYou seriously open 5432 to the world?
ReplyDeleteThank you for the facts. i found your weblog very exciting ,our oracle hcm on-line education provider gained the immoderate common call via international for its schooling.
ReplyDeleteOracle fusion all modules training
oracle fusion training in Hyderabad
very informative post, AWS Course In Pune
ReplyDeleteGreat Blog.
ReplyDeleteLinux course in Pune