如何设置无缝数据库池默认读取从库?

发布于 2025-01-02 00:34:35 字数 535 浏览 5 评论 0原文

我对无缝 gem 有问题

development:
  adapter: jdbcmysql
  database: mydb_development
  username: read_user
  password: abc123
  pool_adapter: jdbcmysql
  port: 3306
  master:
    host: master-db.example.com
    port: 6000
    username: master_user
    password: 567pass
  read_pool:
    - host: read-db-1.example.com
      pool_weight: 2
    - host: read-db-2.example.com

,它应该读取从权利 [read-db-1.example.com] ?但这很奇怪..它总是读取 master 数据库 [mydb_development] 。

您有什么建议吗?我应该如何配置此 gem 以默认读取从属数据库?

谢谢

I have problem with seamless gem

development:
  adapter: jdbcmysql
  database: mydb_development
  username: read_user
  password: abc123
  pool_adapter: jdbcmysql
  port: 3306
  master:
    host: master-db.example.com
    port: 6000
    username: master_user
    password: 567pass
  read_pool:
    - host: read-db-1.example.com
      pool_weight: 2
    - host: read-db-2.example.com

it should read for slave right [read-db-1.example.com] ? but it was weird.. it always read to master database [mydb_development] .

do you have any suggestion, how should i do to configure this gem for default read to slave database?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深陷 2025-01-09 00:34:36

在master配置中指定pool_weight=0

默认情况下,主连接将包含在读取池中。如果您只想将此连接专用于写入操作,则应将池权重设置为零。

seam_leass_database_pool 插件

Specify pool_weight=0 in the master configuration

By default, the master connection will be included in the read pool. If you would like to dedicate this connection only for write operations, you should set the pool weight to zero.

seam_leass_database_pool plugin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文