从v6.0.0-ga.8升级到v6.7.3后启动报错

Viewed 57

版本:v6.0.0-ga.8-5d4151983a170ff0c3438936d367f179f452169c

操作系统:kylin V10

现象:
从现有v6.0.0-ga.8升级到v6.7.3,替换原来的二进制 和 integration 目录后启动n9e进程报错。替换的二进制文件有n9e、n9e-cli、n9e-edge

报错信息:
main.go:39: failed to initialize: cannot query config(rsa_password): failed to query configs: Error 1054: Unknown column 'external' in 'where clause'

个人排查:
看报错意思是初始化读取配置的时候失败,数据库不存在external这个列。查看了下数据库configs这张表只有id , ckey , cval 这三个列字段。我再直接单独部署了套v6.7.3环境,查看数据库configs这张表还多了noteexternalencryptedcreate_atcreate_byupdate_atupdate_by这几个列字段,而安装初始化时的n9e.sql脚本里关于configs这张表的ddl语句也只有id , ckey , cval 这三个列字段。官网上看https://flashcat.cloud/docs/content/flashcat-monitor/nightingale-v6/schema/configs/ 这个configs表的介绍也是三个列字段。

请教各位大佬,这种情况应该要怎么处理才能升级成功?我还有个环境是v6.0.0-ga.1的升级到v6.7.3没有问题

2 Answers

新版本升级,数据库账号具备ddl权限后会自动更新表结构 migrate

嗯,可我的数据库账号是具备ddl权限的,etc目录下config.toml配置文件DB相关用户信息我也没有动过,为何没有更新成功呢

执行细节可以通过日志确认,我理解中程序启动时会调用自动更新表结构逻辑,这里如果有问题日志应该有线索

cat n9e.log
nohup: ignoring input
runner.cwd: /data/n9e
runner.fd_limits: (soft=1024, hard=524288)
runner.vm_limits: (soft=unlimited, hard=unlimited)
2024/04/18 17:18:28 main.go:39: failed to initialize: cannot query config(rsa_password): failed to query configs: Error 1054: Unknown column 'external' in 'where clause'

我启动日志就这些信息,然后进程就挂了,还是说有其他可以看日志信息的,我用nohup ./n9e &> n9e.log & 这个方式启动

应该是自动 migrate configs 表的时候,报错了没成功,可以看下 ERROR.log 应该有报错日志,也可以 登录数据库,shwo create table configs 看下现在的表结构,没有的手动添加下

type Configs struct {
	Note string `gorm:"column:note;type:varchar(1024);default:'';comment:note"`
	Cval string `gorm:"column:cval;type:text;comment:config value"`
	//mysql tinyint//postgresql smallint
	External  int    `gorm:"column:external;type:int;default:0;comment:0\\:built-in 1\\:external"`
	Encrypted int    `gorm:"column:encrypted;type:int;default:0;comment:0\\:plaintext 1\\:ciphertext"`
	CreateAt  int64  `gorm:"column:create_at;type:int;default:0;comment:create_at"`
	CreateBy  string `gorm:"column:create_by;type:varchar(64);default:'';comment:cerate_by"`
	UpdateAt  int64  `gorm:"column:update_at;type:int;default:0;comment:update_at"`
	UpdateBy  string `gorm:"column:update_by;type:varchar(64);default:'';comment:update_by"`
}

感谢大佬,问题已经解决了,是ob数据库的问题。