• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • 升级InnoDB集群元数据

    随着AdminAPI的发展,某些版本可能要求您升级现有集群的元数据,以确保它们与MySQL Shell的较新版本兼容。例如,在8.0.19版中添加InnoDB ReplicaSet意味着元数据架构已升级到2.0版。无论您是否计划使用InnoDB ReplicaSet,或者将MySQL Shell 8.0.19或更高版本与使用早期版本的MySQL Shell部署的群集一起使用,都必须升级群集的元数据。

    警告

    如果不升级元数据,则无法使用MySQL Shell 8.0.19更改使用较早版本创建的集群的配置。例如,您可以只针对集群如执行读操作Cluster.status()Cluster.describe()Cluster.options()

    dba.upgradeMetadata()操作将MySQL Shell当前连接到的群集上找到的元数据模式的版本与此MySQL Shell版本支持的元数据模式的版本进行比较。如果安装的元数据版本较低,则开始升级过程。dba.upgradeMetadata()然后,该操作会将所有自动创建的MySQL Router用户升级为具有正确的权限。手动创建的名称不是以开头的MySQL路由器用户mysql_router_不会自动升级。这是升级群集的重要步骤,只有这样,MySQL Router应用程序才能升级。要获取有关在集群中注册了哪个MySQL路由器实例需要元数据升级的信息,请发出:

    cluster.listRouters({'onlyUpgradeRequired':'true'})
    {
        "clusterName": "mycluster", 
        "routers": {
            "example.com::": {
                "hostname": "example.com", 
                "lastCheckIn": "2019-11-26 10:10:37", 
                "roPort": 6447, 
                "roXPort": 64470, 
                "rwPort": 6446, 
                "rwXPort": 64460, 
                "version": "8.0.18"
            }
        }
    }
    
    警告

    使用新元数据的群集不能由早期的MySQL Shell版本管理,例如,一旦升级到8.0.19版,就不能再使用8.0.18或更早的版本来管理该群集。

    要升级群集的元数据,请将MySQL Shell的全局会话连接到您的群集,并使用该dba.upgradeMetadata()操作将群集的元数据升级到新的元数据。例如:

    mysql-js> \connect user@example.com:3306
    
    mysql-js> dba.upgradeMetadata()
    InnoDB Cluster Metadata Upgrade
    
    The cluster you are connected to is using an outdated metadata schema version
    1.0.1 and needs to be upgraded to 2.0.0.
    
    Without doing this upgrade, no AdminAPI calls except read only operations will
    be allowed.
    
    The grants for the MySQL Router accounts that were created automatically when
    bootstrapping need to be updated to match the new metadata version's
    requirements.
    Updating router accounts...
    NOTE: 2 router accounts have been updated.
    
    Upgrading metadata at 'example.com:3306' from version 1.0.1 to version 2.0.0.
    Creating backup of the metadata schema...
    Step 1 of 1: upgrading from 1.0.1 to 2.0.0...
    Removing metadata backup...
    Upgrade process successfully finished, metadata schema is now on version 2.0.0
    

    如果遇到与clusterAdmin用户缺少特权有关的错误,请按照说明授予正确的特权。