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 [2026/03/21 15:27]
val [Подключение по сети]
сервис_postgresql [2026/06/11 11:11] (current)
val [Kubernetes]
Line 19: Line 19:
 ==== Kubernetes ==== ==== Kubernetes ====
  
-  * Как не надо делать:​ [[https://​www.digitalocean.com/​community/​tutorials/​how-to-deploy-postgres-to-kubernetes-cluster]]+  * Как не надо делать (уже исправили,​ но, комментарии остались:[[https://​www.digitalocean.com/​community/​tutorials/​how-to-deploy-postgres-to-kubernetes-cluster]]
  
 === Helm === === Helm ===
Line 63: Line 63:
  
 kube1:~# kubectl -n cnpg-system get all kube1:~# kubectl -n cnpg-system get all
 +
 +kube1:~# mkdir my-pgcluster;​ cd $_
  
 kube1:​~/​my-pgcluster#​ echo -n keycloak | base64 kube1:​~/​my-pgcluster#​ echo -n keycloak | base64
Line 100: Line 102:
 <​code>​ <​code>​
 kube1:​~/​my-pgcluster#​ kubectl -n my-pgcluster-ns apply -f keycloak-db-secret.yaml,​my-pgcluster.yaml kube1:​~/​my-pgcluster#​ kubectl -n my-pgcluster-ns apply -f keycloak-db-secret.yaml,​my-pgcluster.yaml
- +</​code>​ 
-kube1# ​watch kubectl -n my-pgcluster-ns get all +== Проверка состояния кластера cnpg == 
 +<​code>​ 
 +kube1:​~/​my-pgcluster# kubectl -n my-pgcluster-ns get cluster 
 +NAME AGE INSTANCES READY STATUS PRIMARY 
 +... 
 +</​code>​ 
 +== Подключение к кластеру cnpg == 
 +<​code>​
 kube1# kubectl -n my-pgcluster-ns exec -it pod/​my-pgcluster-1 -- psql kube1# kubectl -n my-pgcluster-ns exec -it pod/​my-pgcluster-1 -- psql
  
Line 116: Line 124:
  
 kube1:~# kubectl cnpg status my-pgcluster -n my-pgcluster-ns kube1:~# kubectl cnpg status my-pgcluster -n my-pgcluster-ns
 +
 +kube1:~# kubectl cnpg promote -n my-pgcluster-ns my-pgcluster my-pgcluster-1
  
 kube1:~# kubectl cnpg logs cluster my-pgcluster -n my-pgcluster-ns kube1:~# kubectl cnpg logs cluster my-pgcluster -n my-pgcluster-ns
 +</​code>​
 +== Миграция с вышедшего из строя узла ==
 +<​code>​
 +kube2:~# kubectl -n my-pgcluster-ns get pods
 +...
 +my-pgcluster-3 ​  ​0/​1 ​    ​Pending ​  ​0 ​         80m
 +
 +kube2# kubectl -n my-pgcluster-ns delete pvc my-pgcluster-3
 +
 +kube2# kubectl -n my-pgcluster-ns delete pods/​my-pgcluster-3
 </​code>​ </​code>​
 ===== Клиент psql ===== ===== Клиент psql =====
Line 195: Line 215:
  
 root@my-debian:​~#​ psql postgres://​keycloak:​strongpassword@my-pgcluster-rw.my-pgcluster-ns:​5432/​keycloak -c "​\dt"​ root@my-debian:​~#​ psql postgres://​keycloak:​strongpassword@my-pgcluster-rw.my-pgcluster-ns:​5432/​keycloak -c "​\dt"​
-kube1:~/my-pgcluster# psql postgres://​keycloak:strongpassword@10.233.13.120:5432/keycloak -c "​\dt"​+ 
 +kube1:~# host my-pgcluster-rw.my-pgcluster-ns.svc.cluster.local 169.254.25.10 
 + 
 +kube1:~# telnet ​10.233.N.5432
 </​code>​ </​code>​
  
сервис_postgresql.1774096032.txt.gz · Last modified: 2026/03/21 15:27 by val