max_slave_connections:
每一个会话连接可以使用的slave数:比如有一个master和三个slave,如果max_slave_connections设置成2,那么这个会话连接只会选择两个slave,而不会使用3个。
默认值:255
注:在maxscale 2.5.0版本之前,这个参数可以写百分数,从这个版本开始,将不可以写百分数。
slave_connections
这个参数控制每个新会话可以建立多少个和slave的连接【This parameter controls how many slave connections each new session starts with】;如果是短链接,官网上建议设置的值比slave数要小,可以提高资源利用率,直接建议设置为1【 It is recommended to use slave_connections=1
when the lifetime of the client connections is short.】,长连接的话建议不要修改该值。
默认值:255
注:像一般业务,最好跟开发沟通好事长连接还是短链接
max_slave_replication_lag
设置slave滞后master的阈值,单位为秒;如果slave滞后于master这个参数所配置的秒数,则maxscale将不会把请求转发到该slave
默认值:0,默认不启用
注:2.5版本以后,这个参数必须指定时间单位
use_sql_variables_in
当再SQL语句中有变量时,将这条语句交由谁来执行,这个只对查询类的语句有效,对insert这类语句无效。
默认值:all
connection_keepalive
保持长连接,每隔一段时间发送ping包到后端数据库服务。如果不需要保持长连接,可直接设置为0
默认值:300 单位为秒
master_reconnection
是否允许master变更,如果master角色转移到了其它节点上,是否允许连接新的master节点。
默认值为:disabled
slave_selection_criteria
连接slave的选择策略,包含了:
- LEAST_GLOBAL_CONNECTIONS:最少的maxscale连接节点
- LEAST_ROUTER_CONNECTIONS:该service最少的连接数的节点
- LEAST_BEHIND_MASTER:数据量与master最接近节点
- LEAST_CURRENT_OPERATIONS:节点最少的活动连接【默认值】
- ADAPTIVE_ROUTING:平均返回最快的节点
max_sescmd_history
用于保存session的历史命令,设置历史命令的最大条数
默认值:50
disable_sescmd_history
禁用保存session的历史命令功能;使用场景,可以解决长连接时内存持续被消耗[Disabling session command history will allow long-lived connections without causing a constant growth in the memory consumption],且该参数只在max_slave_connections的值小于255时有效。
默认值:false
prune_sescmd_history
该参数用于优化历史命令对内存的占用,当命令历史总数超过了max_sescmd_history设置的值,就会触发。
默认值:disabled
master_accept_reads
允许master节点用于查询,默认主节点不允许读
默认值:false
注:如果没有slave时,不管该值设置是否为false,master都将用于查询。
strict_multi_stmt
如果设置为true,如果客户端传来一条多语句查询,maxscale将这个查询传给master
默认值:false
strict_sp_calls
如果设置为true;则会在存储过程中,将CALL命令行后的所有查询语句交由master去执行
默认值:false
注:用于存储过程,且要有CALL命令
master_failure_mode
当master节点不可用的时候,maxscale的处理方式。
- fail_instantly:断开所有连接。【默认值】
- fail_on_write:不可写,只可读。
- error_on_write:写语句时直接报错。只可读
retry_failed_reads
当读错误时,maxscale是否自动帮你重新在新的slave上去读;
默认值:true
delayed_retry
当后端发生错误的时候,maxscale是否重试请求语句;这可能会导致重复性数据,仅在允许重复性数据的情况下才打开【For this reason, it is recommended to only enable delayed_retry
when the possibility of duplicate statement execution is an acceptable risk.】
默认值:false
delayed_retry_timeout
重试超时时间,如果超过了这个时间就返回错误,仅仅在delayed_retry为true时打开
默认值:10秒
transaction_replay
重试被打断了的语句,这个参数仅仅在打开了delayed_retry和master_reconnection还有将master_failure_mode设置为fail_on_write时才有效。
默认值:false
跟这个参数配合的参数有:
transaction_replay_max_size:语句大小超过这个参数设定的值就放弃,默认为1MB
transaction_replay_attempts:重试时,超时多少时间就放弃,默认为5秒
transaction_replay_retry_on_daedlock:死锁时重试,默认为false
optimistic_trx
乐观语句执行,当打开该参数时,就默认打开了transaction_replay,delay_retry,master_reconnection这三个参数。当这个参数打开了,所有的请求都将优先转发到slave上,包括了写请求。
默认值:false
causal_reads
因果读,该参数目前只适用于mariaDB 10.2.16及以上的版本。
默认值:none
跟这个参数相关的参数有:
causal_reads_timeout
lazy_connect
当该值为false时,maxscale在启动时就会去连接后端mysql服务,当该值为true时,仅在有需要的时候才会去连接后端的mysql服务。适用于短链接。
默认值:false