暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

万里数据库GreatDB集中式运维指南之升级数据库的注意事项

原创 Dbb 2024-01-29
301

升级数据库的注意事项

  • 检查并处理instant column

    从数据库内核版本8.0.25(GreatDB 5.1.9)以及之前的版本升级到8.0.32 (GreatDB 6.0.0) 及之后版本时,在升级之前需要检查表中是否含有instant column,如果含有instant column需要进行消除。

    连接到数据库节点,通过information_schema.innodb_tables查询表中是否含有instant column,如下:

    greatdb> SELECT table_id, name, instant_cols FROM information_schema.innodb_tables WHERE instant_cols > 0;
    +----------+-------------+--------------+
    | table_id | name        | instant_cols |
    +----------+-------------+--------------+
    |     1061 | dbtest/tvar |            8 |
    +----------+-------------+--------------+
    

    instant_cols不为0,则表示该表中含有instant column,在升级之前需要通过optimize table table_name消除 instant column,如下:

    greatdb> optimize table tvar;
    +-------------+----------+----------+-------------------------------------------------------------------+
    | Table       | Op       | Msg_type | Msg_text                                                          |
    +-------------+----------+----------+-------------------------------------------------------------------+
    | dbtest.tvar | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
    | dbtest.tvar | optimize | status   | OK                                                                |
    +-------------+----------+----------+-------------------------------------------------------------------+
    2 rows in set (2.29 sec)
    
    greatdb> SELECT table_id, name, instant_cols FROM information_schema.innodb_tables WHERE instant_cols > 0;
    Empty set (0.01 sec)
    

    此外,在发版时对应的压缩包中提供有python脚本可以批量消除instant column。一共包括两个文件,路径是:

    bin/upgrade_optimize_greatdb.py
    bin/conf_greatdb.ini
    

    其中conf_greatdb.ini是配置文件,用于连接启动的实例,内容如下:

    [config]
    user=用户名
    password=密码
    port=端口号
    host=ip地址
    

    配置文件conf_greatdb.ini设置完毕之后,可先执行"python3 upgrade_optimize_greatdb.py 0"命令查询包含instant column的表,如下:

    ~$ python3 upgrade_optimize_greatdb.py 0
    
    the config is :
    user: root
    password: 
    port: 3306
    host: 127.0.0.1
    
    All instant tables as follows :
    
    t1.tab1
    t2.tab2
    

    然后执行"python3 upgrade_optimize_greatdb.py 1" 命令,消除包含instant column的所有的表:

    ```shell ~$ python3 upgrade_optimize_greatdb.py 1

    the config is : user: root password: port: 3306 host: 127.0.0.1

Optimize instant tables :

optimize table t1.tab1 optimize table t2.tab2

SUCCESSS : all instant column is eliminated


  这时表示所有的表都已经消除了instant列。

  再次使用"python3 upgrade_optimize_greatdb.py 0"命令确认集群中所有表的instant列都被消除。

  如果执行 "python3 upgrade_optimize_greatdb.py 1"命令时,有"optimize table table_name"失败,则会将"optimize table"失败的表列出来:

  ```shell
    ~$ python3 upgrade_optimize_greatdb.py 1

    the config is :
    user: root
    password: 
    port: 3306
    host: 127.0.0.1

    Optimize instant tables :

    optimize table test.tt
    optimize table t1.t1

    Failed optimize tables :

    t2.t2

其中t1.t1表执行optimize table时失败;

执行optimize table失败的表需要人工检查失败的原因,然后消除剩余表中的instant列。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论