Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oracle使用sys用户执行 TOP SQL扫描任务失败 #2615

Open
LordofAvernus opened this issue Sep 19, 2024 · 0 comments
Open

Oracle使用sys用户执行 TOP SQL扫描任务失败 #2615

LordofAvernus opened this issue Sep 19, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@LordofAvernus
Copy link
Collaborator

LordofAvernus commented Sep 19, 2024

版本信息(Version)

3.2408.0

问题描述(Describe)

创建Oracle TOP SQL任务,无法从页面获取采集信息。日志中发现连接Oracle失败。

截图或日志(Log)

35612b78-7c97-4466-9bde-cda819da10f7

如何复现(To Reproduce)

添加Oracle数据源,用户为sys, 创建Oracle TOP SQL扫描任务

问题原因

  • sys用户只能用SYSDBA或者SYSOPER两种身份登陆,当前使用的sql.Open()默认为normal登陆。

解决方案

sys用户需要添加 as sysdba的连接字符

var DBAPrivilege string

if strings.ToUpper(dsn.User) == "SYS" {
	DBAPrivilege = "AS SYSDBA"
}
sqlDB, err := sql.Open("oracle", fmt.Sprintf("oracle://%s:%s@%s:%s/%s%s", dsn.User, dsn.Password, dsn.Host, dsn.Port, dsn.ServiceName, DBAPrivilege))
if err != nil {
	return nil, errors.Wrapf(err, "failed to connect to %s", dsn.String())
}
err = sqlDB.Ping()
if err != nil {
	return nil, errors.Wrapf(err, "failed to ping %s", dsn.String())
}

变更影响面

受影响的模块或功能

外部引用的潜在问题或风险

版本兼容性

测试建议

@LordofAvernus LordofAvernus added the bug Something isn't working label Sep 19, 2024
@LordofAvernus LordofAvernus changed the title Oracle TOP SQL扫描任务无法用sys用户 Oracle使用sys用户执行 TOP SQL扫描任务失败 Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants