amazonlinux / amazon-linux-2023

Amazon Linux 2023
https://aws.amazon.com/linux/amazon-linux-2023/
Other
508 stars 38 forks source link

[Package Request] - PostgreSQL 16 #516

Open sylr opened 9 months ago

sylr commented 9 months ago

What package is missing from Amazon Linux 2023? Please describe and include package name.

PostgreSQL 16

Is this an update to existing package or new package request?

New

Is this package available in Amazon Linux 2? If it is available via external sources such as EPEL, please specify.

Any additional information you'd like to include. (use-cases, etc)

GrahamCampbell commented 9 months ago

Would have to be the 2023.3 I think?

syampillai commented 6 months ago

When will this be available? I have migrated to RDS PostgreSQL 16.1 and now I can't do a pg_dump from my EC2 instance.

andrzej-talarek commented 5 months ago

Workaround for this would be temporarly using dockerized version of postgresql client to make a dump. Luckily it's available also for arm (including arm64).

syampillai commented 5 months ago

Yea, but I already installed Ubuntu on the EC2 for the time being.

julrodriguez commented 5 months ago

Is there an ETA on this? we have migrated some RDS database to PG16 and we cannot use pg_dump anymore; is there a workaround we can use in the mean time avaliable in AWS?

andrzej-talarek commented 5 months ago

I've wrote the workaround two comments earlier, did you miss this?

norbertbede commented 5 months ago

Hello @andrzej-talarek

i'm facing this issue after each upgrade of RDS. Since possible to apply workaround, but looks me really not practical to not taking care about this at AWS.

if i would take your suggestion then it will be temp from year 2013 since we are using RDS. :)

norbert

andrzej-talarek commented 5 months ago

Well, I don't argue with this - obviously it should be supported out-of-the-box by Amazon. But sine it's not... I didn't find any simpler solution to workaround this.

dmorehouse commented 4 months ago

It sucks that there's no compatible RPM package available for PostgreSQL 16. That said, you can easily build the PostgreSQL client binaries from source. This is what I'm doing as it performs much better than docker especially to just run psql, pg_dump, pg_restore on a small EC2 instance.

# Install the needed packages to build the client libraries from source
sudo yum install -y gcc readline-devel libicu-devel zlib-devel openssl-devel

# Download the source, you can browse the source code for other PostgreSQL versions (e.g. 16.2)
wget https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz  # PostgreSQL 16.1
tar -xvzf postgresql-16.1.tar.gz

cd postgresql-16.1

# Set bin dir so that executables are put in /usr/bin where psql and the others are installed by RPM
./configure --bindir=/usr/bin --with-openssl

sudo make -C src/bin install
sudo make -C src/include install
sudo make -C src/interfaces install
LimmaPaulus commented 4 months ago

Thanks @dmorehouse! Just to note that you have to run ./configure with --with-openssl flag if you want to use SSL-connections. That requires openssl-devel package to be installed.

`./configure --bindir=/usr/bin --with-openssl'

dmorehouse commented 4 months ago

Thanks @dmorehouse! Just to note that you have to run ./configure with --with-openssl flag if you want to use SSL-connections. That requires openssl-devel package to be installed.

`./configure --bindir=/usr/bin --with-openssl'

Thanks for pointing that out. I wasn't using SSL for my connections (everything is within a private VPC) but that does not mean other people won't want secure connections. I've updated my instructions to include SSL support.

FrederikNygaardSvendsen commented 3 months ago

It sucks that there's no compatible RPM package available for PostgreSQL 16. That said, you can easily build the PostgreSQL client binaries from source. This is what I'm doing as it performs much better than docker especially to just run psql, pg_dump, pg_restore on a small EC2 instance.

# Install the needed packages to build the client libraries from source
sudo yum install -y gcc readline-devel libicu-devel zlib-devel openssl-devel

# Download the source, you can browse the source code for other PostgreSQL versions (e.g. 16.2)
wget https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz  # PostgreSQL 16.1
tar -xvzf postgresql-16.1.tar.gz

cd postgresql-16.1

# Set bin dir so that executables are put in /usr/bin where psql and the others are installed by RPM
./configure --bindir=/usr/bin --with-openssl

sudo make -C src/bin install
sudo make -C src/include install
sudo make -C src/interfaces install

@dmorehouse You just saved my day :-)

sylr commented 3 months ago

I'd suggest to add systemd to the configure config:

yum install systemd-devel
./configure --with-systemd --with-openssl
ritzk commented 2 months ago

I'd suggest to add systemd to the configure config:

yum install systemd-devel
./configure --with-systemd --with-openssl

I would recommend grabbing srpm from https://kojipkgs.fedoraproject.org/packages/postgresql16/, and building it inside amazon linux 2023 container as a user.

rpm -ivh <package>
sudo dnf install -y rpm-build
sudo dnf builddep -y rpmbuild/SPECS/postgresql16.spec
sed  's/%patch /%patch/g' rpmbuild/SPECS/postgresql16.spec
rpmbuild -bb  rpmbuild/SPECS/postgresql.spec
terranova-joseph commented 2 months ago

@dmorehouse THANK YOU!!!

shorn commented 2 months ago

I just needed a container that I could do a few pg client commands from to work with RDS.
I thought AL2023 would be the best distro choice since it's the most modern Amazon-supplied distro. I figured it might not have great support for other non-amazon things, but would be well-supported for AWS stuff.

Eight months later, my workaround is to mix in the binaries from the official postgres image during the build.


Here are the relevant commands from my multi-stage docker build:

FROM public.ecr.aws/docker/library/postgres:16 as pg-client
FROM public.ecr.aws/amazonlinux/amazonlinux:2023

RUN dnf update -y \
  && dnf install -y libpq \
  && dnf clean all

COPY --from=pg-client /usr/lib/postgresql/16 /usr/lib/postgresql/16
ENV LD_LIBRARY_PATH="/usr/lib/postgresql/16/lib:${LD_LIBRARY_PATH}"
ENV PATH="/usr/lib/postgresql/16/bin:${PATH}"

Note that this assumes you're using these tools via the PATH. i.e. psql blah blah blah

If your usage of the tools has hardcoded absolute paths like /usr/bin/psql, you either need to alter those references to use the path, or use /usr/lib/postgresql/16/bin/psql blah blah blah, or you can add the symbolic links to the /usr/bin directory or something.

jensenbox commented 1 week ago

Seems a bit odd that this would not make it in to AL2023 rapidly. Is AL2023 even maintained? I am scared to think that AL2024 will have all these problems all over again.