Configuring PostgreSQL on CentOS

30 minutes
  • 4 Learning Objectives

About this Hands-on Lab

PostgreSQL is the world’s most advanced open source database. Its stability, functionality, and extensibility make it a primary choice for an RDBMS solution. In this hands-on lab scenario you are the DBA for Awesome Company. You have been tasked with building a PostgreSQL database backend to facilitate the development of a new web application. You have already installed the database software and are now ready to configure it to your company’s standards. Performing the configuration tasks of this lab will help you become acquainted with administering permissions via roles, enabling remote connections, and setting server-level options.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Administer Permissions via Roles
  1. Change to the postgres user and launch psql.
  2. Give the postgres role a password (enter and confirm).
  3. Create a database for the web application.
  4. Connect to the new database.
  5. Create a role for the web application.
  6. Give the acwebapp role a password (enter and confirm).
Enable Remote Connections
  1. Exit back to cloud_user, and edit postgresql.conf to listen on any address.
  2. Search for listen_addresses, uncomment it, and set it to *. Save and quit.
  3. Edit pg_hba.conf file.
  4. Append a line to the bottom of the file that will enable remote connections.
  5. Save and exit.
  6. Restart the PostgreSQL service.
Set Server-Level Options
  1. Edit the postgresql.conf file.
  2. Find the port setting under CONNECTIONS AND AUTHENTICATION, uncomment it, and change the value to 1433.
  3. Below that, change max_connections to 500.
  4. Find the shared_buffers setting under - Memory - and change the value to 256MB.
  5. Save and exit, then restart the PostgreSQL service.
Test Changes
  1. Using an external client of your choosing, connect to the acweb database as acwebapp. (For the purposes of this example we will use pgAdmin, found at
  2. Right-click Servers, go to Create, and click on Server.
  3. Provide a name for the server connection.
  4. On the Connection tab, enter the following information:
    • Hostname/address: The public IP address of your lab server
    • Port: 1433
    • Username: acwebapp
    • Password: The password you set for acwebapp earlier
  5. Click Save.
  6. If it connects, you have successfully enabled remote connections and provisioned a role for the web application.
  7. Right-click on a database and click Query Tool. Verify values for all the settings that were changed.

Additional Resources

In this hands-on lab scenario, you are the DBA for Awesome Company. You have been tasked with configuring a PostgreSQL database server to facilitate the development of a new web application. This will be accomplished by:

  • Administering permissions via roles:
    • Secure the postgres role and create a new role named acwebapp for a new database named acweb.
  • Enabling remote connections:
    • Set the server to listen on all addresses and accept password authentication on them.
  • Setting server-level options:
    • Set the port to 1433, max connections to 500, and shared buffers to 256mb.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?