mysql+proxysql+replication-manager的主從半同步複製+高可用+讀寫分離

来源:https://www.cnblogs.com/24la/archive/2023/04/23/mysql-proxysql-replication-manager-read-write-split-mha.html
-Advertisement-
Play Games

環境: AlmaLinux release 9.1 MySQL Community Server Ver 8.0.33 Replication Manager v2.2.40 for MariaDB 10.x and MySQL 5.7 Series ProxySQL version 2.5.1-9 ...


環境:

AlmaLinux release 9.1

MySQL Community Server Ver 8.0.33

Replication Manager v2.2.40 for MariaDB 10.x and MySQL 5.7 Series

ProxySQL version 2.5.1-90-gbedaa6c

主機分配情況:

採用hyper-v創建虛擬機的方式進行的,創建1台模板之後另外3台導入虛擬機複製。

1、安裝mysql

mysql8的預設加密插件變為了caching_sha2_password需要修改成mysql_native_password,因為proxysql不支持caching_sha2_password

安裝完成後在server01、02、03上創建以下用戶

rep-manager供replication-manager使用,repl供主從複製使用

mysql> create user 'rep-manager'@'%' identified by 'your password';
Query OK, 0 rows affected (0.01 sec)

mysql> create user 'repl'@'%' identified by 'your password';
Query OK, 0 rows affected (0.02 sec)

mysql> create user 'proxysql'@'%' identified by 'your password';
Query OK, 0 rows affected (0.02 sec)

mysql> grant process,replication slave,replication client on *.* to 'proxysql'@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> grant select,replication slave,replication client,reload,super on *.* to 'repl'@'%';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> grant all privileges on *.* to 'rep-manager'@'%' with grant option;
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

 

2、複製虛擬機

3、在server00上安裝replication-manager

4、在server00上安裝proxysql

5、啟動mysql,創建主從半同步複製

半同步需要安裝插件,在主庫和從庫上都安裝

mysql> install plugin rpl_semi_sync_source soname 'semisync_source.so';
mysql> install plugin rpl_semi_sync_replica soname 'semisync_replica.so';
mysql> show plugins;
+----------------------------------+----------+--------------------+---------------------+---------+
| Name                             | Status   | Type               | Library             | License |
+----------------------------------+----------+--------------------+---------------------+---------+
| binlog                           | ACTIVE   | STORAGE ENGINE     | NULL                | GPL     |
| mysql_native_password            | ACTIVE   | AUTHENTICATION     | NULL                | GPL     |
| sha256_password                  | ACTIVE   | AUTHENTICATION     | NULL                | GPL     |
| caching_sha2_password            | ACTIVE   | AUTHENTICATION     | NULL                | GPL     |
| sha2_cache_cleaner               | ACTIVE   | AUDIT              | NULL                | GPL     |
| daemon_keyring_proxy_plugin      | ACTIVE   | DAEMON             | NULL                | GPL     |
| CSV                              | ACTIVE   | STORAGE ENGINE     | NULL                | GPL     |
| MEMORY                           | ACTIVE   | STORAGE ENGINE     | NULL                | GPL     |
| InnoDB                           | ACTIVE   | STORAGE ENGINE     | NULL                | GPL     |
| INNODB_TRX                       | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_CMP                       | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_CMP_RESET                 | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_CMPMEM                    | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_CMPMEM_RESET              | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_CMP_PER_INDEX             | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_CMP_PER_INDEX_RESET       | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_BUFFER_PAGE               | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_BUFFER_PAGE_LRU           | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_BUFFER_POOL_STATS         | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_TEMP_TABLE_INFO           | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_METRICS                   | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_FT_DEFAULT_STOPWORD       | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_FT_DELETED                | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_FT_BEING_DELETED          | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_FT_CONFIG                 | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_FT_INDEX_CACHE            | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_FT_INDEX_TABLE            | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_TABLES                    | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_TABLESTATS                | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_INDEXES                   | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_TABLESPACES               | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_COLUMNS                   | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_VIRTUAL                   | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_CACHED_INDEXES            | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| INNODB_SESSION_TEMP_TABLESPACES  | ACTIVE   | INFORMATION SCHEMA | NULL                | GPL     |
| MyISAM                           | ACTIVE   | STORAGE ENGINE     | NULL                | GPL     |
| MRG_MYISAM                       | ACTIVE   | STORAGE ENGINE     | NULL                | GPL     |
| PERFORMANCE_SCHEMA               | ACTIVE   | STORAGE ENGINE     | NULL                | GPL     |
| TempTable                        | ACTIVE   | STORAGE ENGINE     | NULL                | GPL     |
| ARCHIVE                          | ACTIVE   | STORAGE ENGINE     | NULL                | GPL     |
| BLACKHOLE                        | ACTIVE   | STORAGE ENGINE     | NULL                | GPL     |
| FEDERATED                        | DISABLED | STORAGE ENGINE     | NULL                | GPL     |
| ndbcluster                       | DISABLED | STORAGE ENGINE     | NULL                | GPL     |
| ndbinfo                          | DISABLED | STORAGE ENGINE     | NULL                | GPL     |
| ndb_transid_mysql_connection_map | DISABLED | INFORMATION SCHEMA | NULL                | GPL     |
| ngram                            | ACTIVE   | FTPARSER           | NULL                | GPL     |
| mysqlx_cache_cleaner             | ACTIVE   | AUDIT              | NULL                | GPL     |
| mysqlx                           | ACTIVE   | DAEMON             | NULL                | GPL     |
| rpl_semi_sync_source             | ACTIVE   | REPLICATION        | semisync_source.so  | GPL     |
| rpl_semi_sync_replica            | ACTIVE   | REPLICATION        | semisync_replica.so | GPL     |
+----------------------------------+----------+--------------------+---------------------+---------+
50 rows in set (0.00 sec)
要想永久啟用半同步需將配置寫入my.cnf看下麵的配置即可。
在主庫上查看是否啟用了半同步
 mysql> show variables like 'rpl_semi%';
+---------------------------------------------+------------+
| Variable_name                               | Value      |
+---------------------------------------------+------------+
| rpl_semi_sync_replica_enabled               | ON        |
| rpl_semi_sync_replica_trace_level           | 32         |
| rpl_semi_sync_source_enabled                | ON         |
| rpl_semi_sync_source_timeout                | 10000      |
| rpl_semi_sync_source_trace_level            | 32         |
| rpl_semi_sync_source_wait_for_replica_count | 1          |
| rpl_semi_sync_source_wait_no_replica        | ON         |
| rpl_semi_sync_source_wait_point             | AFTER_SYNC |
+---------------------------------------------+------------+
從庫上
mysql> show variables like 'rpl_semi%';
+---------------------------------------------+------------+
| Variable_name                               | Value      |
+---------------------------------------------+------------+
| rpl_semi_sync_replica_enabled               | ON         |
| rpl_semi_sync_replica_trace_level           | 32         |
| rpl_semi_sync_source_enabled                | ON         |
| rpl_semi_sync_source_timeout                | 10000      |
| rpl_semi_sync_source_trace_level            | 32         |
| rpl_semi_sync_source_wait_for_replica_count | 1          |
| rpl_semi_sync_source_wait_no_replica        | ON         |
| rpl_semi_sync_source_wait_point             | AFTER_SYNC |
+---------------------------------------------+------------+
8 rows in set (0.01 sec)

master主機mysql配置my.cnf如下

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

default-authentication-plugin=mysql_native_password

######replication settings######
server-id=1001
log-bin=mysql-bin
binlog_format=row

binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
binlog-ignore-db=sys

######gtid#######
gtid_mode=on
enforce_gtid_consistency=on
binlog_gtid_simple_recovery=on

relay_log_recovery = ON
relay-log-index=mysql-relay
relay-log=mysql-relay

loose_rpl_semi_sync_source_enabled = ON
loose_rpl_semi_sync_replica_enabled = ON

log_slow_replica_statements = 1

slave主機myql的配置如下:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

default-authentication-plugin=mysql_native_password

######replication settings######
server-id=1002
log-bin=mysql-bin
binlog_format=row
log_slave_updates=on
relay_log_recovery=1

binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
binlog-ignore-db=sys

######gtid#######
gtid_mode=on
enforce_gtid_consistency=on
binlog_gtid_simple_recovery=on

relay_log_recovery = ON
relay-log-index=mysql-relay
relay-log=mysql-relay

loose_rpl_semi_sync_source_enabled = ON
loose_rpl_semi_sync_replica_enabled = ON

log_slow_replica_statements = 1

read_only = on

啟動主從

mysql> CHANGE REPLICATION SOURCE to SOURCE_HOST='server01.mshome.net',SOURCE_USER='repl',SOURCE_PASSWORD='your password',SOURCE_PORT=3306;
Query OK, 0 rows affected, 3 warnings (0.03 sec)

mysql> start replica;
Query OK, 0 rows affected (0.02 sec)

mysql> show replica status\G;
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: server01.mshome.net
                  Source_User: repl
                  Source_Port: 3306
                Connect_Retry: 60
              Source_Log_File: mysql-bin.000009
          Read_Source_Log_Pos: 157
               Relay_Log_File: mysql-relay.000010
                Relay_Log_Pos: 373
        Relay_Source_Log_File: mysql-bin.000009
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Source_Log_Pos: 157
              Relay_Log_Space: 795
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Source_SSL_Allowed: No
           Source_SSL_CA_File:
           Source_SSL_CA_Path:
              Source_SSL_Cert:
            Source_SSL_Cipher:
               Source_SSL_Key:
        Seconds_Behind_Source: 0
Source_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Source_Server_Id: 1001
                  Source_UUID: 590af332-e04e-11ed-8935-00155d030202
             Source_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
    Replica_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Source_Retry_Count: 86400
                  Source_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Source_SSL_Crl:
           Source_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 0
         Replicate_Rewrite_DB:
                 Channel_Name:
           Source_TLS_Version:
       Source_public_key_path:
        Get_Source_public_key: 1
            Network_Namespace:
1 row in set (0.00 sec)

ERROR:
No query specified
 

server00主機上安裝了replication-manager和proxysql

replication-manager的配置如下

查看replication-manager配置文件cluster1.toml
cat
/etc/replication-manager/cluster.d/cluster1.toml
[cluster1]
title = "cluster1"
prov-orchestrator = "onpremise"
prov-db-tags = "innodb,noquerycache,slow,pfs,pkg,linux,smallredolog,logtotable"
prov-db-memory = "256"
prov-db-memory-shared-pct = "threads:16,innodb:60,myisam:10,aria:10,rocksdb:1,tokudb:1,s3:1,archive:1,querycache:0"
prov-db-disk-size = "1"
prov-db-cpu-cores = "1"
prov-db-disk-iops = "300"

db-servers-hosts = "server01.mshome.net:3306,server02.mshome.net:3306,server03.mshome.net:3306"
db-servers-prefered-master = "server01.mshome.net:3306"
db-servers-credential = "rep-manager:yourpassword"
db-servers-connect-timeout = 5
replication-credential = "rep-manager:yourpassword"


verbose = false
log-failed-election  = true
log-level = 1
log-rotate-max-age = 7
log-rotate-max-backup = 7
log-rotate-max-size = 5
log-sql-in-monitoring   = true
log-sst = true

##############
## TOPOLOGY ##
##############

replication-multi-master = false
replication-multi-tier-slave = false

############
# BACKUPS ##
###########


backup-streaming = false
backup-streaming-aws-access-key-id = "admin"
backup-streaming-aws-access-secret = "xxxx"
backup-streaming-endpoint= "https://s3.signal18.io/"
backup-streaming-region= "fr-1"
backup-streaming-bucket= "repman"

#####這裡可以設置備份工具restic,工具可以跨伺服器,結合minio備份就很爽了,後續再介紹吧 backup-restic = false backup-restic-aws = false backup-physical-type = "mariabackup" backup-logical-type = "mysqldump" backup-restic-aws-access-secret = "xxxx" backup-restic-password = "xxxx" backup-restic-binary-path = "/usr/bin/restic" monitoring-scheduler = true scheduler-db-servers-logical-backup = true scheduler-db-servers-logical-backup-cron= "0 30 23 * * 6" scheduler-db-servers-logs = false scheduler-db-servers-logs-cron = "0 0 * * * *" scheduler-db-servers-logs-table-keep = 4 scheduler-db-servers-logs-table-rotate = false scheduler-db-servers-logs-table-rotate-cron = "0 0 0/6 * * *" scheduler-db-servers-optimize = false scheduler-db-servers-optimize-cron = "0 0 3 1 * 5" scheduler-db-servers-physical-backup = true scheduler-db-servers-physical-backup-cron = "0 30 23 * * *" ############## ## FAILOVER ## ############## failover-mode = "manual" failover-pre-script = "" failover-post-script = "" ## Slaves will re enter with read-only failover-readonly-state = true failover-event-scheduler = false failover-event-status = false ## Failover after N failures detection failover-falsepositive-ping-counter = 5 ## Cancel failover if already N failover ## Cancel failover if last failover was N seconds before ## Cancel failover in semi-sync when one slave is not in sync ## Cancel failover if one slave receive master heartbeat ## Cancel failover when replication delay is more than N seconds failover-limit = 0 failover-time-limit = 0 failover-at-sync = false failover-max-slave-delay = 30 failover-restart-unsafe = false # failover-falsepositive-heartbeat = true # failover-falsepositive-heartbeat-timeout = 3 # failover-falsepositive-maxscale = false # failover-falsepositive-maxscale-timeout = 14 # failover-falsepositive-external = false # failover-falsepositive-external-port = 80 ################ ## SWITCHOVER ## ################ ## In switchover Wait N milliseconds before killing long running transactions ## Cancel switchover if transaction running more than N seconds ## Cancel switchover if write query running more than N seconds ## Cancel switchover if one of the slaves is not synced based on GTID equality switchover-wait-kill = 5000 switchover-wait-trx = 10 switchover-wait-write-query = 10 switchover-at-equal-gtid = false switchover-at-sync = false switchover-max-slave-delay = 30 ############ ## REJOIN ## ############ autorejoin = true autorejoin-script = "" autorejoin-semisync = true autorejoin-backup-binlog = true autorejoin-flashback = false autorejoin-mysqldump = false #################### ## CHECKS & FORCE ## #################### check-replication-filters = true check-binlog-filters = true check-replication-state = true force-slave-heartbeat= false force-slave-heartbeat-retry = 5 force-slave-heartbeat-time = 3 force-slave-gtid-mode = false force-slave-semisync = false force-slave-failover-readonly-state = false force-binlog-row = false force-binlog-annotate = false force-binlog-slowqueries = false force-binlog-compress = false force-binlog-checksum = false force-inmemory-binlog-cache-size = false force-disk-relaylog-size-limit = false force-disk-relaylog-size-limit-size = 1000000000 force-sync-binlog = false force-sync-innodb = false ############## ## MAXSCALE ## ############## ## for 2 nodes cluster maxscale can be driven by replication manager maxscale = false maxscale-binlog = false maxscale-servers = "192.168.0.201" maxscale-port = 4003 maxscale-user = "admin" maxscale-pass = "mariadb" ## When true replication manager drive maxscale server state ## Not required unless multiple maxscale or release does not support detect_stale_slave maxscale-disable-monitor = false ## maxinfo|maxadmin maxscale-get-info-method = "maxadmin" maxscale-maxinfo-port = 4002 maxscale-write-port = 4007 maxscale-read-port = 4008 maxscale-read-write-port = 4006 maxscale-binlog-port = 4000 ############# ## HAPROXY ## ############# ## Wrapper mode unless maxscale or proxysql required to be located with replication-manager haproxy = false haproxy-binary-path = "/usr/sbin/haproxy" ## Read write traffic ## Read only load balance least connection traffic haproxy-write-port = 3306 haproxy-read-port = 3307 #################### ## SHARDING PROXY ## #################### mdbshardproxy = false mdbshardproxy-hosts = "127.0.0.1:3306" mdbshardproxy-user = "root:mariadb" ################################# ###### proxysql settings ######## ################################# proxysql = true proxysql-servers = "127.0.0.1" proxysql-port = "6033" proxysql-admin-port = "6032" proxysql-writer-hostgroup = "1000" proxysql-reader-hostgroup = "1001" proxysql-user = "admin" proxysql-password = "admin" proxysql-bootstrap = false proxysql-bootstrap-users = false #不從master複製用戶到proxysql,因為複製會出問題
查看replication-manager配置文件config.toml
cat
/etc/replication-manager/config.toml
[Default]

include = "/etc/replication-manager/cluster.d"

monitoring-save-config = false
monitoring-datadir = "/var/lib/replication-manager"
#monitoring-sharedir = "/usr/share/replication-manager"

## Timeout in seconds between consecutive monitoring

monitoring-ticker = 2

#########
## LOG ##
#########

log-file = "/var/log/replication-manager.log"
log-heartbeat = false
log-syslog = false



#################
## ARBITRATION ##
#################

arbitration-external = false
arbitration-external-secret = "13787932529099014144"
arbitration-external-hosts = "88.191.151.84:80"
arbitration-peer-hosts ="127.0.0.1:10002"

## Unique value on each replication-manager

arbitration-external-unique-id = 0

##########
## HTTP ##
##########

http-server = true
http-bind-address = "0.0.0.0"
http-port = "10001"
http-auth = false
http-session-lifetime =   3600
http-bootstrap-button = false
http-refresh-interval = 4000

#########
## API ##
#########

api-credentials = "admin:repman"
api-port = "10005"
api-https-bind = false

api-credentials-acl-allow =  "admin:cluster proxy db prov,dba:cluster proxy db,foo:"
api-credentials-acl-discard = false
api-credentials-external = "dba:repman,foo:bar"

############
## ALERTS ##
############

mail-from = "replication-manager@localhost"
mail-smtp-addr = "localhost:25"
mail-to = "[email protected]"
mail-smtp-password=""
mail-smtp-user=""

alert-slack-channel = "#support"
alert-slack-url = ""
alert-slack-user = "svar"

##########
# STATS ##
##########

graphite-metrics = false
graphite-carbon-host = "127.0.0.1"
graphite-carbon-port = 2003
graphite-embedded = false
graphite-carbon-api-port = 10002
graphite-carbon-server-port = 10003
graphite-carbon-link-port = 7002
graphite-carbon-pickle-port = 2004
graphite-carbon-pprof-port = 7007

####這裡可以設置邏輯備份和物理備份的程式,結合上面的配置里的restic做備份,很不錯,後續有時間了再繼續配置吧 backup-mydumper-path
= "/usr/local/bin/mydumper" backup-myloader-path = "/usr/local/bin/myloader" backup-mysqlbinlog-path = "/usr/local/bin/mysqlbinlog" backup-mysqldump-path = "/usr/local/bin/mysqldump" ############## # BENCHMARK ## ############## sysbench-binary-path = "/usr/bin/sysbench" sysbench-threads = 4 sysbench-time = 100 sysbench-v1 = true
查看proxysql的配置
cat
/etc/proxysql.cnf
#file proxysql.cfg

########################################################################################
# This config file is parsed using libconfig , and its grammar is described in:        
# http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-File-Grammar 
# Grammar is also copied at the end of this file                                       
########################################################################################

########################################################################################
# IMPORTANT INFORMATION REGARDING THIS CONFIGURATION FILE:                             
########################################################################################
# On startup, ProxySQL reads its config file (if present) to determine its datadir. 
# What happens next depends on if the database file (disk) is present in the defined
# datadir (i.e. "/var/lib/proxysql/proxysql.db").
#
# If the database file is found, ProxySQL initializes its in-memory configuration from 
# the persisted on-disk database. So, disk configuration gets loaded into memory and 
# then propagated towards the runtime configuration. 
#
# If the database file is not found and a config file exists, the config file is parsed 
# and its content is loaded into the in-memory database, to then be both saved on-disk 
# database and loaded at runtime.
#
# IMPORTANT: If a database file is found, the config file is NOT parsed. In this case
#            ProxySQL initializes its in-memory configuration from the persisted on-disk
#            database ONLY. In other words, the configuration found in the proxysql.cnf
#            file is only used to initial the on-disk database read on the first startup.
#
# In order to FORCE a re-initialise of the on-disk database from the configuration file 
# the ProxySQL service should be started with "systemctl start proxysql-initial".
#
########################################################################################

datadir="/var/lib/proxysql"
errorlog="/var/lib/proxysql/proxysql.log"

admin_variables=
{
    admin_credentials="admin:admin"
#    mysql_ifaces="127.0.0.1:6032;/tmp/proxysql_admin.sock"
    mysql_ifaces="0.0.0.0:6032"
#    refresh_interval=2000
#    debug=true
}

mysql_variables=
{
    threads=4
    max_connections=2048
    default_query_delay=0
    default_query_timeout=36000000
    have_compress=true
    poll_timeout=2000
#    interfaces="0.0.0.0:6033;/tmp/proxysql.sock"
    interfaces="0.0.0.0:6033"
    default_schema="information_schema"
    stacksize=1048576
    server_version="5.5.30"
    connect_timeout_server=3000
# make sure to configure monitor username and password
# https://github.com/sysown/proxysql/wiki/Global-variables#mysql-monitor_username-mysql-monitor_password
    monitor_username="monitor"
    monitor_password="monitor"
    monitor_history=600000
    monitor_connect_interval=60000
    monitor_ping_interval=10000
    monitor_read_only_interval=1500
    monitor_read_only_timeout=500
    ping_interval_server_msec=120000
    ping_timeout_server=500
    commands_stats=true
    sessions_sort=true
    connect_retries_on_failure=10
}


# defines all the MySQL servers
mysql_servers =
(
#    {
#        address = "127.0.0.1" # no default, required . If port is 0 , address is interpred as a Unix Socket Domain
#        port = 3306           # no default, required . If port is 0 , address is interpred as a Unix Socket Domain
#        hostgroup = 0            # no default, required
#        status = "ONLINE"     # default: ONLINE
#        weight = 1            # default: 1
#        compression = 0       # default: 0
#   max_replication_lag = 10  # default 0 . If greater than 0 and replication lag passes such threshold, the server is shunned
#    },
#    {
#        address = "/var/lib/mysql/mysql.sock"
#        port = 0
#        hostgroup = 0
#    },
#    {
#        address="127.0.0.1"
#        port=21891
#        hostgroup=0
#        max_connections=200
#    },
#    { address="127.0.0.2" , port=3306 , hostgroup=0, max_connections=5 },
#    { address="127.0.0.1" , port=21892 , hostgroup=1 },
#    { address="127.0.0.1" , port=21893 , hostgroup=1 }
#    { address="127.0.0.2" , port=3306 , hostgroup=1 },
#    { address="127.0.0.3" , port=3306 , hostgroup=1 },
#    { address="127.0.0.4" , port=3306 , hostgroup=1 },
#    { address="/var/lib/mysql/mysql.sock" , port=0 , hostgroup=1 }
)


# defines all the MySQL users
mysql_users:
(
#    {
#        username = "username" # no default , required
#        password = "password" # default: ''
#        default_hostgroup = 0 # default: 0
#        active = 1            # default: 1
#    },
#    {
#        username = "root"
#        password = ""
#        default_hostgroup = 0
#        max_connections=1000
#        default_schema="test"
#        active = 1
#    },
#    { username = "user1" , password = "password" , default_hostgroup = 0 , active = 0 }
)



#defines MySQL Query Rules
mysql_query_rules:
(
#    {
#        rule_id=1
#        active=1
#        match_pattern="^SELECT .* FOR UPDATE$"
#        destination_hostgroup=0
#        apply=1
#    },
#    {
#        rule_id=2
#        active=1
#        match_pattern="^SELECT"
#        destination_hostgroup=1
#        apply=1
#    }
)

scheduler=
(
#  {
#    id=1
#    active=0
#    interval_ms=10000
#    filename="/var/lib/proxysql/proxysql_galera_checker.sh"
#    arg1="0"
#    arg2="0"
#    arg3="0"
#    arg4="1"
#    arg5="/var/lib/proxysql/proxysql_galera_checker.log"
              
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • @(文件和目錄操作命令) 前言 這期呢主要說一說Linux中文件與目錄相關的命令,一共包含19個命令 cd 切換目錄 1、簡介 cd 是“change directory” 中每個單詞的首字母,其功能是從當前目錄切換到目標路徑。 2、語法格式 cd [參數選項] [目標路徑] 3、參數說明 這裡呢只 ...
  • @(文章目錄) 前言 從這篇開始,我們正式開始Linux命令了。 上一篇中已經預告,我們這篇主要說一說Linux中怎麼在命令行下查看命令幫助?Linux怎麼關機、重啟? 註意:Linux命令和命令後面的選項至少要有一個空格 一、在命令行下查看命令幫助 man 命令 1、簡介 man是Linux核心命 ...
  • 一.引言 kafka是廣泛使用的流處理組件,我們知道怎麼使用它,也知道它的實現原理。但是更重要的部分是它的設計理念,即kafka設計者當時是如何考量各種方案的,瞭解這些,對提升我們的設計能力非常有幫助。 二.動機 我們將 Kafka 設計為一個統一平臺,來處理大型公司可能擁有的所有實時數據流。 為此 ...
  • Oracle 的exp、imp、expdp、impdp命令用於資料庫邏輯備份與恢復; exp命令用於把數據從遠程資料庫server導出至本地,生成dmp文件。 筆者在實操中遇到: $exp user/pass file=exp.dmp tables = (TABLE1,TABLE3,TABLE3) ...
  • 最近讀了一本書《mysql是怎樣運行的》,讀完後在大體上對mysql的運行有一定的瞭解。在以前,我對mysql有以下的為什麼: InnoDB中的表空間、段、區和頁是什麼? redo log為什麼就能實現事務的持久性? 到底什麼是意向鎖?意向鎖有什麼用? mysql中的外連接、內連接到底是什麼? 事務 ...
  • 《Redis設計與實現》讀書筆記 簡單動態字元串 SDS的定義 結構: buf數組:用於保存字元串 len屬性:記錄SDS中保存字元串的長度 free屬性:記錄buf中未使用位元組數量 遵循C字元串以空字元串結尾的慣例,保存空字元串的位元組不計入長度 SDS與C字元串的區別 常數複雜度獲取字元串長度 因 ...
  • 4月20日,以“數實融合,韌性生長”為主題的袋鼠雲春季生長大會圓滿落幕。 在春季生長大會中,袋鼠雲帶來了數實融合趨勢下的最新行業沉澱、最佳實踐經驗和行業前瞻性的產品發佈。從大數據基礎軟體“數棧”、到低代碼數字孿生世界“易知微”,再到可觀測運維專家“雲掣”,為廣大用戶帶來了一場場精彩內容,共話數字未來 ...
  • 摘要:推送服務(Push Kit)是華為提供的消息推送平臺,建立了從雲端到終端的消息推送通道。通過集成推送服務,您可以向客戶端應用實時推送消息,讓應用更精準觸達用戶,是開發者提升用戶感知度和活躍度的一件利器。 本文分享自華為雲社區《無懼百萬級併發,GaussDB(for Cassandra)讓華為P ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...