Search code examples
postgresqlamazon-web-servicespostgresql-13amazon-linuxamazon-linux-2

AWS EC2 Amazon Linux 2 AMI Starting PostgreSQL


Have an AWS EC2 instance which is running Amazon Linux AMI 2. Installed PostgreSQL using

 sudo amazon-linux-extras install postgresql13 

Now, how to start it and configure it?

I can see Package postgresql-13.3-2.amzn2.0.1.aarch64 already installed...


Solution

  • The command

    sudo amazon-linux-extras install postgresql13 
    

    installs only the client. This is not server. You still have to setup server separately apart from the client yourself.

    Thus, to install postgresql 13, you have install the client (if you haven't done so yet). It is needed as Amazon Linux 2 will install matching server (v13), not default version 9.

    sudo amazon-linux-extras install postgresql13 
    

    and now install server (this should install v13, as it matches your client):

    sudo yum install postgresql-server
    

    now you enable it:

    sudo systemctl enable postgresql
    

    initialize it:

    sudo /usr/bin/postgresql-setup --initdb
    

    start it:

    sudo systemctl start postgresql
    

    and finally check its status:

    sudo systemctl status postgresql