21

I am trying to install postgresql for the meta data of hive on Amazon EC2 Linux machine. And at that point, I am trying to connect postgresql outside docker image. Inside, I can connect the postgresql.

I tried this command:

[ec2-user@ip-****-***-** ~]$ sudo yum install postgresql-client -y

and the result:

Failed to set locale, defaulting to C
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                                                                                                                               | 3.7 kB  00:00:00     
No package postgresql-client available.
Error: Nothing to do

To ensure locale, I tried these ones:

[ec2-user@ip-***-***-*** ~]$ echo "$LANG"
en_US.UTF-8
[ec2-user@ip-***-***-*** ~]$ echo "$LC_CTYPE"
UTF-8

Then, I tried this one install postgresql-client lastly:

[ec2-user@ip-***-***-*** ~]$ sudo amazon-linux-extras install postgresql-client
Topic postgresql-client is not found.

I am not so familiar with these technologies, if you can help I will be so appreciated

5
  • Which AMI are you using? Commented May 19, 2022 at 15:26
  • 2
    sudo yum install postgresql96. Amazon linux and RHEL do not split the client into a separate package. Commented May 19, 2022 at 15:31
  • My AMI is amzn2-ami-kernel-5.10-hvm-2.0.20220316.0-x86_64-gp2 Commented May 19, 2022 at 15:36
  • @jordanm, when I wrote this command I took the same error :( Failed to set locale, defaulting to C Loaded plugins: extras_suggestions, langpacks, priorities, update-motd amzn2-core | 3.7 kB 00:00:00 No package postgresql96 available Commented May 19, 2022 at 21:01
  • 2
    sudo yum install postgresql should install the latest amzn2 supported psql client. Commented May 20, 2022 at 0:53

6 Answers 6

31

If you get the error...

No match for argument: postgresql ...

I found that AWS Linux is a dynamic changing OS, so here is the current method + how to detect a new way to do this...

Current method (as of Oct 21, 2022)

(I have Machine Image (AMI): Amazon Linux 2022)

$ sudo yum update 
$ sudo yum install postgresql13
$ psql --version
psql (PostgreSQL) 13.5

Future proof answer

Try this first ...

$ sudo yum update
$ sudo yum search "postgres"

... and look in the output for a line like this: postgresql13.aarch64 : PostgreSQL client programs. This tells you the current version of an installable client package name - in this case postgresql13. Now you know which package to install and avoid: No match for argument: postgresql error.

TLDR;

It seems, for Linux that Amazon now says to use yum directly vs. the old amazon-linux-extras here... Install software packages on an Amazon Linux instance. Then you wonder, how to know which package name to use to install it, which is here: Find software packages on an Amazon Linux instance. I used a small part of the name as a 'key' to search for: sudo yum search "postgres" which got me the answer, by looking at the output.

This currently works for my version of Amazon linux:

$ uname -a
Linux ip-0-0-0-0.ec2.internal 5.15.43-20.123.amzn2022.aarch64 #1 SMP Thu May 26 17:03:36 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

This is a new instance with almost nothing added, not even additional yum archives, YMMV.

Sign up to request clarification or add additional context in comments.

2 Comments

Do you mean "Amazon Linux 2023"? As far as I know there's only AL2 and AL2023.
Note that AL2023 uses DNF instead of YUM, although YUM does still work. Read all about it.
17

Adding to James' answer, the complete list of Amazon Linux packages is also published to the respective distro Release Notes which you can search online.

E.g.: for Amazon Linux 2023:

https://docs.aws.amazon.com/linux/al2023/release-notes/all-packages.html

Here I was able to find postgresql15 and other package directly in the web.

So I'm my case this did the trick for me: sudo yum -y install postgresql15

enter image description here

There's also a comparison section with previous distros which will show new packages, removed packages, and updated packages.

enter image description here

2 Comments

Note that, according to the docs, AL2023 uses dnf as the default package manager, although the yum command does still work.
SO is STILL better than chatGPT... thanks.
9

For my case, the original Amazon Linux 2 AMI was modified (hardening) to follow the organization security checklist. So non of the above approach work for me.
The approach that works for me is install the postgresql by Amazon Linux Extra repository

sh-4.2$ sudo amazon-linux-extras install postgresql14
<....>
sh-4.2$ psql --version
psql (PostgreSQL) 14.8

Reference
FAQ - Amazon Linux Extras
Amazon Linux Extra repository

3 Comments

Perfect. Thank you! $ amazon-linux-extras list shows all available packages
Jun 2024, this works for me, I needed to update to postgresql13 and the other solutions didn't work for me.
One can use amazon-linux-extras | grep -i postgre to check the available postgres versions.
7

As of September 2024, for Amazon Linux 2023, the following command installs Postgresql 15 client programs:

sudo dnf install postgresql15

2 Comments

dnf install postgresql16 also works as of Jan 2025 (Amazon Linux 2023). DOES NOT WORK on Amazon Linux 2, which only has older Postgres versions (up to 9) in the catalog.
Also valid for dnf install postgresql17
5

Install postgresql package

sudo yum install postgresql

As mentioned by @Anon Coward in comments, this package contains the postgresql client. Check it with

yum search postgresql

4 Comments

Not working: Error: Unable to find a match: postgresql
@EvandroPomatti did you test yum search?
this failed sudo yum install postgresql, but I understood why now.
why did it fail?
2

as of today - i was able to find version 15 of postgressql in linux ec2 so run as below

sudo yum install postgresql15

This will avoid error Error: Unable to find a match: postgresql14

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.