mysql主从复制

mysql主从复制

mysql主从复制原理:


Master将自己二进制日志中记录的事件,发送给Slave,Slave收到事件,保存至中继日志中,Slave不接受本地任何的sql命令,只是从中继日志中,读取事件,执行,保存数据。一般来说,无论是Master还是Slave,他们的数据文件和日志文件不在用一块磁盘上

主从同步的详细过程如下:

  1. 主服务器验证连接。

  1. 主服务器为从服务器开启一个线程。

  1. 从服务器将主服务器日志的偏移位告诉主服务器。

  1. 主服务器检查该值是否小于当前二进制日志偏移位。

  1. 如果小于,则通知从服务器来取数据。

  1. 从服务器持续从主服务器取数据,直至取完,这时,从服务器线程进入睡眠,主服务器线程同时进入睡眠。

  1. 当主服务器有更新时,主服务器线程被激活,并将二进制日志推送给从服务器,并通知从服务器线程进入工作状态。

  1. 从服务器SQL线程执行二进制日志,随后进入睡眠状态。

由于主服务器可以并行(多cpu)执行事务,通过缓存机制,才会保存二进制日志到磁盘,而只有一个线程处理主从复制同步,所以Slvae数据复制会比Master慢。mysql主从复制,采用异步机制,允许一主多从,也支持多级复制,即从服务器可以有自己的从服务器。

为了保证主从服务器上数据一致,从服务器上应该拒绝写操作!

主从复制的作用:

  1. 辅助实现复制

  2. 实现高可用

  3. 异地容灾

  4. 负载:scale out 主服务器写入,从服务器读取

mysql读写分离

通过应用层代理服务器,理解sql命令,将不同sql命令分发给不同的后端mysql服务器(主从模型服务器)。

在mysql主从复制(一主一从)模型中,不适用mysql代理,如何让主服务器负责写,从服务器负责读?拆库

要使用mysql读写分离,最好还是使用mysql的代理,mysql提供mysql proxy;阿里提供amoeba、cobar

amoeba连接

cobar是一个数据库拆分工具

mysql主从模型

mysql主从复制模型:

  • 一主一从

  • 主主复制

  • 一主多从---扩展系统读取的性能,因为读是在从库读取的;

  • 多主一从---5.7开始支持

  • 联级复制---


这里讲一主多从模型,不存在一从多主,一个从服务器只能对应一个主服务器。

mysql5.5之前,复制功能比较简单。5.5之后,引入了:

gtid机制:使得复制更加安全

mutil-thread机制:多线程复制

mysql双主模型

MySQL双主(主主)架构方案思路是:

1.两台mysql都可读写,互为主备,默认只使用一台(masterA)负责数据的写入,另一台(masterB)备用;

2.masterA是masterB的主库,masterB又是masterA的主库,它们互为主从;

3.两台主库之间做高可用,可以采用keepalived等方案(使用VIP对外提供服务);

4.所有提供服务的从服务器与masterB进行主从同步(双主多从);

5.建议采用高可用策略的时候,masterA或masterB均不因宕机恢复后而抢占VIP(非抢占模式);

双主模型可以在一定程度上保证主库的高可用,在一台主库down掉之后,可以在极短的时间内切换到另一台主库上(尽可能减少主库宕机对业务造成的影响),减少了主从同步给线上主库带来的压力;

双主模型,互为Master,互为Slave,所以都有数据文件,二进制日志,中继日志,在使用中继日志重放时,每个服务器只重放自己没有的数据的sql指令,依靠ServerID时别,某一条sql指令是否属于自己。

双主模型的问题:

双主模型实质上,只时分担读操作能力。无法实现减轻写操作的能力(都得主从复制)。

双主模型容易出现主键冲突,甚至出现同时操作同一数据,出现问题。

所以不建议使用双主模型。

mysql5.5之前主从复制实现

mysql主从复制配置基本步骤:

对于master:

  1. 启用二进制日志

    log_bin = master-bin

    log-bin-index = master-bin.index

  2. 选择一个唯一的server-id

    server_id = {0-2^32^}

  3. 创建具有复制权限的用户

    REPLICATION SLAVE:复制从节点,从二进制日志中复制日志的权限

    REPLICATION CLIENT:连接服务器获取相关信

对于slave:

  1. 启用中继日志(特别的,从服务器不需要启用二进制日志,可以关闭)

    relay_log = relay-log

    relay_log_index = relay-log.index

  2. 选择一个唯一的server-id(唯一的,不能重复)

    server_id = {0-2^32}

  3. 连接至主服务器,并开始复制数据

    mysql>CHANGE MASTER TO,MASTER_HOST = ' ',MASTER_PORT=' ',MASTER_LOG_FILE=' ',MASTER_LOG_POS=' ',MASTER_USER=' ',MASTER_PASSWORD=' ';

    启动从服务器线程:

    mysql>START SLAVE (会启动从服务器得IO线程和sql线程)

    如果想指定启动:

    mysql>START SLAVE IO_Thread

    mysql>START SLAVE SQL_Thread

  4. 在不安全网络下,应当基于ssl进行主从复制

mysql的复制线程:在mysql的复制架构中,主服务器会在本地执行写操作的时候,将数据保存到数据文件中,和二进制日志文件中。一旦有了从服务器,还要将二进制日志事件信息发送给从服务器,这就要为每一个从服务器启动一个线程,实现事件的发送,在主服务器上的线程叫dump线程(每一个从服务器都会有一个对应的dump线程),从服务器也得有一个线程接入,IO线程,负责到主服务器上dump线程读取日志事件,如果事件没有,需要读取,dump就会发送个IO线程,然后保存至中继日志。在重放时,从服务器会启动一个sql线程,进行replay。


复制线程:

msater:

dump_Thread

slave:

IO_Thread,SQL_Thread

实现主从复制

对于主服务器:

  1. 编辑配置文件:

    vim /etc/my.cnf

    [mysqld]
    #skip-grant-tables
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    #开启二进制日志,并且二进制日志命名以master-bin开头
    log_bin=master-bin
    #二进制index文件
    log_bin_index=master-bin.index
    #将InnoDB,按单表存储
    innodb_file_per_table=ON
    #二进制日志存储格式
    binlog_format=MIXED
    #定义Master得serverid
    server_id=1
    #sync_binlog用于事务安全
    sync_binlog=ON
    
  2. 重启服务

    [root@mysql_salver mysql]# systemctl restart mariadb
  3. 进入mysql,创建主从复制中master信息

    MariaDB [(none)]> GRANT REPLICATION SLAVE ON *.* TO 'copyuser'@'172.25.254.%' IDENTIFIED BY 'qq123.456';
    Query OK, 0 rows affected (0.00 sec)
    MariaDB [(none)]> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)

对于从服务器:

  1. 编辑配置文件:

    vim /etc/my.cnf

    [mysqld]
    #skip-grant-tables
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    #将InnoDB,按单表存储
    innodb_file_per_table=ON
    #开启中继日志,并将中继日志命名以relay-log开头
    relay_log = relay-log
    #定义中继日志index文件名
    relay_log_index = relay-log.index
    #定义Slave的serverid
    server_id=2
    #保证从服务器不能写入数据,一旦用户把数据写入到从服务器的数据库内,然后从服务器从主服务器上同步数据库的时候,会造成数据的错乱,从而会造成数据的损坏
    read_only=ON
  2. 重启mysql服务

    [root@mysql_salver mysql]# systemctl restart mariadb
  3. 进入mysql,添加Slave配置信息

    MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST='172.25.254.7',MASTER_USER='copyuser',MASTER_PASSWORD='qq123.456',MASTER_LOG_FILE='master-bin.000001',MASTER_LOG_POS=480;
    Query OK, 0 rows affected (0.34 sec)
    
    MariaDB [(none)]> SHOW SLAVE STATUS\G
    *************************** 1. row ***************************
                   Slave_IO_State: 
                      Master_Host: 172.25.254.7
                      Master_User: copyuser
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: master-bin.000001
              Read_Master_Log_Pos: 480
                   Relay_Log_File: relay-log.000001
                    Relay_Log_Pos: 4
            Relay_Master_Log_File: master-bin.000001
                 Slave_IO_Running: No//IO线程
                Slave_SQL_Running: No//SQL线程
                  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_Master_Log_Pos: 480
                  Relay_Log_Space: 245
                  Until_Condition: None
                   Until_Log_File: 
                    Until_Log_Pos: 0
               Master_SSL_Allowed: No
               Master_SSL_CA_File: 
               Master_SSL_CA_Path: 
                  Master_SSL_Cert: 
                Master_SSL_Cipher: 
                   Master_SSL_Key: 
            Seconds_Behind_Master: NULL//比服务器慢多久
    Master_SSL_Verify_Server_Cert: No
                    Last_IO_Errno: 0
                    Last_IO_Error: 
                   Last_SQL_Errno: 0
                   Last_SQL_Error: 
      Replicate_Ignore_Server_Ids: 
                 Master_Server_Id: 0
    1 row in set (0.00 sec)
    
    MariaDB [(none)]> START SLAVE;
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> SHOW SLAVE STATUS\G
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 172.25.254.7
                      Master_User: copyuser
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: master-bin.000001
              Read_Master_Log_Pos: 480
                   Relay_Log_File: relay-log.000002
                    Relay_Log_Pos: 530
            Relay_Master_Log_File: master-bin.000001
                 Slave_IO_Running: Yes
                Slave_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_Master_Log_Pos: 480
                  Relay_Log_Space: 818
                  Until_Condition: None
                   Until_Log_File: 
                    Until_Log_Pos: 0
               Master_SSL_Allowed: No
               Master_SSL_CA_File: 
               Master_SSL_CA_Path: 
                  Master_SSL_Cert: 
                Master_SSL_Cipher: 
                   Master_SSL_Key: 
            Seconds_Behind_Master: 0    #同步落后主服务器时长,单位为秒
    Master_SSL_Verify_Server_Cert: No
                    Last_IO_Errno: 0
                    Last_IO_Error: 
                   Last_SQL_Errno: 0
                   Last_SQL_Error: 
      Replicate_Ignore_Server_Ids: 
                 Master_Server_Id: 1
    1 row in set (0.00 sec)
    

从服务器拒绝写入使用read_only:但是对于SUPER用户,不生效。

到此,主从复制模型已经成功开启。

可以在从服务器的数据目录查看一些信息:

[root@mysql_salver mysql]# ls master.info relay-log.000001 relay-log.index relay-log.info 
master.info  relay-log.000001  relay-log.index  relay-log.info
//可以看到开启了中继日志,并且有两个info文件
[root@mysql_salver mysql]# cat master.info 
#记录的是开启slave后连接的信息
18
master-bin.000001   #复制主服务器的二进制日志名
4568
172.25.254.7        #主服务器ip
copyuser            #复制时使用的用户名
qq123.456           #密码
3306                #端口
60                  #重新连接时间
0





0
1800.000

0
[root@mysql_salver mysql]# cat relay-log.info   #中继日志保存的一些信息
./relay-log.000001      #当前使用的中继日志
4618
master-bin.000001       #复制的主服务器的二进制日志
4568

进行测试:

  • 在主服务器上创建一个新的库,表,并添加数据

    MariaDB [(none)]> CREATE DATABASE test_copy;
    Query OK, 1 row affected (0.00 sec)
    
    MariaDB [(none)]> USE test_copy;
    Database changed
    MariaDB [test_copy]> CREATE TABLE test(id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,name VARCHAR(30),scale TINYINT) ENGINE=InnoDB;
    Query OK, 0 rows affected (0.20 sec)
    MariaDB [test_copy]> INSERT INTO test (name,scale) VALUES('fsx',88),('qpy',100),('coco',97);
    Query OK, 3 rows affected (0.09 sec)
    Records: 3  Duplicates: 0  Warnings: 0
    MariaDB [test_copy]> SELECT * FROM test;
    +----+------+-------+
    | id | name | scale |
    +----+------+-------+
    |  1 | fsx  |    88 |
    |  2 | qpy  |   100 |
    |  3 | coco |    97 |
    +----+------+-------+
    3 rows in set (0.00 sec)
  • 在从服务器上查看:

    MariaDB [(none)]> SHOW DATABASES;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | copy               |
    | mysql              |
    | performance_schema |
    | test               |
    | test_copy          |
    +--------------------+
    6 rows in set (0.00 sec)
    MariaDB [(none)]> SELECT * FROM test_copy.test;
    +----+------+-------+
    | id | name | scale |
    +----+------+-------+
    |  1 | fsx  |    88 |
    |  2 | qpy  |   100 |
    |  3 | coco |    97 |
    +----+------+-------+
    3 rows in set (0.00 sec)
    

这种使用默认同步模式,属于同步模式,当SLAVE的IO_THREAD关闭,可能有用户在主mysql服务器中插入数据,会阻塞。所以实现半同步模式,可以在SLAVE的IO_THREAD关闭时,将MYSQL复制变为异步模式。

半同步实现

半同步实现的意义:为了保证主库上的每一个binlog事务都能够被可靠的复制到从库上,主库在每次事务成功提交时, 并不及时反馈给前端应用用户,而是等待其中之一个从库也接收到Binlog事务并成功写入中继日志后, 主库才返回Commit操作成功给客户端。如果同步出现故障, 则MySQL自动调整复制为异步模式,事务正常返回提交结果给客户端。

安装了mysql后,在mysql的库文件目录中,有两个库文件(google提供的插件),用来实现半同步:

[root@mysql_salver plugin]# pwd
/usr/lib64/mysql/plugin
[root@mysql_salver plugin]# ls semisync_slave.so semisync_master.so 
semisync_master.so  semisync_slave.so

对于master需要加载semisync_master.so库

MariaDB [(none)]> SHOW GLOBAL VARIABLES LIKE '%rpl%';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| rpl_recovery_rank | 0     |
+-------------------+-------+
1 row in set (0.00 sec)

MariaDB [(none)]> INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
Query OK, 0 rows affected (0.10 sec)

MariaDB [(none)]> SHOW GLOBAL VARIABLES LIKE '%rpl%';
+------------------------------------+-------+
| Variable_name                      | Value |
+------------------------------------+-------+
| rpl_recovery_rank                  | 0     |
| rpl_semi_sync_master_enabled       | OFF   |  #是否开启半同步master端
| rpl_semi_sync_master_timeout       | 10000 |  #超时时间
| rpl_semi_sync_master_trace_level   | 32    |  #级别
| rpl_semi_sync_master_wait_no_slave | ON    |  #如果没有slave,是否等待
+------------------------------------+-------+
5 rows in set (0.00 sec)

MariaDB [(none)]> SET GLOBAL rpl_semi_sync_master_enabled=1;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SET GLOBAL rpl_semi_sync_master_timeout=1000;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW GLOBAL VARIABLES LIKE '%rpl%';
+------------------------------------+-------+
| Variable_name                      | Value |
+------------------------------------+-------+
| rpl_recovery_rank                  | 0     |
| rpl_semi_sync_master_enabled       | ON    |
| rpl_semi_sync_master_timeout       | 1000  |
| rpl_semi_sync_master_trace_level   | 32    |
| rpl_semi_sync_master_wait_no_slave | ON    |
+------------------------------------+-------+
5 rows in set (0.00 sec)

对于从服务器需要加载semisync_slave.so模块:

MariaDB [(none)]> INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';
Query OK, 0 rows affected (0.06 sec)

MariaDB [(none)]> SHOW GLOBAL VARIABLES LIKE '%rpl%';
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| rpl_recovery_rank               | 0     |
| rpl_semi_sync_slave_enabled     | OFF   |
| rpl_semi_sync_slave_trace_level | 32    |
+---------------------------------+-------+
3 rows in set (0.00 sec)

MariaDB [(none)]> SET GLOBAL rpl_semi_sync_slave_enabled=1;
Query OK, 0 rows affected (0.00 sec)

只有在重新启动IO_THREAD后才会生效:

MariaDB [(none)]> STOP SLAVE IO_THREAD;
Query OK, 0 rows affected (0.07 sec)

MariaDB [(none)]> START SLAVE IO_THREAD;
Query OK, 0 rows affected (0.00 sec)

如何查看是否在Master上添加了半同步客户端?:

MariaDB [(none)]> SHOW GLOBAL STATUS LIKE '%rpl%';
+--------------------------------------------+-------------+
| Variable_name                              | Value       |
+--------------------------------------------+-------------+
| Rpl_semi_sync_master_clients               | 1           |
| Rpl_semi_sync_master_net_avg_wait_time     | 0           |
| Rpl_semi_sync_master_net_wait_time         | 0           |
| Rpl_semi_sync_master_net_waits             | 0           |
| Rpl_semi_sync_master_no_times              | 0           |
| Rpl_semi_sync_master_no_tx                 | 0           |
| Rpl_semi_sync_master_status                | ON          |
| Rpl_semi_sync_master_timefunc_failures     | 0           |
| Rpl_semi_sync_master_tx_avg_wait_time      | 0           |
| Rpl_semi_sync_master_tx_wait_time          | 0           |
| Rpl_semi_sync_master_tx_waits              | 0           |
| Rpl_semi_sync_master_wait_pos_backtraverse | 0           |
| Rpl_semi_sync_master_wait_sessions         | 0           |
| Rpl_semi_sync_master_yes_tx                | 0           |
| Rpl_status                                 | AUTH_MASTER |
+--------------------------------------------+-------------+
15 rows in set (0.00 sec)
#可以看到Rpl_semi_sync_master_clients为1,就是我们添加的SLAVE

半同步模式下,如果SLAVE的IO_THREAD一直在运行,那么就是在同步处理,当IO_THREAD关闭后,会在连接超时后,自动变异步模式:

如果SLAVE的IO_THREAD在运行,在master直行sql语句,执行时间:

MariaDB [test_copy]> CREATE TABLE test2(id INT);
Query OK, 0 rows affected (0.20 sec)
#用了0.20秒,这是因为执行该命令,做了同步,所以消耗时间比较长

如果SLAVE的IO_THREAD在此时关闭了,那么连接超时后,会自动降级异步模式:

SLAVE上执行:

MariaDB [(none)]> STOP SLAVE IO_THREAD;
Query OK, 0 rows affected (0.34 sec)

MASTER上执行sql命令:

MariaDB [test_copy]> CREATE TABLE test3(id INT);
Query OK, 0 rows affected (1.27 sec)
#这里创建一个表用了1.27秒,因为我们设置的超时时间为1秒,所以这是在超时后,才执行的SQL指令

mysql主从复制管理

percona提供了对mysql的主动复制的管理。如:查看主从服务器之间延迟。

percona提供了percona tools。

安装percona tools:

[root@mysql ~]# ls
anaconda-ks.cfg  fsx.sh  percona-toolkit-3.0.10-1.el7.x86_64.rpm
[root@mysql ~]# yum install percona-toolkit-3.0.10-1.el7.x86_64.rpm 
#安装包可以在percona官网下载

安装成功后,会有很多以pt开头的命令:

[root@mysql ~]# pt
pt-align                  pt-ioprofile              pt-slave-delay
pt-archiver               pt-kill                   pt-slave-find
pt-config-diff            pt-mext                   pt-slave-restart
pt-deadlock-logger        pt-mongodb-query-digest   pt-stalk
pt-diskstats              pt-mongodb-summary        pt-summary
pt-duplicate-key-checker  pt-mysql-summary          pt-table-checksum
pt-fifo-split             pt-online-schema-change   pt-table-sync
pt-find                   pt-pmp                    pt-table-usage
pt-fingerprint            pt-query-digest           pt-upgrade
pt-fk-error-logger        pt-secure-collect         pt-variable-advisor
pt-heartbeat              pt-show-grants            pt-visual-explain
pt-index-usage            pt-sift                   ptx
[root@mysql ~]# pt-slave-delay -h
Option h requires an argument
Usage: pt-slave-delay [OPTIONS] SLAVE_DSN [MASTER_DSN]

Errors in command-line arguments:
  * Error parsing options
  * Missing or invalid slave host

pt-slave-delay starts and stops a slave server as needed to make it lag behind
the master.  The SLAVE_DSN and MASTER_DSN use DSN syntax, and values are copied
from the SLAVE_DSN to the MASTER_DSN if omitted.  For more details, please use
the --help option, or try 'perldoc /usr/bin/pt-slave-delay' for complete
documentation.

具体使用方法都可以使用-h选项进行查看,如:

[root@mysql ~]# pt-mysql-summary    #获取主服务器信息
# Percona Toolkit MySQL Summary Report #######################
              System time | 2018-06-03 20:24:00 UTC (local TZ: CST +0800)
# Instances ##################################################
  Port  Data Directory             Nice OOM Socket
  ===== ========================== ==== === ======
        /var/lib/mysql             0    0   /var/lib/mysql/mysql.sock
# MySQL Executable ###########################################
       Path to executable | /usr/libexec/mysqld
              Has symbols | No
# Slave Hosts ################################################
*************************** 1. row ***************************
Server_id: 2
     Host: 
     Port: 3306
Master_id: 1
# Report On Port 3306 ########################################
                     User | root@localhost
                     Time | 2018-06-04 04:24:00 (CST)
                 Hostname | mysql
                  Version | 5.5.35-MariaDB-log MariaDB Server
                 Built On | Linux x86_64
                  Started | 2018-06-04 02:17 (up 0+02:06:26)
                Databases | 12
                  Datadir | /var/lib/mysql/
                Processes | 4 connected, 2 running
              Replication | Is not a slave, has 1 slaves connected
                  Pidfile | /var/run/mariadb/mariadb.pid (exists)
# Processlist ################################################

  Command                        COUNT(*) Working SUM(Time) MAX(Time)
  ------------------------------ -------- ------- --------- ---------
  Binlog Dump                           1       1      1750      1750
  Query                                 1       1         0         0
  Sleep                                 2       0      6000      4000

  User                           COUNT(*) Working SUM(Time) MAX(Time)
  ------------------------------ -------- ------- --------- ---------
  copyuser                              1       1      1750      1750
  root                                  3       1         0         0

  Host                           COUNT(*) Working SUM(Time) MAX(Time)
  ------------------------------ -------- ------- --------- ---------
  172.25.254.8                          1       1      1750      1750
  localhost                             3       1         0         0

  db                             COUNT(*) Working SUM(Time) MAX(Time)
  ------------------------------ -------- ------- --------- ---------
  NULL                                  2       2      1750      1750
  test_copy                             2       0         0         0

  State                          COUNT(*) Working SUM(Time) MAX(Time)
  ------------------------------ -------- ------- --------- ---------
                                        2       0         0         0
  Master has sent all binlog to         1       1      1750      1750
  NULL                                  1       1         0         0

# Status Counters (Wait 10 Seconds) ##########################
Variable                                Per day  Per second     10 secs
Aborted_clients                              35                        
Aborted_connects                             10                        
Access_denied_errors                         10                        
Aria_pagecache_blocks_unused             175000           2            
Aria_pagecache_blocks_used                   25                        
Aria_pagecache_read_requests               1500                       4
Aria_pagecache_reads                         60                        
Aria_pagecache_write_requests                70                        
Binlog_commits                              150                        
Binlog_group_commits                        150                        
Binlog_snapshot_position                   5000                        
Binlog_bytes_written                      50000                        
Binlog_cache_use                            150                        
Bytes_received                           200000           2         300
Bytes_sent                              2000000          25        2500
Com_admin_commands                           35                        
Com_change_db                                25                        
Com_create_db                                25                        
Com_create_table                             45                        
Com_flush                                    25                        
Com_grant                                    10                        
Com_help                                     35                        
Com_insert                                  150                        
Com_install_plugin                           10                        
Com_kill                                     10                        
Com_select                                 1000                       2
Com_set_option                              125                        
Com_show_binlog_events                       10                        
Com_show_binlogs                             25                        
Com_show_databases                           80                        
Com_show_engine_status                       25                        
Com_show_fields                              45                        
Com_show_master_status                       60                        
Com_show_plugins                             25                        
Com_show_processlist                         25                        
Com_show_slave_hosts                         25                        
Com_show_slave_status                        25                        
Com_show_status                             125                        
Com_show_storage_engines                     10                        
Com_show_tables                              35                        
Com_show_variables                          175                        
Connections                                 800                       1
Created_tmp_disk_tables                     250                       1
Created_tmp_files                            70                        
Created_tmp_tables                         2000                       6
Empty_queries                                60                        
Flush_commands                               25                        
Handler_commit                              300                        
Handler_prepare                             300                        
Handler_read_first                           25                        
Handler_read_key                             80                        
Handler_read_next                            25                        
Handler_read_rnd_next                     50000                      50
Handler_tmp_write                         50000                      50
Handler_write                               200                        
Innodb_adaptive_hash_cells              3000000          35            
Innodb_adaptive_hash_non_hash_searches        1000                        
Innodb_background_log_sync                  300                        
Innodb_buffer_pool_bytes_data          60000000         600            
Innodb_buffer_pool_pages_flushed            700                        
Innodb_buffer_pool_read_requests          15000                        
Innodb_buffer_pool_reads                   3000                        
Innodb_buffer_pool_write_requests          2500                        
Innodb_checkpoint_max_age              90000000        1000            
Innodb_checkpoint_target_age           90000000        1000            
Innodb_data_fsyncs                          700                        
Innodb_data_read                       80000000         900            
Innodb_data_reads                          3500                        
Innodb_data_writes                         1250                        
Innodb_data_written                    22500000         250            
Innodb_dblwr_pages_written                  700                        
Innodb_dblwr_writes                          60                        
Innodb_descriptors_memory                 90000           1            
Innodb_dict_tables                          175                        
Innodb_history_list_length                   10                        
Innodb_ibuf_segment_size                     25                        
Innodb_ibuf_size                             10                        
Innodb_log_write_requests                   400                        
Innodb_log_writes                           350                        
Innodb_lsn_current                     22500000         250            
Innodb_lsn_flushed                     22500000         250            
Innodb_lsn_last_checkpoint             22500000         250            
Innodb_master_thread_1_second_loops         300                        
Innodb_master_thread_10_second_loops          25                        
Innodb_master_thread_background_loops         125                        
Innodb_master_thread_main_flush_loops         125                        
Innodb_master_thread_sleeps                 300                        
Innodb_max_trx_id                         40000                        
Innodb_mem_adaptive_hash               25000000         300            
Innodb_mem_dictionary                   7000000          80            
Innodb_mem_total                     1500000000       17500            
Innodb_oldest_view_low_limit_trx_id       40000                        
Innodb_os_log_fsyncs                        450                        
Innodb_os_log_written                    350000           4            
Innodb_pages_created                        175                        
Innodb_pages_read                          3000                        
Innodb_pages_written                        700                        
Innodb_read_views_memory                   2000                        
Innodb_rows_inserted                        175                        
Innodb_rows_read                             35                        
Innodb_s_lock_os_waits                       80                        
Innodb_s_lock_spin_rounds                  2500                        
Innodb_s_lock_spin_waits                     80                        
Key_read_requests                           450                        
Key_reads                                   150                        
Key_write_requests                           25                        
Key_writes                                   25                        
Open_table_definitions                      500                        
Opened_files                               2500                       4
Opened_table_definitions                    150                        
Opened_tables                               150                        
Queries                                    3000                       5
Questions                                  3000                       5
Rows_read                                   450                        
Rows_sent                                 50000                      50
Rows_tmp_read                             50000                      50
Rpl_semi_sync_master_clients                 10                        
Rpl_semi_sync_master_net_avg_wait_time      450000           5            
Rpl_semi_sync_master_net_wait_time      1500000          15            
Rpl_semi_sync_master_net_waits               35                        
Rpl_semi_sync_master_no_times                10                        
Rpl_semi_sync_master_no_tx                   10                        
Rpl_semi_sync_master_tx_avg_wait_time        4000                        
Rpl_semi_sync_master_tx_wait_time          4000                        
Rpl_semi_sync_master_tx_waits                10                        
Rpl_semi_sync_master_yes_tx                  10                        
Select_scan                                 500                        
Syncs                                       200                        
Table_locks_immediate                       900                        
Threads_created                             800                       1
Uptime                                    90000           1           1
# Table cache ################################################
                     Size | 400
                    Usage | 9%
# Key Percona Server features ################################
      Table & Index Stats | Disabled
     Multiple I/O Threads | Enabled
     Corruption Resilient | Enabled
      Durable Replication | Disabled
     Import InnoDB Tables | Disabled
     Fast Server Restarts | Disabled
         Enhanced Logging | Disabled
     Replica Perf Logging | Not Supported
      Response Time Hist. | Not Supported
          Smooth Flushing | Enabled
      HandlerSocket NoSQL | Not Supported
           Fast Hash UDFs | Unknown
# Percona XtraDB Cluster #####################################
# Plugins ####################################################
       InnoDB compression | ACTIVE
# Query cache ################################################
         query_cache_type | ON
                     Size | 0.0
                    Usage | 0%
         HitToInsertRatio | 0%
# Semisynchronous Replication ################################
   master semisync status | 
       master trace level | 32, net wait (more information about network waits)
master timeout in milliseconds | 1000
  master waits for slaves | ON
           master clients | 
 master net_avg_wait_time | 
     master net_wait_time | 
         master net_waits | 
          master no_times | 
             master no_tx | 
 master timefunc_failures | 
  master tx_avg_wait_time | 
      master tx_wait_time | 
          master tx_waits | 
master wait_pos_backtraverse | 
     master wait_sessions | 
            master yes_tx | 
                    Slave | Disabled
# Schema #####################################################
Specify --databases or --all-databases to dump and summarize schemas
# Noteworthy Technologies ####################################
                      SSL | No
     Explicit LOCK TABLES | No
           Delayed Insert | No
          XA Transactions | No
              NDB Cluster | No
      Prepared Statements | No
 Prepared statement count | 0
# InnoDB #####################################################
                  Version | 5.5.35-MariaDB-33.0
         Buffer Pool Size | 128.0M
         Buffer Pool Fill | 3%
        Buffer Pool Dirty | 0%
           File Per Table | ON
                Page Size | 16k
            Log File Size | 2 * 5.0M = 10.0M
          Log Buffer Size | 8M
             Flush Method | 
      Flush Log At Commit | 1
               XA Support | ON
                Checksums | ON
              Doublewrite | ON
          R/W I/O Threads | 4 4
             I/O Capacity | 200
       Thread Concurrency | 0
      Concurrency Tickets | 500
       Commit Concurrency | 0
      Txn Isolation Level | REPEATABLE-READ
        Adaptive Flushing | ON
      Adaptive Checkpoint | 
           Checkpoint Age | 0
             InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
       Oldest Transaction | 0 Seconds
         History List Len | 1
               Read Views | 1
         Undo Log Entries | 0 transactions, 0 total undo, 0 max undo
        Pending I/O Reads | 0 buf pool reads, 0 normal AIO, 0 ibuf AIO, 0 preads
       Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
      Pending I/O Flushes | 0 buf pool, 0 log
       Transaction States | 3xnot started
# MyISAM #####################################################
                Key Cache | 128.0M
                 Pct Used | 20%
                Unflushed | 0%
# Security ###################################################
                    Users | 9 users, 0 anon, 1 w/o pw, 1 old pw
            Old Passwords | OFF
# Encryption #################################################
Warning: /usr/bin/mysql: ignoring option '--named-commands' due to invalid value 'root'
No keyring plugins found
# Binary Logging #############################################
                  Binlogs | 2
               Zero-Sized | 0
               Total Size | 4.9k
            binlog_format | MIXED
         expire_logs_days | 0
              sync_binlog | 0
                server_id | 1
             binlog_do_db | 
         binlog_ignore_db | 
# Noteworthy Variables #######################################
     Auto-Inc Incr/Offset | 1/1
   default_storage_engine | InnoDB
               flush_time | 0
             init_connect | 
                init_file | 
                 sql_mode | 
         join_buffer_size | 128k
         sort_buffer_size | 2M
         read_buffer_size | 128k
     read_rnd_buffer_size | 256k
       bulk_insert_buffer | 0.00
      max_heap_table_size | 16M
           tmp_table_size | 16M
       max_allowed_packet | 1M
             thread_stack | 288k
                      log | OFF
                log_error | /var/log/mariadb/mariadb.log
             log_warnings | 1
         log_slow_queries | OFF
log_queries_not_using_indexes | OFF
        log_slave_updates | OFF
# Configuration File #########################################
              Config File | /etc/my.cnf

[mysqld]
datadir                             = /var/lib/mysql
socket                              = /var/lib/mysql/mysql.sock
symbolic-links                      = 0
log_bin                             = master-bin 
log_bin_index                       = master-bin.index
innodb_file_per_table               = ON
binlog_format                       = MIXED
server_id                           = 1
sync_binlog                         = ON

[mysqld_safe]
log-error                           = /var/log/mariadb/mariadb.log
pid-file                            = /var/run/mariadb/mariadb.pid
# Memory management library ##################################
jemalloc is not enabled in mysql config for process with id 16029
# The End ####################################################
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值