本文场景:

在一个x86环境用docker-compose安装了老版本的harbor,现在需要将其数据迁移到arm版本k8s集群的harbor中

 

1. 到老harbor环境执行:

docker exec postgres pg_dumpall -U postgres -c > ./fullbackup.sql  // 全量备份数据库

2. 拷贝到新环境中

3. 在新harbor环境:

进入postgres容器,先kubectl get pod -o wide判断容器在哪个节点,然后连接到该节点,执行:

docker ps | grep database查找postgres容器,然后拷贝备份的sql到该容器

4.  psql进入交互式命令行

5.  删除数据库

drop database notaryserver ;
drop database notarysigner ;
drop database registry ;

如果有DETAIL:  There are 7 other sessions using the database.报错,执行如下命令然后重新删除数据库

SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE datname='testdb' AND pid<>pg_backend_pid(); //testdb为具体数据库名称

6. 退出交互式命令行,然后在容器里执行

psql -f fullbackup.sql

7. 退出重启容器,如果容器报错:

错误:Password does not match for user "postgres".

Connection matched pg_hba.conf line 95: "host all all all md5"

修改pg_data/pg_hba.conf文件,md5改为trust

#host all all all md5
host all all all trust

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐