Install PostgreSQL on CentOS
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Install PostgreSQL on CentOS

on

  • 1,701 views

How to install Postgresql 9.1 on CentOS 6.5. #

How to install Postgresql 9.1 on CentOS 6.5. #

Statistics

Views

Total Views
1,701
Views on SlideShare
1,586
Embed Views
115

Actions

Likes
2
Downloads
40
Comments
0

3 Embeds 115

http://www.slideee.com 57
http://rangsang.tumblr.com 46
http://www.tumblr.com 12

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Hello everyone. My name is Rangson Sangboonruang. This is, sort of, my second video I’ve ever posted to Youtube and I’m doing this to demonstrate one easy way to install PostgreSQL one of the most popular open source operating system, CentOS. Before we proceed I hope that you already have CentOS with X window installed on your machine. If not, please download it from available sources and get it installed.

Install PostgreSQL on CentOS Presentation Transcript

  • 1. Installation Rangson Sangboonruang rangson.sng@gmail.com 0
  • 2. 1 https://www.youtube.com/watch?v=yTsirtODBX8 You can find video demonstration on YouTube
  • 3.  Update repository  Creating a user group of sudoers  Putting sudogroup in sudoer file  Installing Postgresql  Starting Postgresql Server  Editing configuration files  Connecting from local computer  Connecting from other computers  Configuring the firewall Things to be covered Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 2
  • 4. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 It is assumed that you already had CentOS Installed. Let’s log on to CentOS. 3
  • 5. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Updating repository ls - Download pgdg-redhat91-9.1-5.noarch.rpm from this urlo – http://yum.pgrpms.org/9.1/redhat/rhel-6-x86_64/pgdg-redhat91-9.1-5.noarch.rpm 1 - Place the file in your preferred directory, e.g. /tmp. - Open Terminal window and go to /tmp. cd /tmp - List all the files in the directory to ensure that pgdg- redhat91-9.1-5.noarch.rpm is already there. - The screen shall display something like the following. 4
  • 6. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 - Try updating repository. rpm –Uvh pgdg-redhat91-9.1-5.noarch.rpm Explanation: You get this permission denied message because the user you are logging on is not a privileged user. You can log on using root but using root is not recommended because root is super powerful and accidental damage can potentially happen using root to perform admin tasks. On CentOS you can use sudo to obtain supper user privilege and the command will be like the following. sudo rpm –Uvh pgdg-redhat91-9.1-5.noarch.rpm 5
  • 7. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Explanation: You get this message because the user you are using is not listed in sudoers file. It is recommended that you create a group called sudogroup (or anything you like) and add the user you are using to this group and put the whole group in sudoer file. To do all these, follow the following steps. 6
  • 8. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Creating a user group of sudoers - From the menu bar choose System>Administration>Users and Groups and you’ll be prompted to enter root’s password. - For those you are familiar with Linux command line, you can ignore this and perform the geek stuff. 2 7
  • 9. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 - Now, you should see User Manager window. Click Add Group button and enter the group name then click OK. 8
  • 10. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 - Add your current user to “sudogroup” by choosing “Users” tab, click Properties button (as highlighted). You should see User Properties window. In the list box scroll to the “sudogroup” and have it checked. Do not forget to specify the Primary Group as “sudogroup”. 9
  • 11. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Putting sudogroup in sudoer file - Go back to Terminal window and type the following command. su root Explanation: “su” is used to switch user from one to another. Now you are root. This is because to edit sudoer file you need root’s privilege. Next command is as followed. visudo 3 10
  • 12. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Explanation: The Terminal window is now a text editor called “vi”. Now go through these steps - Locate the cursor to the line that looks like “root ALL=(ALL) ALL”. - Press “i” on your keyboard insert text. - Put “$sudogroup ALL=(ALL) ALL” underneath. - Press “esc” on your keyboard then type :wq - Press “Enter” Explanation: You have just exited the vi editor and are ready to proceed the next step by typing the following command. sudo rpm –Uvh pgdg-redhat91-9.1-5.noarch.rpm 11
  • 13. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Explanation: After running the previous command you should receive the response like the above. - Run the following command to list all available Postgresql packages. yum list postgresql* 12
  • 14. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Installing Postgresql Explanation: Among all the listed packages the highlighted one is what we are about to use for our installation. - Type the following command sudo yum install postgresql91-server.x86_64 4 13
  • 15. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Explanation: After running yum install you should see the screen like the above and you’ll be prompted to say y (for yes) or n (for no) to proceed downloading the package and finish the installation. - Type y for now and wait until the screen displays “Complete!” Explanation: Now you have done with the installation. Next, let’s move on to the next slide. 14
  • 16. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Starting Postgresql Server - Type the following command. sudo service postgresql-9.1 start Starting the server FAILED because you need to initialize the database first. So let’s do it by typing the following command. sudo service postgresql-9.1 initdb 5 15
  • 17. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 You are supposed to see the following screen. Now try starting the server again. This time you should see the following screen. 16
  • 18. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Editing configuration files - Type the following command to edit postgresql.conf sudo vi /var/lib/pgsql/9.1/data/postgresql.conf - Edit the file by changing these two lines: Uncomment by removing #, and Change from ‘localhost’ to ‘*’ Uncomment 6 17
  • 19. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 - Type the following command to edit pg_hba.conf sudo vi /var/lib/pgsql/9.1/data/pg_hba.conf - Edit the file by changing these two lines: Before After Insert new line Change from “indent” to “md5” The new line added contains the network address of you machine. This is to allow other computer to connect to your sever. 18
  • 20. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 - Type the following command to restart the server. sudo service postgresql-9.1 restart - If successful you should see the following. - Type the following command to test your server. sudo su postgres createdb test psql test Explanation: You should see this screen after running the command above. sudo su postgres => To switch to user postgres createdb test => To create a database called test psql test => To login to test database <<Successful screen>> 19
  • 21. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Connecting from local computer - Type the following command to crate a role for the database. CREATE ROLE testuser WITH SUPERUSER LOGIN PASSWORD ‘test’; - Type the following command to test the connection to the server. psql -h localhost –U testuser test - Type the following command to exit test database q <<Successful screen>> 7 20
  • 22. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Connecting from other computers Explanation: I used pgAdmin III to connect to the Postgresql Server. And, first, failed to connect saying the server was not listening on port 5432. Of cause, there is something you have to do with the server. 8 21
  • 23. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 Configuring the firewall (iptables) - Type the following command to exit test database q - Type the following command to exit from postgres exit <<Successful screen>> 9 22
  • 24. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 - Type the following command to edit iptables sudo vi /etc/sysconfig/iptables Insert this line (before –A INPUT –j Reject….). 23
  • 25. Installation of Postgresql on CentOS Postgresql Sever 9.1 and CentOS 6.5 - Type the following command to edit restart the firewall sudo service iptables restart <<Successful screen>> - Try connecting to the server from other computer again. This time you should be able to connect to the server. 24