Skip to content

Commit 1199cfe

Browse files
committed
Added the note
1 parent 94d65b1 commit 1199cfe

File tree

2 files changed

+36
-28
lines changed

2 files changed

+36
-28
lines changed

ydb/docs/en/core/postgresql/import.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Dump data form PostgreSQL
22

3+
{% include [./_includes/alert.md](./_includes/alert_preview.md) %}
4+
35
Data from PostgreSQL can be migrated to {{ ydb-short-name }} using utilities such as [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html), [psql](https://www.postgresql.org/docs/current/app-psql.html), and [{{ ydb-short-name }} CLI](../reference/ydb-cli/index.md). The [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html) and [psql](https://www.postgresql.org/docs/current/app-psql.html) utilities are installed with PostgreSQL. [{{ ydb-short-name }} CLI](../reference/ydb-cli/index.md) is {{ ydb-short-name }}'s command-line client, which is [installed separately](../reference/ydb-cli/install.md).
46

57
To do this, you need to:
@@ -26,8 +28,8 @@ The `ydb tools pg-convert` command reads a dump file or standard input created b
2628
* Deleting the `WITH (...)` section in `CREATE TABLE`.
2729
* Commenting out unsupported constructs (optionally):
2830

29-
* `SELECT pg_catalog.set_config.*`
30-
* `ALTER TABLE`
31+
* `SELECT pg_catalog.set_config.*`
32+
* `ALTER TABLE`
3133

3234
If the CLI cannot find a table's primary key, it will automatically create a [BIGSERIAL](https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL) column named `__ydb_stub_id` as the primary key.
3335

@@ -60,31 +62,33 @@ As an example, data generated by [pgbench](https://www.postgresql.org/docs/curre
6062

6163
1. Start Docker containers with PostgreSQL and {{ ydb-short-name }}:
6264

63-
```bash
64-
docker run -d --rm -e POSTGRES_USER=root -e POSTGRES_PASSWORD=1234 \
65-
-e POSTGRES_DB=local --name postgres postgres:14
66-
docker run --name ydb-postgres -d --pull always -p 5432:5432 -p 8765:8765 \
67-
-e POSTGRES_USER=root -e POSTGRES_PASSWORD=1234 \
68-
-e YDB_FEATURE_FLAGS=enable_temp_tables,enable_table_pg_types \
69-
-e YDB_USE_IN_MEMORY_PDISKS=true \
70-
ghcr.io/ydb-platform/local-ydb:latest
71-
```
65+
```bash
66+
docker run --name my_postgres_container \
67+
-e POSTGRES_USER=pgroot -e POSTGRES_PASSWORD=1234 \
68+
-e POSTGRES_DB=local \
69+
-p 5433:5433 -d postgres:14 -c 'port=5433'
70+
docker run --name ydb-postgres -d --pull always -p 5432:5432 -p 8765:8765 \
71+
-e POSTGRES_USER=ydbroot -e POSTGRES_PASSWORD=4321 \
72+
-e YDB_FEATURE_FLAGS=enable_temp_tables,enable_table_pg_types \
73+
-e YDB_USE_IN_MEMORY_PDISKS=true \
74+
ghcr.io/ydb-platform/local-ydb:latest
75+
```
7276

7377
2. Generate data through [pgbench](https://www.postgresql.org/docs/current/pgbench.html):
7478

75-
```bash
76-
docker exec postgres pgbench postgres://root:1234@localhost/local -i
77-
```
79+
```bash
80+
docker exec my_postgres_container pgbench postgres://pgroot:1234@localhost:5433/local -i
81+
```
7882

7983
3. Create a dump of the database using [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html):
8084

81-
```bash
82-
docker exec postgres pg_dump postgres://root:1234@localhost/local --inserts \
83-
--column-inserts --encoding=utf_8 --rows-per-insert=1000 > dump.sql
84-
```
85+
```bash
86+
docker exec my_postgres_container pg_dump postgres://pgroot:1234@localhost:5433/local --inserts \
87+
--column-inserts --encoding=utf_8 --rows-per-insert=1000 > dump.sql
88+
```
8589

86-
4. Load the dump into {{ ydb-short-name }}:
90+
4. Load the dump into {{ ydb-short-name }}:
8791

88-
```bash
89-
ydb tools pg-convert --ignore-unsupported -i dump.sql | psql postgresql://root:1234@localhost/local
90-
```
92+
```bash
93+
ydb tools pg-convert --ignore-unsupported -i dump.sql | psql postgresql://ydbroot:4321@localhost:5432/local
94+
```

ydb/docs/ru/core/postgresql/import.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Импорт данных из PostgreSQL
22

3+
{% include [./_includes/alert.md](./_includes/alert_preview.md) %}
4+
35
Данные из PostgreSQL в {{ ydb-name }} можно импортировать различными способами:
46

57
- С помощью [pg-dump](#pg-dump).
@@ -78,10 +80,12 @@
7880
1. Поднять докер-контейнеры с PostgreSQL и {{ ydb-short-name }}:
7981

8082
```bash
81-
docker run -d --rm -e POSTGRES_USER=root -e POSTGRES_PASSWORD=1234 \
82-
-e POSTGRES_DB=local --name postgres postgres:14
83+
docker run --name my_postgres_container \
84+
-e POSTGRES_USER=pgroot -e POSTGRES_PASSWORD=1234 \
85+
-e POSTGRES_DB=local \
86+
-p 5433:5433 -d postgres:14 -c 'port=5433'
8387
docker run --name ydb-postgres -d --pull always -p 5432:5432 -p 8765:8765 \
84-
-e POSTGRES_USER=root -e POSTGRES_PASSWORD=1234 \
88+
-e POSTGRES_USER=ydbroot -e POSTGRES_PASSWORD=4321 \
8589
-e YDB_FEATURE_FLAGS=enable_temp_tables,enable_table_pg_types \
8690
-e YDB_USE_IN_MEMORY_PDISKS=true \
8791
ghcr.io/ydb-platform/local-ydb:latest
@@ -90,18 +94,18 @@
9094
2. Сгенерировать данные через [pgbench](https://www.postgresql.org/docs/current/pgbench.html):
9195

9296
```bash
93-
docker exec postgres pgbench postgres://root:1234@localhost/local -i
97+
docker exec my_postgres_container pgbench postgres://pgroot:1234@localhost:5433/local -i
9498
```
9599

96100
3. Сделать дамп базы через [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html):
97101

98102
```bash
99-
docker exec postgres pg_dump postgres://root:1234@localhost/local --inserts \
103+
docker exec my_postgres_container pg_dump postgres://pgroot:1234@localhost:5433/local --inserts \
100104
--column-inserts --encoding=utf_8 --rows-per-insert=1000 > dump.sql
101105
```
102106

103107
4. Загрузить дамп базы в {{ ydb-short-name }}:
104108

105109
```bash
106-
ydb tools pg-convert --ignore-unsupported -i dump.sql | psql postgresql://root:1234@localhost/local
110+
ydb tools pg-convert --ignore-unsupported -i dump.sql | psql postgresql://ydbroot:4321@localhost:5432/local
107111
```

0 commit comments

Comments
 (0)