Skip to content

Commit c8ddb4f

Browse files
authored
Merge pull request #6068 from EnterpriseDB/release-2024-09-18a
Release 2024-09-18a
2 parents f52b8c1 + 0088850 commit c8ddb4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1220
-567
lines changed
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
---
2+
title: Installing PostgreSQL in a Docker container on your local machine
3+
navTitle: Docker
4+
description: Learn how to install PostgreSQL in a Docker container on your local machine for development purposes.
5+
deepToC: true
6+
---
7+
8+
## Prerequisites
9+
10+
* Docker-compatible OS (macOS, Windows, Linux)
11+
12+
Using Docker for your local PostgreSQL development environment streamlines setup, ensures consistency, and simplifies management. It provides a flexible, isolated, and portable solution that can adapt to various development needs and workflows.
13+
14+
## Preparing Docker
15+
16+
### Install Docker:
17+
18+
Make sure Docker is installed on your machine or download and install it from [Docker’s official website](https://www.docker.com/products/docker-desktop/).
19+
20+
* macOS: Download and install Docker Desktop from Docker’s official website.
21+
* Windows: Download and install Docker Desktop from Docker’s official website. Ensure WSL 2 is enabled if using Windows 10 or later.
22+
* Linux: Install Docker using your distribution’s package manager. For example, on Ubuntu:
23+
24+
```
25+
sudo apt update
26+
sudo apt install docker.io
27+
sudo systemctl start docker
28+
sudo systemctl enable docker
29+
sudo usermod -ag docker $USER
30+
newgrp docker
31+
```
32+
33+
34+
### Pull the PostgreSQL Docker image:
35+
36+
Open a terminal or command prompt and run the following command to pull the latest PostgreSQL image from Docker Hub:
37+
38+
```
39+
docker pull postgres
40+
```
41+
42+
## Running the PostgreSQL container
43+
44+
Run a new container with the PostgreSQL image using the following command:
45+
46+
```
47+
docker run --name my_postgres -d postgres -e POSTGRES_PASSWORD=mysecretpassword -v my_pgdata:/var/lib/postgresql/data -p 5432:5432
48+
```
49+
50+
#### `--name my_postgres`
51+
52+
The `--name` flag tells docker to creates a new container named `my_postgres`.
53+
54+
#### `-d`
55+
56+
The `-d` flag tells Docker to run the container in detached mode. This means the container runs in the background and does not block the terminal.
57+
58+
#### `postgres`
59+
60+
This is the name of the image to run. Docker uses this name to pull the image from Docker Hub if it is not already present on the local machine. Note that if we had not pulled it, this command would automatically pull the PostgreSQL image.
61+
62+
#### `-e POSTGRES_PASSWORD=mysecretpassword`
63+
64+
The `-e` flag sets an environment variable `POSTGRES_PASSWORD` to `mysecretpassword`. This is used the password for the default `postgres` user. You should use a different password.
65+
66+
#### `-v my_pgdata:/var/lib/postgresql/data`
67+
Docker uses volumes to persist data in Docker containers. This flag mounts a volume named `my_pgdata` to persist data.
68+
The data in this case is whatever Postgres writes to the `/var/lib/postgresql/data` directory within the container.
69+
These writes are persisted outside the container in a docker volume; the command `docker volume inspect my_pgdata` will show you information about that volume.
70+
71+
#### `-p 5432:5432`
72+
73+
The `-p` flag maps the container’s port 5432 to the host machine’s port 5432. Port 5432 is Postgres's default port for communications. By using this flag, it allows you to access the PostgreSQL database from your host machine.
74+
75+
## Verifying the container is running
76+
77+
To verify that the container is running, use the following command:
78+
79+
```
80+
docker ps
81+
```
82+
83+
This command lists all running containers. You should see the `my_postgres` container listed.
84+
85+
You now have a persistent, locally accessible Postgres database running in a Docker container.
86+
You can now start using it.
87+
88+
## Access PostgreSQL with a client
89+
90+
To access the PostgreSQL database, without any additional tools, you can use the following command to open a PostgreSQL prompt:
91+
92+
```
93+
docker exec \-it my\_postgres psql \-U postgres
94+
```
95+
96+
This logs into the Docker container and runs the `psql` command as the `postgres` user from there.
97+
98+
The `psql` command is a powerful tool for interacting with PostgreSQL databases. You should install it on your local machine to interact with the PostgreSQL database running in the Docker container.
99+
100+
### macOS
101+
102+
You can install the PostgreSQL client using Homebrew:
103+
104+
```
105+
brew install libpq
106+
```
107+
108+
### Windows
109+
110+
Download the PostgreSQL client from the [official website](https://www.enterprisedb.com/downloads/postgres-postgresql-downloads).
111+
112+
### Linux
113+
114+
Use your distribution’s package manager to install the PostgreSQL client. For example, on Ubuntu:
115+
116+
```
117+
sudo apt-get install postgresql-client
118+
```
119+
120+
## Connecting other apps
121+
122+
You can also connect other applications to the PostgreSQL database running in the Docker container. You need to provide the following connection details:
123+
124+
* Host: `localhost`
125+
* Port: `5432`
126+
* Username: `postgres`
127+
* Password: (whatever you set it to)
128+
* Database: `postgres`
129+
130+
Or use the connection string:
131+
132+
```
133+
postgresql://postgres:mysecretpassword@localhost:5432/postgres
134+
```
135+
136+
## Verifying data persistence
137+
138+
1. Create a table and insert data.
139+
Access the PostgreSQL instance and run the following SQL commands to create a table with columns and insert some data:
140+
141+
```sql
142+
CREATE TABLE employees (
143+
id SERIAL PRIMARY KEY,
144+
first_name VARCHAR(50),
145+
last_name VARCHAR(50),
146+
email VARCHAR(100),
147+
hire_date DATE
148+
);
149+
INSERT INTO employees (first_name, last_name, email, hire_date) VALUES
150+
('John', 'Doe','[email protected]', '2020-01-15'),
151+
('Jane', 'Smith', '[email protected]', '2019-03-22');
152+
```
153+
154+
2. Stop and completely remove the container.
155+
```
156+
docker stop my_postgres
157+
docker rm my_postgres
158+
```
159+
160+
3. Recreate the container with the same volume.
161+
162+
```
163+
docker run --name my_postgres -d postgres -e POSTGRES_PASSWORD=mysecretpassword -v my_pgdata:/var/lib/postgresql/data -p 5432:5432
164+
```
165+
166+
4. Verify Data Persistence.
167+
Access the PostgreSQL instance and check if the data still exists:
168+
169+
```sql
170+
SELECT * FROM employees
171+
```
172+
173+
If everything worked as expected, you should see the employee table with the data previously loaded still present.
174+
175+
176+
## Stopping and removing the container
177+
178+
To stop and remove the container, use the following commands:
179+
180+
```
181+
docker stop my_postgres
182+
docker rm my_postgres
183+
```
184+
185+
## Deleting the volume
186+
187+
To remove the volume containing the database, use the following command (after stopping and removing the container):
188+
189+
```
190+
docker volume rm my_pgdata
191+
```
192+
193+
## Conclusion
194+
195+
By following these steps, you have set up a robust local development environment for PostgreSQL using Docker. This setup ensures data persistence and provides a flexible, isolated, and consistent environment for all of your development needs.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Deploying Postgres for developers
3+
navTitle: Deploying for developers
4+
description: How to deploy Postgres for developers.
5+
---
6+
7+

advocacy_docs/dev-guides/index.mdx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: The EDB Postgres AI Developer Guides
3+
navTitle: Developer Guides
4+
description: The EDB Postgres AI Developer Guides provide information on how to use the EDB Postgres AI platform to build and develop Postgres and AI applications.
5+
deepToC: true
6+
directoryDefaults:
7+
iconName: "CodeWriting"
8+
indexCards: simple
9+
prevNext: true
10+
navigation:
11+
- deploy
12+
- working
13+
---
14+
15+
The EDB Postgres AI Developer Guides are all about providing you, the developer, with the information you need to accelerate your development efforts using the EDB Postgres AI platform. The guides cover a wide range of topics, from setting up your development environment to deploying Postgres and AI applications.
16+
17+
## Deploying Postgres Locally for developers
18+
19+
* [Deploying Postgres Using Docker Locally](deploy/docker)
20+
21+
## Working with Postgres
22+
23+
* [PSQL for busy developers](working/psql-for-busy-developers)
24+
25+
<!-- ## Developing Postgres Applications
26+
27+
* [Developing Postgres Applications with Python](developing/developing-postgres-applications-with-python)
28+
-->
29+
30+
31+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Working with Postgres tools - guides for developers
3+
navTitle: Working with tools
4+
description: How to work with a range of Postgres tools, with a focus on developers and debugging.
5+
---
6+
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
title: PSQL for busy developers
3+
navTitle: PSQL for developers
4+
description: How to use PSQL for common developer tasks
5+
---
6+
7+
The PSQL command line tool is essential in a developer's toolkit as it provides full command-line access to PostgreSQL databases.
8+
9+
## Getting psql installed
10+
11+
The `psql` command is a powerful tool for interacting with PostgreSQL databases. You should install it on your local machine to interact with the PostgreSQL database. Unless you've just installed Postgres natively on your machine, you'll need to install the `psql` client.
12+
13+
### macOS:
14+
15+
You can install the PostgreSQL client using [Homebrew](brew.sh):
16+
17+
```
18+
brew install libpq
19+
```
20+
21+
### Windows:
22+
23+
Download the PostgreSQL client from the [official website](https://www.enterprisedb.com/downloads/postgres-postgresql-downloads).
24+
25+
### Linux:
26+
27+
Use your distribution’s package manager to install the PostgreSQL client. For example, on Ubuntu:
28+
29+
```
30+
sudo apt-get install postgresql-client
31+
```
32+
33+
## Connecting to a database
34+
35+
### Connection strings
36+
37+
The `psql` client can use a connection string to connect to a database. The connection string is a single string that contains all the information needed to connect to a database.
38+
39+
!!! tip
40+
Always wrap your connection string in single quotes to avoid the shell interpreting any special characters.
41+
!!!
42+
43+
### PGPASSWORD environment variable
44+
45+
Best practice is to not have your password in your connection string or in your command history. Instead, you can use the `PGPASSWORD` environment variable to store your Postgres password. This is simple, but not very secure because some Unix systems allow other users to see the environment variables of other users.
46+
47+
### .pgpass file
48+
49+
Creating a .pgpass file is a more secure way to store your password. The .pgpass file is a plain text file that contains the connection information for your databases. The file should be stored in your home directory and should be readable only by you. The file should have the following format:
50+
51+
```
52+
hostname:port:database:username:password
53+
```
54+
55+
Hostname, port, database and username can all be set to wildcards to match any value. For example, `*:*:*:postgres:password` would match any database on any host for the user `postgres`.
56+
57+
Read more about the .pgpass file in the [Postgres documentation](https://www.postgresql.org/docs/current/libpq-pgpass.html).
58+
59+
## The PSQL command line
60+
61+
You can enter SQL commands directly into the PSQL command line. Be sure to end each command with a semicolon, otherwise PSQL doesn't execute the command.
62+
63+
You can use tab-completion in many situations to help you complete commands and table names. Pressing tab at the start of a line will show you a list of available SQL commands.
64+
65+
PSQL also has a number of built-in commands that can help you manage your databases and tables.
66+
67+
68+
| Command | Description |
69+
|-----------------|----------------------------------------------------------|
70+
| `\l` | List all databases |
71+
| `\c` | Connect to a database |
72+
| `\d` | List tables, sequences and views in the current database |
73+
| `\d table_name` | Describe a table |
74+
| `\watch seconds` | Re-run a query every `seconds` |
75+
| `\q` | Quit PSQL |
76+
77+
`\d` is a very useful command that shows a range of different information when followed by another character. Think of it as `d` for display. For example, `\dt` shows all the tables in the current database, `\dv` shows all the views, and `\ds` shows all the sequences.
78+
79+
`\watch` is useful when you want to repeat running a query at regular intervals. For example, you could use `\watch 5` to run a query every 5 seconds. The query that will be re-run is the last query you entered.
80+
81+
82+
83+

advocacy_docs/edb-postgres-ai/cloud-service/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The EDB Postgres® AI Cloud Service is a holistic platform which includes hybrid
2020

2121
The EDB Postgres AI Cloud Service itself is a fully managed cloud service that provides a high-performance, scalable, and secure database platform for analytics, AI, and machine learning workloads. It also provides the platform for [EDB Postgres AI Analytics](../analytics/) and [EDB Postgres AI Machine Learning](../ai-ml/) services.
2222

23-
Cloud Service builds on the [EDB Postgres Advanced Server](../databases/epas) and [EDB Postgres Extended](../databases/pge) databases and it's designed to help organizations accelerate the development and deployment of AI and machine learning applications.
23+
Cloud Service builds on the [EDB Postgres Advanced Server](/epas/latest) and [EDB Postgres Extended](/pge/latest) databases and it's designed to help organizations accelerate the development and deployment of AI and machine learning applications.
2424

2525
Databases in the EDB Postgres AI Cloud Service can run on EDB's own cloud accounts or managed by EDB on your own cloud on your behalf.
2626

advocacy_docs/edb-postgres-ai/cloud-service/managing_your_cluster/backup_and_restore.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: "Backing up and restoring"
3+
description: "Learn how to back up and restore your EDB Postgres AI clusters."
34
deepToC: true
45
---
56

advocacy_docs/edb-postgres-ai/cloud-service/managing_your_cluster/deleting_your_cluster.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: "Deleting your cluster"
3+
description: "How to delete and restore your EDB Postgres AI clusters."
34
---
45

56
If you no longer need a particular cluster, you can delete it from the Console. You can restore deleted clusters after you delete the cluster for as long as the backup is available. The backup remains available for the retention period set for each cluster. After the retention period, the backup is deleted.

advocacy_docs/edb-postgres-ai/cloud-service/managing_your_cluster/managing_cluster.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Pausing and resuming a cluster"
3-
description: Describes options for managing clusters
3+
description: "Pause and resume an EDB Postgres AI cluster to save on compute costs."
44
---
55

66
## Pausing and resuming clusters

advocacy_docs/edb-postgres-ai/cloud-service/managing_your_cluster/migration/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Migrating databases to Cloud Service
3+
description: Techniques and tools to migrate your databases to EDB Postgres AI Cloud Service.
34
---
45

56
EDB provides migration tools to bring data from Oracle, PostgresSQL, and EDB Postgres Advanced Server databases into Cloud Service. These tools include Migration Portal and Migration Toolkit for Oracle migrations. More sophisticated migration processes can use tools such as [Replication Server](/eprs/latest/) for ongoing migrations and [LiveCompare](/livecompare/latest/) for data comparisons.

advocacy_docs/edb-postgres-ai/cloud-service/managing_your_cluster/modifying_your_cluster/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Modifying your cluster
3+
description: How to modify your EDB Postgres AI cluster's configuration settings.
34
# Added this redirect because we removed the Modify and Scale topic
45
redirects:
56
- ../03_modify_and_scale_cluster

advocacy_docs/edb-postgres-ai/cloud-service/managing_your_cluster/periodic_maintenance.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Periodic maintenance
3+
description: Find out when periodic maintenance is performed on your EDB Postgres AI clusters.
34
---
45

56
EDB performs periodic maintenance to ensure stability and security of your clusters. We perform minor version upgrades and patch updates as part of this periodic maintenance.

advocacy_docs/edb-postgres-ai/cloud-service/managing_your_cluster/upgrading_your_cluster.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Performing a major version upgrade of Postgres on Cloud Service
3-
navTitle: Upgrading Postgres major versions
3+
description: Upgrading Postgres major versions when your cluster is running on EDB Postgres AI Cloud Service.
44
deepToC: true
55
---
66

0 commit comments

Comments
 (0)