User Tools

Site Tools


сервис_postgresql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
сервис_postgresql [2025/05/12 13:21]
val [CloudNativePG PgBouncer]
сервис_postgresql [2025/05/13 20:52] (current)
val [CloudNativePG Recovery]
Line 144: Line 144:
  
 keycloak=# \d user_entity keycloak=# \d user_entity
 +
 +keycloak=# SELECT id, username FROM user_entity;​
  
 keycloak=# SELECT * FROM user_entity WHERE username='​admin';​ keycloak=# SELECT * FROM user_entity WHERE username='​admin';​
Line 215: Line 217:
 kube1:​~/​my-pgcluster#​ kubectl -n my-pgcluster-ns get all kube1:​~/​my-pgcluster#​ kubectl -n my-pgcluster-ns get all
 </​code>​ </​code>​
 +===== Потоковая репликация =====
 +
 +  * [[https://​selectel.ru/​blog/​tutorials/​how-to-set-up-replication-in-postgresql/​|Как настроить репликацию в PostgreSQL]]
 +
 ===== Резервное копирование и восстановление ===== ===== Резервное копирование и восстановление =====
  
Line 234: Line 240:
 gate# sudo -u postgres pg_dump -d keycloak > /​tmp/​keycloak.sql gate# sudo -u postgres pg_dump -d keycloak > /​tmp/​keycloak.sql
  
-gate# scp /​tmp/​keycloak.* kube1:+gate# ###scp /​tmp/​keycloak.* kube1:
 </​code>​ </​code>​
  
Line 251: Line 257:
 kube1:~# kubectl -n my-postgres-ns exec -ti pod/​my-postgres-postgresql-0 -- env PGPASSWORD="​strongpassword"​ psql -U postgres -c "​CREATE USER keycloak WITH PASSWORD '​strongpassword';"​ kube1:~# kubectl -n my-postgres-ns exec -ti pod/​my-postgres-postgresql-0 -- env PGPASSWORD="​strongpassword"​ psql -U postgres -c "​CREATE USER keycloak WITH PASSWORD '​strongpassword';"​
  
-kube1:~# cat ~/​keycloak.dump | kubectl -n my-postgres-ns exec -i pod/​my-postgres-postgresql-0 -- env PGPASSWORD="​strongpassword"​ pg_restore -C -d postgres -U postgres+kube1:​~# ​ssh gate.corp13.un ​cat /tmp/​keycloak.dump | kubectl -n my-postgres-ns exec -i pod/​my-postgres-postgresql-0 -- env PGPASSWORD="​strongpassword"​ pg_restore -C -d postgres -U postgres
 </​code>​ </​code>​
  
Line 281: Line 287:
  
   * [[https://​pgbarman.org/​]]   * [[https://​pgbarman.org/​]]
 +  * [[https://​sidmid.ru/​barman-%D0%BC%D0%B5%D0%BD%D0%B5%D0%B4%D0%B6%D0%B5%D1%80-%D0%B1%D1%8D%D0%BA%D0%B0%D0%BF%D0%BE%D0%B2-%D0%B4%D0%BB%D1%8F-%D1%81%D0%B5%D1%80%D0%B2%D0%B5%D1%80%D0%BE%D0%B2-postgresql/​|Barman. менеджер бэкапов для серверов PostgreSQL]]
 ==== CloudNativePG Backup ==== ==== CloudNativePG Backup ====
  
Line 330: Line 337:
 kube1:​~/​my-pgcluster#​ kubectl -n my-pgcluster-ns apply -f my-scheduled-backup.yaml kube1:​~/​my-pgcluster#​ kubectl -n my-pgcluster-ns apply -f my-scheduled-backup.yaml
  
-kube1# kubectl -n my-pgcluster-ns describe ​backup ​my-scheduled-backup+kube1# kubectl -n my-pgcluster-ns describe ​backups.postgresql.cnpg.io ​my-scheduled-backup
  
-kube1# kubectl -n my-pgcluster-ns get backup+kube1# kubectl -n my-pgcluster-ns get backups.postgresql.cnpg.io
 </​code>​ </​code>​
  
Line 340: Line 347:
  
 <​code>​ <​code>​
-kube1:~/my-pgcluster#​ kubectl -n my-pgcluster-ns create secret generic minio-secret \+kube1:~# kubectl create ns my-pgcluster-ns 
 + 
 +kube1:~# kubectl -n my-pgcluster-ns create secret generic minio-secret \
   --from-literal=ACCESS_KEY_ID=root \   --from-literal=ACCESS_KEY_ID=root \
   --from-literal=ACCESS_SECRET_KEY=strongpassword   --from-literal=ACCESS_SECRET_KEY=strongpassword
сервис_postgresql.1747045308.txt.gz · Last modified: 2025/05/12 13:21 by val