community.proxysql.proxysql_replication_hostgroups 模块 – 使用 proxysql 管理界面管理复制主机组
注意
此模块是 community.proxysql 集合 (版本 1.6.0) 的一部分。
如果您使用的是 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.proxysql
。您需要其他要求才能使用此模块,请参阅 需求了解详情。
要在剧本中使用它,请指定:community.proxysql.proxysql_replication_hostgroups
。
概要
mysql_replication_hostgroups 中的每一行代表一对 writer_hostgroup 和 reader_hostgroup。ProxySQL 将监控指定主机组中所有服务器的 read_only 值,并根据 read_only 值将服务器分配给 writer 或 reader 主机组。
需求
在执行此模块的主机上需要以下需求。
PyMySQL
mysqlclient
参数
参数 |
注释 |
---|---|
检测节点是否为备用节点时使用的检查类型。 需要 proxysql >= 2.0.1。否则无效。
选项
|
|
可用于用户定义的任何用途的文本字段。 默认值: |
|
指定一个配置文件,从中读取login_user 和 login_password。 默认值: |
|
动态地将配置加载到运行时内存。 选项
|
|
用于连接到 ProxySQL 管理界面的主机。 默认值: |
|
用于对 ProxySQL 管理界面进行身份验证的密码。 |
|
用于连接到 ProxySQL 管理界面的端口。 默认值: |
|
用于连接到 ProxySQL 管理界面的套接字。 |
|
用于对 ProxySQL 管理界面进行身份验证的用户名。 |
|
读取器主机组的 ID。 |
|
将配置保存到磁盘上的 sqlite 数据库以持久化配置。 选项
|
|
当 选项
|
|
写入器主机组的 ID。 |
注释
注意
支持
check_mode
。
示例
---
# This example adds a replication hostgroup, it saves the mysql server config
# to disk, but avoids loading the mysql server config to runtime (this might be
# because several replication hostgroup are being added and the user wants to
# push the config to runtime in a single batch using the
# community.general.proxysql_manage_config module). It uses supplied credentials
# to connect to the proxysql admin interface.
- name: Add a replication hostgroup
community.proxysql.proxysql_replication_hostgroups:
login_user: 'admin'
login_password: 'admin'
writer_hostgroup: 1
reader_hostgroup: 2
state: present
load_to_runtime: false
- name: Change check_type
community.proxysql.proxysql_replication_hostgroups:
login_user: 'admin'
login_password: 'admin'
writer_hostgroup: 1
reader_hostgroup: 2
check_type: innodb_read_only
state: present
load_to_runtime: false
# This example removes a replication hostgroup, saves the mysql server config
# to disk, and dynamically loads the mysql server config to runtime. It uses
# credentials in a supplied config file to connect to the proxysql admin
# interface.
- name: Remove a replication hostgroup
community.proxysql.proxysql_replication_hostgroups:
config_file: '~/proxysql.cnf'
writer_hostgroup: 3
reader_hostgroup: 4
state: absent
返回值
常用的返回值在此处有说明 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
从 proxysql 中修改或删除的复制主机组。 返回: 创建/更新时将返回新修改的组,删除时将返回已删除的记录。 示例: |