Sha256: 956526148c924df72090978a39f59d36e552a76c7bc8467cd7a6689183d3abed

Contents?: true

Size: 1.95 KB

Versions: 6

Compression:

Stored size: 1.95 KB

Contents

# Hosted Postgres

Some hosted providers like Amazon RDS and Heroku do not support the HypoPG extension, which Dexter needs to run. Hopefully this will change with time. For now, we can spin up a separate database instance to run Dexter. It’s not super convenient, but can be useful to do from time to time.

### Install Postgres and Ruby

Linux

```sh
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt-get install -y wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y postgresql-9.6 postgresql-server-dev-9.6
sudo -u postgres createuser $(whoami) -s
sudo apt-get install -y ruby2.2 ruby2.2-dev
```

Mac

```sh
brew install postgresql
brew install ruby
```

### Install HypoPG and Dexter

HypoPG

```sh
cd /tmp
curl -L https://github.com/dalibo/hypopg/archive/1.0.0.tar.gz | tar xz
cd hypopg-1.0.0
make
make install # may need sudo
```

Dexter

```sh
gem install pgdexter # may need sudo
```

### Download logs

#### Amazon RDS

Create an IAM user with the policy below:

```
{
  "Statement": [
    {
      "Action": [
        "rds:DescribeDBLogFiles",
        "rds:DownloadDBLogFilePortion"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}
```

And run:

```sh
aws configure
gem install pghero_logs # may need sudo
pghero_logs download <instance-id>
```

#### Heroku

Production-tier databases only

```sh
heroku logs -p postgres > postgresql.log
```

### Dump and restore

We recommend creating a new instance from a snapshot for the dump to avoid affecting customers.

```sh
pg_dump -v -j 8 -Fd -f /tmp/newout.dir <connection-options>
```

Then shutdown the dump instance. Restore with:

```sh
createdb dexter_restore
pg_restore -v -j 8 -x -O --format=d -d dexter_restore /tmp/newout.dir/
```

### Run Dexter

```sh
dexter dexter_restore postgresql.log* --analyze
```

:tada:

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pgdexter-0.3.5 guides/Hosted-Postgres.md
pgdexter-0.3.4 guides/Hosted-Postgres.md
pgdexter-0.3.3 guides/Hosted-Postgres.md
pgdexter-0.3.2 guides/Hosted-Postgres.md
pgdexter-0.3.1 guides/Hosted-Postgres.md
pgdexter-0.3.0 guides/Hosted-Postgres.md