zoukankan      html  css  js  c++  java
  • grafana 4 升级到 grafana 5错误处理

    遇到2个错误:

    1. UNIQUE KEY 问题

    INFO[07-16|15:34:36] Executing migration logger=migrator id="Remove unique index org_id_slug"
    EROR[07-16|15:34:36] Executing migration failed logger=migrator id="Remove unique index org_id_slug" error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists"
    EROR[07-16|15:34:36] Exec failed logger=migrator error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists" sql="DROP INDEX `UQE_dashboard_org_id_slug` ON `dashboard`"
    EROR[07-16|15:34:36] Server shutdown logger=server reason="Service init failed: Migration failed err: Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists"
    

      

    故障原因,原数据库中的`dashboard`表没有“UQE_dashboard_org_id_slug”这个UNIQUE KEY ,所以在删除的时候失败了。

    2. Convert existing annotations from seconds to milliseconds问题

    INFO[07-16|17:13:41] Executing migration                      logger=migrator id="Convert existing annotations from seconds to milliseconds"
    EROR[07-16|17:13:41] Executing migration failed               logger=migrator id="Convert existing annotations from seconds to milliseconds" error="Error 1264: Out of range value for column 'epoch' at row 1"
    EROR[07-16|17:13:41] Exec failed                              logger=migrator error="Error 1264: Out of range value for column 'epoch' at row 1" sql="UPDATE annotation SET epoch = (epoch*1000) where epoch < 9999999999"
    EROR[07-16|17:13:41] Server shutdown                          logger=server reason="Service init failed: Migration failed err: Error 1264: Out of range value for column 'epoch' at row 1"
    

      

    故障原因,原表annotation的字段epoch类型是int,但是新版grafana中,需要将该字段的秒转换为毫秒,长度不够用了,执行转换的sql语句执行失败。

    解决方案:

    1,导出当前grafana使用的数据库内容:

    mysqldump -uroot -hlocalhost -p grafana > grafana.sql

    2, 编辑导出的sql文件,将int(11)替换为bigint(20)

    vi grafana.sql

    :%s/int(11)/int(20)/g

    3,找到`dashboard`表的创建语句,添加UNIQUE KEY `UQE_dashboard_org_id_slug`,例如:

    DROP TABLE IF EXISTS `dashboard`;
    /*!40101 SET @saved_cs_client     = @@character_set_client */;
    /*!40101 SET character_set_client = utf8 */;
    CREATE TABLE `dashboard` (
      `id` bigint(20) NOT NULL AUTO_INCREMENT,
      `version` bigint(20) NOT NULL,
      `slug` varchar(189) COLLATE utf8mb4_unicode_ci NOT NULL,
      `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
      `data` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
      `org_id` bigint(20) NOT NULL,
      `created` datetime NOT NULL,
      `updated` datetime NOT NULL,
      `updated_by` bigint(20) DEFAULT NULL,
      `created_by` bigint(20) DEFAULT NULL,
      `gnet_id` bigint(20) DEFAULT NULL,
      `plugin_id` varchar(189) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `UQE_dashboard_org_id_slug` (`org_id`,`slug`),
      KEY `IDX_dashboard_org_id` (`org_id`),
      KEY `IDX_dashboard_gnet_id` (`gnet_id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=187 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    

      

    4, 创建新的数据库,然后导入刚刚编辑的sql文件。

    create database grafana5  DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
    use grafana5
    source  ./grafana.sql;
    

      

    5, 为grafana账号添加新数据库授权,然后修改新版本配置文件,使用刚创建的数据库。

    然后再重新启动grafana5,启动后会自动进行旧数据转换,转换完毕访问grafana的页面,你会发现旧版所有内容都已经可以在新版上访问啦。

  • 相关阅读:
    Spring基于注解整合Redis实现内容缓存
    配置Mybatis二级缓存为Redis来实现内容缓存
    Spring整合Redis
    Java连接redis
    机器学习之 KNN近邻算法(一)入门
    matplotlib 之 快速入门
    Pandas 之入门
    Hadoop 之 环形缓冲区原理
    numpy 之 rollaxis的理解
    python 之 遇到SyntaxError: Non-UTF-8 code starting with 'xb8' in file
  • 原文地址:https://www.cnblogs.com/yzhch/p/9319425.html
Copyright © 2011-2022 走看看