Zalando 에서 CloudNativePG 으로의 데이터 마이그레이션 (클러스터 및 Linux on IBM Z and LinuxONELinux x86_64 클러스터에서)
복제 모드로 운영 중인 클러스터 내에서 부트스트랩 pg_basebackup 모드를 사용하여 Zalando 에서 CloudNativePG 으로 데이터를 전송할 수 있습니다. 데이터를 전송하려면 Zalando 데이터 저장소(소스)를 복제하는 CloudNativePG 복제 클러스터(대상)를 생성해야 합니다.
전제조건
실행 중인 클러스터에서 부트스트랩하려면 다음 단계를 완료하십시오:
- 대상과 소스가 동일한 메이저 버전( PostgreSQL )을 가지는지 확인하십시오.
- ZalandoPostgreSQL 데이터베이스에서 복제 및 로그인 역할을 가진 사용자를
streaming_replica설정하십시오.
Zalando 의 Postgres 데이터 저장소 수정(데이터 마이그레이션용)
데이터 마이그레이션을 위해 Zalando 의 Postgres 데이터 저장소를 수정하려면 다음 단계를 완료하십시오:
Zalando 포드에 연결:
기본 포드의 세부 정보를 확인하세요:
kubectl get pods -o jsonpath={.items..metadata.name} -l application=spilo,spilo-role=master -n instana-postgres포드 내에서 직접 명령어를 실행합니다:
kubectl exec -it <primary_pod_name> -n instana-postgresPostgres 데이터베이스에 연결합니다:
psql -U postgresZalando 데이터베이스에서 역할을 나열하고 복제 및 로그인 역할을 가진 사용자를
streaming_replica생성하십시오:\du CREATE ROLE streaming_replica WITH REPLICATION; ALTER ROLE streaming_replica WITH LOGIN PASSWORD '<password_retrived_from_zalando>';PostgreSQL 대화형 터미널을 종료합니다:
\q
모든 포드의
pgdata디렉터리 내에 파일과postgresql.conf동일한override.conf위치에 및custom.conf라는 두 개의 빈 파일을 생성하십시오.팟(Pod)을 나열하십시오.
kubectl get pods -n instana-postgres포드에서 직접 명령어를 실행합니다. 모든 포드에서 다음 명령어를 실행하십시오:
kubectl exec -it <pod_name> -n instana-postgrescd /var/lib/postgresql/data/pgdata touch -f custom.conf touch -f override.conf
포드 터미널에서 나가기:
exit
CloudNativePGPostgres 연산자를 사용한 데이터 마이그레이션을 통한 Postgres 데이터 저장소 생성
Postgres 운영자 온라인 설치
CloudNativePGPostgres 오퍼레이터를 온라인으로 배포하려면 다음 단계를 완료하십시오:
네임스페이스를
instana-postgres-01생성하십시오:kubectl create namespace instana-postgres-01Red Hat OpenShift 에서 파일 시스템 그룹 ID를 확인하십시오.
Red Hat OpenShift 파일 시스템 그룹이 네임스페이스에 특정한 값 범위 내에 있어야 합니다. CloudNativePGKubernetes 연산자가 배포된 클러스터에서 다음 명령을 실행하십시오:
kubectl get namespace instana-postgres-01 -o yaml명령어에 대해 다음과 유사한 출력이 표시됩니다:
apiVersion: v1 kind: Namespace metadata: annotations: ....... openshift.io/sa.scc.uid-range: 1000750000/10000 creationTimestamp: "2024-01-14T07:04:59Z" labels: kubernetes.io/metadata.name: instana-postgres-01 ....... name: instana-postgres-01주석에는
openshift.io/sa.scc.supplemental-groups허용되는 ID의 범위가 포함됩니다. 범위는 ID 로 시작하는1000750000/1000010,000개의 값을1000750000나타내므로, ID 의 범위 를 지정합니다10007500001000760000. 이 예시에서 값은 파일 시스템 그룹1000750000ID로 사용될 수 있습니다.다음 Helm 명령어를 실행하여 CloudNativePGPostgres 운영자를 설치하십시오:
helm repo add instana https://artifact-public.instana.io/artifactory/rel-helm-customer-virtual --username=_ --password=<AGENT_KEY>helm repo updatehelm install cnpg instana/cloudnative-pg --set image.repository=artifact-public.instana.io/self-hosted-images/3rd-party/operator/cloudnative-pg --set image.tag=v1.29.1_v0.34.0 --version=0.28.2 --set imagePullSecrets[0].name=instana-registry --set containerSecurityContext.runAsUser=<UID from namespace> --set containerSecurityContext.runAsGroup=<UID from namespace> -n instana-postgres-01
네임스페이스에
instana-postgres-01대한 이미지 풀 시크릿 생성:kubectl create secret docker-registry instana-registry -n instana-postgres-01 \ --docker-username=_ \ --docker-password=<AGENT_KEY> \ --docker-server=artifact-public.instana.io참고: 비밀 키를 생성하기 전에 <AGENT_KEY> 값을 자신의 에이전트 키로 업데이트하십시오.외부 클러스터 접근을 위한 파일을 생성하십시오. 예를
postgres-secret.yaml들어:kind: Secret apiVersion: v1 metadata: name: instanaadmin type: Opaque stringData: username: instanaadmin password: <user_generated_password_from_zalando>파일을
postgres-secret.yaml적용하십시오:kubectl apply -f postgres-secret.yaml -n instana-postgres-01CloudNativePG
Cluster리소스를 다음replica모드로 생성하십시오:다음과 같이 파일을
cnpg-postgres.yaml생성하십시오:apiVersion: postgresql.cnpg.io/v1 kind: Cluster metadata: name: postgres spec: instances: 3 imageName: artifact-public.instana.io/self-hosted-images/3rd-party/cnpg-containers:15_v0.39.0 imagePullPolicy: IfNotPresent imagePullSecrets: - name: instana-registry enableSuperuserAccess: true replicationSlots: highAvailability: enabled: true managed: roles: - name: instanaadmin login: true superuser: true createdb: true createrole: true replication: true passwordSecret: name: instanaadmin postgresql: pg_hba: - local all all trust - host replication postgres all trust - host replication streaming_replica 0.0.0.0/0 trust - host all all 0.0.0.0/0 trust - local replication standby trust - hostssl replication standby all md5 - hostnossl all all all reject - hostssl all all all md5 bootstrap: pg_basebackup: source: zalando-postgres replica: enabled: true source: zalando-postgres externalClusters: - name: zalando-postgres connectionParameters: host: postgres.instana-postgres.svc user: postgres password: name: instanaadmin key: password superuserSecret: name: instanaadmin storage: size: 20Gi storageClass: nfs-client다음 명령어를 실행하여 파일을
cnpg-postgres.yaml적용하십시오:kubectl apply -f cnpg-postgres.yaml -n instana-postgres-01
첫 번째 ` CloudNativePG ` 포드의 디버그 컨테이너에 SSH로 접속하여 수정합니다
postgresql.conf.클러스터가 복제본 모드로 초기화된 후, 초기 Pod (
postgres-1-pgbasebackup) 상태는 가 됩니다Completed. 첫 번째 CloudNativePG Pod(postgres-1)를 시작하려는 후속 시도는 실패할 것입니다. 이는 예상 동작입니다.포드의
Cluster초기화 및 후속 시작을 성공적으로 수행하려면 다음 단계를 완료하십시오:다음 명령어를 실행하여 초기 Pod를 확인하고, 해당 Pod에 SSH로 접속한 후
pgdata볼륨이 포함된 디렉터리로 이동하십시오:kubectl debug pod/postgres-1 --as-root -n instana-postgres-01cd /var/lib/postgresql/data/pgdata/각 포드 내부의
postgresql.conf파일에서 및pg_identpg_hba경로를 수정하십시오:경로를
pg_hba다음/var/lib/postgresql/15/main/pg_hba.conf경로로 변경하십시오:/var/lib/postgresql/data/pgdata/pg_hba.conf경로를
pg_ident다음/var/lib/postgresql/15/main/pg_ident.conf경로로 변경하십시오:/var/lib/postgresql/data/pgdata/pg_ident.conf
파일 끝에
include 'override.conf'다음을include 'custom.conf'추가하십시오:echo "include 'custom.conf'" >> postgresql.conf echo "include 'override.conf'" >> postgresql.conf
팟(Pod)을 다시 시작하십시오. 포드가 시작된 후, 모든 포드는 첫 번째 포드로부터 복제됩니다.
새로운 cnpg-cluster를 사용하십시오.
레플리카 클러스터를 비활성화합니다:
파일을
cnpg-postgres.yaml수정하십시오:........ replica: enabled: false source: zalando-postgres ..........파일을
cnpg-postgres.yaml다시 적용하십시오:kubectl apply -f cnpg-postgres.yaml -n instana-postgres-01
데이터베이스에 연결하십시오.
psql -U postgres정렬 버전 업데이트:
ALTER DATABASE template1 REFRESH COLLATION VERSION;
핵심 사양 구성을 업데이트하십시오:
Instana Core 파일에서 다음 예시와 같이 구성을
postgresConfig업데이트하십시오:..................... postgresConfigs: - authEnabled: true hosts: - postgres-rw.instana-postgres-01 .....................파일을
core.yaml다시 적용하십시오:kubectl apply -f core.yaml -n instana-core