在 Linux on Power 上升级 Postgres 数据存储 ( ppc64le )
安装 Postgres 操作员并配置数据存储。
准备工作
请确保您已配置好线上和线下的主机,以便从外部仓库拉取图片。 此外,请确保已添加正确的 Helm 仓库。
Postgres 运算符版本和图像标签
以下图片是固定在 Helm 图表或操作员版本中所需的。
CNPG Postgres
| 平台 | 操作员版本 | Helm Chart 版本 | 带有标签的图片 |
|---|---|---|---|
| Linux® on Power® (ppc64le) | v1.29.1 | 0.28.2 | artifact-public.instana.io/self-hosted-images/3rd-party/operator/cloudnative-pg: v1.29.1_v0.34.0 artifact-public.instana.io/self-hosted-images/3rd-party/datastore/cnpg-containers: 15_v0.39.0 |
Zalando Postgres
| 平台 | 操作员版本 | Helm Chart 版本 | 带有标签的图片 |
|---|---|---|---|
| Linux® on Power® (ppc64le) | 1.10.0 | v1.10.1 | artifact-public.instana.io/self-hosted-images/3rd-party/operator/zalando: v1.10.0_v0.1.0 artifact-public.instana.io/self-hosted-images/3rd-party/datastore/zalando: 15.7_v0.1.0 |
在线升级 Postgres
在在线环境中升级 Postgres 操作员。
使用 CloudNativePG 操作符升级 Postgres
请按照以下步骤升级 Postgres 数据存储。
如果您正在升级 Red Hat® OpenShift® 集群上的 Postgres ,请从命名
instana-postgres空间中确定文件系统组ID。 Red Hat OpenShift 要求文件系统组必须位于该命名空间特有的数值范围内。kubectl get namespace instana-postgres -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 ....... name: instana-postgres该
openshift.io/sa.scc.supplemental-groups注释包含允许的 ID 范围。 该范围1000750000/10000表示从 ID 开始的 10,1000750000000 个值,因此它指定了从1000750000到 的 ID1000760000范围。 在此示例中,该值1000750000可能被用作文件系统组 ID(UID)。升级 Postgres 操作符。
helm upgrade --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通过应用以下补丁来更新 Postgres 集群资源:
kubectl patch cluster postgres -n instana-postgres --type=merge --patch ' spec: imageName: artifact-public.instana.io/self-hosted-images/3rd-party/datastore/cnpg-containers:15_v0.39.0 '请按照 《验证 Postgres 》(在线和离线) 中的步骤操作。
使用 Zalando 操作符升级 Postgres
要在线升级 Zalando Postgres 运营商,请完成以下步骤:
创建一个文件,例如
values.yaml,使用 Postgres 配置。configGeneral: kubernetes_use_configmaps: true securityContext: runAsUser: 101 image: registry: artifact-public.instana.io repository: self-hosted-images/3rd-party/operator/zalando tag: "v1.10.0_v0.1.0" imagePullSecrets: - name: instana-registry configKubernetes: pod_service_account_definition: | apiVersion: v1 kind: ServiceAccount metadata: name: postgres-pod imagePullSecrets: - name: instana-registry podServiceAccount: name: postgres-pod升级 Postgres 操作符。
helm upgrade --install postgres-operator instana/postgres-operator \ --version=v1.10.1 \ -f values.yaml \ -n instana-postgres通过应用以下补丁来更新 Postgres 集群资源:
kubectl patch postgresql postgres -n instana-postgres --type=merge --patch ' spec: dockerImage: artifact-public.instana.io/self-hosted-images/3rd-party/datastore/zalando:15.7_v0.1.0 '请按照 《验证 Postgres 》(在线和离线) 中的步骤操作。
离线升级 Postgres
在物理隔离的环境中升级 Postgres 操作员。
使用 CloudNative PG 操作员离线升级 Postgres
如果您尚未从外部注册表中拉取 Postgres 的镜像,现在可以进行拉取。 在您的堡垒主机上运行以下命令。 然后,将这些图像复制到位于物理隔离环境中的 Instana 主机上。
docker pull artifact-public.instana.io/self-hosted-images/3rd-party/operator/cloudnative-pg:v1.29.1_v0.34.0
docker pull artifact-public.instana.io/self-hosted-images/3rd-party/datastore/cnpg-containers:15_v0.39.0
请在您的 Instana 主机上完成以下步骤。
将图片重新标记到您的内部图片库中。
docker tag artifact-public.instana.io/self-hosted-images/3rd-party/operator/cloudnative-pg:v1.29.1_v0.34.0 <internal-image-registry>/operator/cloudnative-pg:v1.29.1_v0.34.0 docker tag artifact-public.instana.io/self-hosted-images/3rd-party/datastore/cnpg-containers:15_v0.39.0 <internal-image-registry>/datastore/cnpg-containers:15_v0.39.0将镜像推送到堡垒主机上的内部镜像仓库。
docker push <internal-image-registry>/operator/cloudnative-pg:v1.29.1_v0.34.0 docker push <internal-image-registry>/datastore/cnpg-containers:15_v0.39.0如果您正在升级 Red Hat® OpenShift® 集群上的 Postgres ,请从命名
instana-postgres空间中确定文件系统组ID。 Red Hat OpenShift 要求文件系统组必须位于该命名空间特有的数值范围内。kubectl get namespace instana-postgres -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 ....... name: instana-postgres该
openshift.io/sa.scc.supplemental-groups注释包含允许的 ID 范围。 该范围1000750000/10000表示从 ID 开始的 10,1000750000000 个值,因此它指定了从1000750000到 的 ID1000760000范围。 在此示例中,该值1000750000可能被用作文件系统组 ID(UID)。升级 Postgres 操作符。 在以下命令中,请将 <download_key> 的值替换为您自己的代理密钥。 如果您为内部注册表创建了镜像拉取密钥,请
--docker-server=<internal-image-registry>:<internal-image-registry-port>在以下命令中添加。Red Hat OpenShift 集群
在以下命令中,
<UID from namespace>请使用上一步骤生成的 UID:helm upgrade --install cnpg cloudnative-pg-1.28.0.tgz --set image.repository=<internal-image-registry>/instana-postgres/cloudnative-pg-operator -set image.tag=v1.29.1_v0.34.0 --version=0.28.2 --set containerSecurityContext.runAsUser=<UID from namespace> --set containerSecurityContext.runAsGroup=<UID from namespace> -n instana-postgresKubernetes 集群
helm upgrade --install cnpg cloudnative-pg-0.28.2.tgz --set image.repository=<internal-image-registry>/operator/cloudnative-pg --set image.tag=v1.29.1_v0.34.0 --version=0.28.2 -n instana-postgres
运行以下命令来修补 Postgres 自定义资源,从而升级 Postgres。
kubectl patch cluster postgres -n instana-postgres --type=merge --patch ' spec: imageName: <internal-image-registry>/self-hosted-images/3rd-party/datastore/cnpg-containers:15_v0.39.0 '请按照 《验证 Postgres 》(在线和离线) 中的步骤操作。
使用 Zalando 操作符离线升级 Postgres
如果您使用的是 Red Hat OpenShift 集群,请在部署 Postgres 操作员之前创建安全上下文约束。
更新 YAML 文件,例如
postgres-scc.yaml,添加SCC资源定义。apiVersion: security.openshift.io/v1 kind: SecurityContextConstraints metadata: name: postgres-scc runAsUser: type: MustRunAs uid: 101 seLinuxContext: type: RunAsAny fsGroup: type: RunAsAny allowHostDirVolumePlugin: false allowHostNetwork: true allowHostPorts: true allowPrivilegedContainer: false allowHostIPC: true allowHostPID: true readOnlyRootFilesystem: false users: - system:serviceaccount:instana-postgres:postgres-operator - system:serviceaccount:instana-postgres:postgres-pod - system:serviceaccount:instana-postgres:default
然后,继续升级 Postgres 操作员。
如果您尚未从外部注册表中拉取 Postgres 的镜像,现在可以进行拉取。 在您的堡垒主机上运行以下命令。 然后,将这些图像复制到位于物理隔离环境中的 Instana 主机上。
docker pull artifact-public.instana.io/self-hosted-images/3rd-party/operator/zalando:v1.10.0_v0.1.0
docker pull artifact-public.instana.io/self-hosted-images/3rd-party/datastore/zalando:15.7_v0.1.0
请在您的 Instana 主机上完成以下步骤。
将图片重新标记到您的内部图片库中。
docker tag artifact-public.instana.io/self-hosted-images/3rd-party/operator/zalando:v1.10.0_v0.1.0 <internal-image-registry>/self-hosted-images/3rd-party/operator/zalando:v1.10.0_v0.1.0 docker tag artifact-public.instana.io/self-hosted-images/3rd-party/datastore/zalando:15.7_v0.1.0 <internal-image-registry>/self-hosted-images/3rd-party/datastore/zalando:15.7_v0.1.0将镜像推送到堡垒主机上的内部镜像仓库。
docker push <internal-image-registry>/self-hosted-images/3rd-party/operator/zalando:v1.10.0_v0.1.0 docker push <internal-image-registry>/self-hosted-images/3rd-party/datastore/zalando:15.7_v0.1.0更新 YAML 文件,例如
values.yaml,使用 Postgres 配置。configGeneral: kubernetes_use_configmaps: true securityContext: runAsUser: 101 image: registry: <internal-image-registry> repository: self-hosted-images/3rd-party/operator/zalando tag: "v1.10.0_v0.1.0" imagePullSecrets: - name: instana-registry configKubernetes: pod_service_account_definition: | apiVersion: v1 kind: ServiceAccount metadata: name: postgres-pod imagePullSecrets: - name: instana-registry podServiceAccount: name: postgres-pod升级 Postgres 操作符。 如果您在上一步中创建了镜像拉取密钥,请
--set imagePullSecrets[0].name="<internal-image-registry-pull-secret>"在以下命令中添加。helm upgrade --install postgres-operator postgres-operator-ppc64le-1.10.0.tgz \ --version=1.10.0 \ --set configGeneral.kubernetes_use_configmaps=true \ --set securityContext.runAsUser=101 \ --namespace=instana-postgres \ --set image.registry=<internal-image-registry> \ --set image.repository=ppc64le-oss/postgres-operator-ppc64le \ --set image.tag=v1.10.0_v0.1.0运行以下命令,对 Postgres 自定义资源进行补丁更新,从而升级 Postgres。
kubectl patch postgresql postgres -n instana-postgres --type=merge --patch ' spec: dockerImage: <internal-image-registry>/self-hosted-images/3rd-party/datastore/zalando:15.7_v0.1.0 '请按照 《验证 Postgres 》(在线和离线) 中的步骤操作。
验证 Postgres (在线和离线)
请按照以下步骤验证 Postgres 实例和数据存储。
验证 Postgres 操作员的升级情况。
kubectl get all -n instana-postgres如果成功部署了 Postgres 操作员,则该命令的执行结果如下:
以下输出是 Zalando 运算符的一个示例:
NAME READY STATUS RESTARTS AGE pod/postgres-0 1/1 Running 0 100s pod/postgres-1 1/1 Running 0 69s pod/postgres-2 1/1 Running 0 41s pod/postgres-operator-766455c58c-ntmpf 1/1 Running 0 11m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/postgres ClusterIP 192.168.1.107 <none> 5432/TCP 101s service/postgres-operator ClusterIP 192.168.1.35 <none> 8080/TCP 11m service/postgres-repl ClusterIP 192.168.1.72 <none> 5432/TCP 101s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/postgres-operator 1/1 1 1 11m NAME DESIRED CURRENT READY AGE replicaset.apps/postgres-operator-766455c58c 1 1 1 11m NAME READY AGE statefulset.apps/postgres 3/3 103s NAME IMAGE CLUSTER-LABEL SERVICE-ACCOUNT MIN-INSTANCES AGE operatorconfiguration.acid.zalan.do/postgres-operator ghcr.io/zalando/spilo-15:3.0-p1 cluster-name postgres-pod -1 11m NAME TEAM VERSION PODS VOLUME CPU-REQUEST MEMORY-REQUEST AGE STATUS postgresql.acid.zalan.do/postgres instana 15 3 10Gi 500m 2Gi 106s Running以下输出是 CloudNativePG 运算符的一个示例:
NAME READY STATUS RESTARTS AGE pod/postgres-1 1/1 Running 0 100s pod/postgres-2 1/1 Running 0 69s pod/postgres-3 1/1 Running 0 41s pod/cnpg-cloudnative-pg-64bbc87958-fqnrl 1/1 Running 0 11m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT service/cnpg-webhook-service ClusterIP 172.30.66.183 <none> 443/TCP service/postgres-r ClusterIP 172.30.163.146 <none> 5432/TCP service/postgres-ro ClusterIP 172.30.226.75 <none> 5432/TCP service/postgres-rw ClusterIP 172.30.235.178 <none> 5432/TCP NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/cnpg-cloudnative-p 1/1 1 1 11m NAME DESIRED CURRENT READY AGE replicaset.apps/cnpg-cloudnative-pg-64bbc87958 1 1 1 11m
将数据从 Zalando 迁移至 CloudNativePG
通过使用引导 pg_basebackup 模式,您可以创建一个新的 PostgreSQL 集群(目标),该集群将精确复制现有 PostgreSQL 实例(源)的物理状态。
您可以通过有效的流式复制连接从一个正在运行的集群进行初始化,并将源 PostgreSQL 实例用作主服务器或备用 PostgreSQL 服务器。
若要通过引导 pg_basebackup 模式将数据从 Zalando PostgreSQL 集群迁移到 CloudNativePG 副本集群,请参阅 《将数据从 Zalando 迁移到 CloudNativePG 》。