Can't install Postgres 9 on stock Bamboo AMI
Asked by Dan Fabulich:

The stock Bamboo AMI ami-e4399e8d is running Amazon Linux 2011.09; when I run yum install postgresql I get Postgres 8.4.

But my build requires Postgres 9, which isn't available except in Amazon Linux 2012.03. According to the Amazon Linux documentation <http://aws.amazon.com/amazon-linux-ami/2012.03-release-notes/> I should be able to run yum update to upgrade to 2012.03, but when I do that on the Bamboo AMI it doesn't do anything.

How can I upgrade to Postgres 9 from a stock Bamboo AMI?


Answers:
author: Dan Fabulich
body: Lucas' answer got me on the right track. I did need to add a new yum repo, but it wouldn't work out of the box. This article explains what you need to do: <http://blog.henrygis.com/2011/04/installing-postgresql-84-postgis-and.html>

Running rpm -i <http://yum.postgresql.org/9.1/redhat/rhel-6-x86_64/pgdg-redhat91-9.1-5.noarch.rpm> installs a pgdg-91-redhat.repo file in /etc/yum.repos.d

The problem is that the file contains "$releasever" variables that insert the Amazon Linux version, e.g. "2011.09" instead of a valid RHEL version, e.g. "6.0".

This one-liner fixes the problem:

```
perl -pi -e 's/\$releasever/6.0/g' /etc/yum.repos.d/pgdg-91-redhat.repo
```


author: LucasA
body: Hello Dan,

You can configure a new yum repo:

rpm -i <http://yum.postgresql.org/9.0/redhat/rhel-6-i386/pgdg-redhat90-9.0-5.noarch.rpm>

Them install the required package:

```
yum install postgresql91-server postgresql91-contrib
```

```

```

```
Start the service:
```

```
service postgresql-9.1 initdb
```

```

```

```
For more info:
```

```

```

```
http://www.postgresql.org/download/linux/redhat/
```

```

```

```
Lucas Lima
```

```
Atlassian Support
```

comments: author: Dan Fabulich
body: That doesn't work, either when I use the URL you provided or when I grab the RHEL6 URL from here: <http://yum.postgresql.org/repopackages.php>

\[ec2-user@ip-10-123-9-232 \~\]$ sudo rpm -i <http://yum.postgresql.org/9.0/redhat/rhel-6-i386/pgdg-redhat90-9.0-5.noarch.rpm>

warning: /var/tmp/rpm-tmp.pmp1FA: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY

\[ec2-user@ip-10-123-9-232 \~\]$ sudo yum install postgresql91-server postgresql91-contrib

Loaded plugins: fastestmirror, priorities, security, update-motd

Loading mirror speeds from cached hostfile

\* amzn-main: [packages.us-east-1.amazonaws.com](http://packages.us-east-1.amazonaws.com)

\* amzn-updates: [packages.us-east-1.amazonaws.com](http://packages.us-east-1.amazonaws.com)

amzn-main \| 2.1 kB 00:00

amzn-updates \| 2.3 kB 00:00

<http://yum.postgresql.org/9.0/redhat/rhel-2011.09-x86_64/repodata/repomd.xml:> \[Errno 14\] PYCURL ERROR 22 - "The requested URL returned error: 404"

Trying other mirror.

Error: Cannot retrieve repository metadata (repomd.xml) for repository: pgdg90. Please verify its path and try again

\[ec2-user@ip-10-123-9-232 \~\]$

The problem is that it knows it's running Amazon Linux 2011.09, and finds that it doesn't have a copy of Postgres for that version of Amazon Linux. (If I could just upgrade the box to Amazon Linux 2012.03, this would be trivial!)


author: Dan Fabulich
body: Since this question didn't get a good answer, I've posed a separate but more specific question here: https://answers.atlassian.com/questions/80482/upgrade-bamboo-ami-to-amazon-linux-2012-03