|
| 1 | + |
| 2 | +## Create an intermediary EC2 Ubuntu instance |
| 3 | +<Procedure> |
| 4 | + |
| 5 | +1. In [https://console.aws.amazon.com/rds/home#databases:][databases], |
| 6 | + select the RDS instance to migrate. |
| 7 | +1. Click `Actions` > `Set up EC2 connection`. |
| 8 | + Press `Create EC2 instance` and use the following settings: |
| 9 | + - **AMI**: Ubuntu Server. |
| 10 | + - **Key pair**: use an existing pair or create a new one that you will use to access the intermediary machine. |
| 11 | + - **VPC**: by default, this is the same as the database instance. |
| 12 | + - **Configure Storage**: adjust the volume to at least the size of RDS instance you are migrating from. |
| 13 | + You can reduce the space used by your data on Timescale Cloud using [data compression][data-compression]. |
| 14 | +1. Click `Lauch instance`. AWS creates your EC2 instance, then click `Connect to instance` > `SSH client`. |
| 15 | + Follow the instructions to create the connection to your intermediary EC2 instance. |
| 16 | + |
| 17 | +</Procedure> |
| 18 | + |
| 19 | +## Install the psql client tools on the intermediary instance |
| 20 | + |
| 21 | +<Procedure> |
| 22 | + |
| 23 | +1. Connect to your intermediary EC2 instance. For example: |
| 24 | + ```sh |
| 25 | + ssh -i "<key-pair>.pem" ubuntu@<EC2 instance's Public IPv4> |
| 26 | + ``` |
| 27 | +1. On your intermediary EC2 instance, install the PostgreSQL client. |
| 28 | + ```sh |
| 29 | + sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' |
| 30 | + wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null |
| 31 | + sudo apt update |
| 32 | + sudo apt install postgresql-client-16 -y # "postgresql-client-16" if your source DB is using PG 16. |
| 33 | + psql --version && pg_dump --version |
| 34 | + ``` |
| 35 | +
|
| 36 | + Keep this terminal open, you need it to connect to the RDS instance for migration. |
| 37 | +
|
| 38 | +</Procedure> |
| 39 | +
|
| 40 | +## Setup secure connectivity between your RDS and EC2 instances |
| 41 | +<Procedure> |
| 42 | +
|
| 43 | +1. In [https://console.aws.amazon.com/rds/home#databases:][databases], |
| 44 | + select the RDS instance to migrate. |
| 45 | +1. Scroll down to `Security group rules (1)` and select the `EC2 Security Group - Inbound` group. The |
| 46 | + `Security Groups (1)` window opens. Click the `Security group ID`, then click `Edit inbound rules` |
| 47 | +
|
| 48 | + <img class="main-content__illustration" |
| 49 | + src="https://assets.timescale.com/docs/images/migrate/rds-add-security-rule-to-ec2-instance.svg" |
| 50 | + alt="Create security group rule to enable RDS EC2 connection"/> |
| 51 | +
|
| 52 | +1. On your intermediary EC2 instance, get your local IP address: |
| 53 | + ```sh |
| 54 | + ec2metadata --local-ipv4 |
| 55 | + ``` |
| 56 | + Bear with me on this one, you need this IP address to enable access to your RDS instance, |
| 57 | +1. In `Edit inbound rules`, click `Add rule`, then create a `PostgreSQL`, `TCP` rule granting access |
| 58 | + to the local IP address for your EC2 instance (told you :-)). Then click `Save rules`. |
| 59 | +
|
| 60 | + <img class="main-content__illustration" |
| 61 | + src="https://assets.timescale.com/docs/images/migrate/rds-add-inbound-rule-for-ec2-instance.png" |
| 62 | + alt="Create security rule to enable RDS EC2 connection"/> |
| 63 | +
|
| 64 | +</Procedure> |
| 65 | +
|
| 66 | +## Test the connection between your RDS and EC2 instances |
| 67 | +<Procedure> |
| 68 | +
|
| 69 | +1. In [https://console.aws.amazon.com/rds/home#databases:][databases], |
| 70 | + select the RDS instance to migrate. |
| 71 | +1. On your intermediary EC2 instance, use the values of `Endpoint`, `Port`, `Master username`, and `DB name` |
| 72 | + to create the postgres connectivity string to the `SOURCE` variable. |
| 73 | + |
| 74 | + <img class="main-content__illustration" |
| 75 | + src="https://assets.timescale.com/docs/images/migrate/migrate-source-rds-instance.svg" |
| 76 | + alt="Record endpoint, port, VPC details"/> |
| 77 | +
|
| 78 | + ```sh |
| 79 | + export SOURCE="postgres://<Master username>:<Master password>@<Endpoint>:<Port>/<DB name>" |
| 80 | + ``` |
| 81 | + The value of `Master password` was supplied when this Postgres RDS instance was created. |
| 82 | +
|
| 83 | +1. Test your connection: |
| 84 | + ```sh |
| 85 | + psql -d $SOURCE |
| 86 | + ``` |
| 87 | + You are connected to your RDS instance from your intermediary EC2 instance. |
| 88 | +
|
| 89 | +</Procedure> |
| 90 | +
|
| 91 | +[about-hypertables]: /use-timescale/:currentVersion:/hypertables/about-hypertables/ |
| 92 | +[data-compression]: /use-timescale/:currentVersion:/compression/about-compression/ |
| 93 | +[databases]: https://console.aws.amazon.com/rds/home#databases: |
0 commit comments