V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
mingwiki
V2EX  ›  PostgreSQL

错误迁移 pgsql 导致日志报 warning,请问如何解决?

  •  
  •   mingwiki · 13 天前 · 667 次点击

    换系统的时候图简单脑子抽抽了,直接 tar czf /var/lib/postgresql 。后解压放到新系统/var/lib 目录下,没有用 dump pgloader 之类的工具。现在所有的 database 一直报同一个错,不重建所有数据库可以解决吗? 报错如下,查询 gemini/gpt3.5 无果,尝试ALTER DATABASE xxx REFRESH COLLATION VERSION;显示 invalid collation version. 请问大佬们如何解决?

    "2024-04-28 10:07:27.248 CST [3392] WARNING: database \"template1\" has no actual collation version, but a version was recorded",
    "2024-04-28 10:07:39.298 CST [3393] WARNING: database \"postgres\" has no actual collation version, but a version was recorded",
    "2024-04-28 10:07:49.150 CST [3398] WARNING: database \"vaultwarden\" has no actual collation version, but a version was recorded",
    "2024-04-28 10:07:49.150 CST [3399] WARNING: database \"vaultwarden\" has no actual collation version, but a version was recorded",
    "2024-04-28 10:07:51.323 CST [3400] WARNING: database \"vaultwarden\" has no actual collation version, but a version was recorded",
    "2024-04-28 10:08:03.244 CST [3401] WARNING: database \"miniflux\" has no actual collation version, but a version was recorded",
    "2024-04-28 10:08:15.275 CST [3402] WARNING: database \"core\" has no actual collation version, but a version was recorded",
    
    17 条回复    2024-04-28 11:35:04 +08:00
    dode
        1
    dode  
       13 天前
    重新安装同版本 pg 数据库,修改数据目录权限,看看有没有表,数据
    mingwiki
        2
    mingwiki  
    OP
       13 天前
    @dode #1 所有数据都在,表都在,但是每个查询都会出这么一天 warning 警告,虽然没啥大问题,但是这个报错消不掉。
    dode
        3
    dode  
       13 天前
    @mingwiki 重新导出数据,导入到新版 PG 数据库中去
    mingwiki
        4
    mingwiki  
    OP
       13 天前
    @dode #3 10 几个库 我想偷个懒 哦对了原本系统是 arch ,新系统是 alpine 用的 musl libc ,可能底层不一样所以出错
    encro
        5
    encro  
       13 天前
    看提示因为相应的校队规则不存在。去掉或者迁移过来。
    encro
        6
    encro  
       13 天前   ❤️ 1
    比如你数据库建库语句上指定了使用 template1 ,但是 template1 不存在,可能就会报这个错误。
    mingwiki
        8
    mingwiki  
    OP
       13 天前
    @encro #6 表是存在的但是就是报错。
    mingwiki
        9
    mingwiki  
    OP
       13 天前
    @encro #7 这个我看到了也尝试过不起作用,template1 是模版数据库可以备份但是删不掉,所以还不能重建。报错如下 postgres=# ALTER DATABASE template1 REFRESH COLLATION VERSION;
    ERROR: invalid collation version change
    retanoj
        10
    retanoj  
       13 天前
    encro
        11
    encro  
       13 天前
    版本不对没法了,尝试重新恢复到原始状态,然后走导出导入吧。
    ai 告诉我们如果是 icu 或者 glibc 更新导致的。可能就没辙了。
    mingwiki
        12
    mingwiki  
    OP
       13 天前
    @retanoj #10 看最后一句话 That's it again - just that this post has no happy end. If you have some approach to fix the collation error, let me know!
    mingwiki
        13
    mingwiki  
    OP
       13 天前
    @encro #11 我其他库都重建成功了,但是 postgres 和 template1 重建不了,要不我重装一下 pg ?
    cslive
        14
    cslive  
       13 天前
    小版本可以,大版本不行,必须迁移
    encro
        15
    encro  
       13 天前
    @mingwiki
    估计没用的,应该是 pg 版本不对了,内置 postgres 和 template1 变了,你重装现在的 pg 解决不了问题。
    只能先重装一个原来的 pg ,然后导出,再导入新的 pg 环境,让 pg 系统帮你解决。不去修改 pg 核心,才是比较稳妥的。
    encro
        16
    encro  
       13 天前
    @mingwiki

    你的办法也可以:
    1 ,备份你自己的库,除了 postgres 和 template1
    2 ,然重新 init 恢复系统 postgres 和 template1 。
    3 ,然后导入备份的库。
    mingwiki
        17
    mingwiki  
    OP
       13 天前
    @encro #16 我晚上回去试一下,应该可以,让 pg 建个新的 postgres 和 template1 ,然后我再 psql 导入
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5462 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 07:46 · PVG 15:46 · LAX 00:46 · JFK 03:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.