xsql_ha_set_switch_mode
此函数接受一个字符串参数,即“auto”、“master”、“replica”或“standalone”,如果先前的 switch_mode 值相同(即模式实际上未更改),则返回 false,否则返回 true。在出现错误的情况下,它会抛出异常(与其他大多数用户定义函数一样)。
在“auto”模式下,如果 xSQL 配置文件指定了主节点和副本节点的参数,高可用性运行时会以副本模式运行 xSQL,并尝试多次连接主节点。如果这些尝试均未成功,则 xSQL 将以主节点模式运行。
在“master”模式下,xSQL 将始终作为主服务器运行,无论其配置文件中的副本参数如何;
在“replica”模式下,xSQL 始终作为副本运行,同样不考虑配置文件中的主服务器参数。
在“standalone”模式下,xSQL 服务器会暂时完全忽略高可用性设置。
bool xsql_ha_set_switch_mode( switch_mode );
参数
switch_mode
要切换到的模式
示例
XSQL>select xsql_ha_set_switch_mode('auto);
#1
------------------------------------------------------------------------------
true
Selected records: 1
XSQL>select xsql_ha_set_switch_mode('bad mode');
#1
------------------------------------------------------------------------------
ERROR: Possible parameter values are 'auto', 'master', 'replica' or 'standalone'