-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: 切分 metadata 访问单独 db --story=115316807 #400
feat: 切分 metadata 访问单独 db --story=115316807 #400
Conversation
请在 PR 中添加类型标签,例如: |
请在 PR 中添加项目标签,例如: |
bkmonitor/apm/constants.py
Outdated
@@ -33,7 +33,7 @@ class VisibleEnum: | |||
|
|||
GLOBAL_CONFIG_BK_BIZ_ID = 0 | |||
# 获取需要增加事务的DB链接名 | |||
DATABASE_CONNECTION_NAME = getattr(settings, "METADATA_DEFAULT_DATABASE_NAME", "monitor_api") | |||
DATABASE_CONNECTION_NAME = getattr(settings, "METADATA_DEFAULT_DATABASE_NAME", "metadata") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要确认是否所有的事务都仅有metadata库发起吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为当前key,还没有使用,调整 METADATA_DEFAULT_DATABASE_NAME
=》 APM_BACKEND_DEFAULT_DATABASE_NAME
@@ -813,6 +824,15 @@ | |||
"PORT": GRAFANA_MYSQL_PORT or BACKEND_MYSQL_PORT, | |||
"OPTIONS": {"charset": "utf8mb4"}, | |||
}, | |||
"metadata": { | |||
"ENGINE": "django.db.backends.mysql", | |||
"NAME": METADATA_MYSQL_NAME, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参考上面: "PORT": GRAFANA_MYSQL_PORT or BACKEND_MYSQL_PORT,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在返回的方法中,统一处理
@@ -758,7 +759,7 @@ | |||
KAFKA_AUTO_COMMIT = True | |||
|
|||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField" | |||
DATABASE_ROUTERS = ["bk_dataview.router.DBRouter"] | |||
DATABASE_ROUTERS = ["bk_dataview.router.DBRouter", "metadata.db_router.DBRouter"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最好判断下是否配置了METADATA_MYSQL_HOST这种变量,如果没有这个变量,可以不用append
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要调整路由,因为backend的默认router中,需要移除 metadata
的app标识
暂时不需要切换 DB,先关闭 |
No description provided.