如何不丢失innodb的buffer pool的data page?

  前言

    每当我们重启mysql数据库,内存里的数据就都会丢失,特别是innodb的BP里的数据,如果一刚启动并发量大的话,产生的IO将不可估量,percona xtradb有个新特性就是可以重载data  page数据,也就是可以恢复重新启动前的data page数据,具体是由两个命令XTRA_LRU_DUMP、XTRA_LRU_RESTORE来执行的,它会在datadir目录下会产生一个ib_lru_dump文件,具体我们来看实例:



  
  
  
  
  1. mysql> show status like 'Innodb_buffer_pool_pages_data'
  2. +-------------------------------+-------+ 
  3. | Variable_name                 | Value | 
  4. +-------------------------------+-------+ 
  5. | Innodb_buffer_pool_pages_data | 5067  | 
  6. +-------------------------------+-------+ 
  7. 1 row in set (0.00 sec) 


#我们用XTRA_LRU_DUMP来备份page data里的数据,它会在datadir下产生ib_lru_dump,注意命令调用的方式

  
  
  
  
  1. mysql> select * from information_schema.XTRADB_ADMIN_COMMAND /*!XTRA_LRU_DUMP*/; 
  2. +------------------------------+ 
  3. | result_message               | 
  4. +------------------------------+ 
  5. | XTRA_LRU_DUMP was succeeded. | 
  6. +------------------------------+ 
  7. 1 row in set (0.00 sec) 



mysql> quit
Bye
[root@localhost swd]# /etc/init.d/mysqld restart
Shutting down MySQL....                                    [  OK  ]
Starting MySQL..                                           [  OK  ]
[root@localhost swd]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.45-XinYing-log Test

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
#重启数据库之后,BP里的数据会丢失。

  
  
  
  
  1. mysql> show status like 'Innodb_buffer_pool_pages_data'
  2. +-------------------------------+-------+ 
  3. | Variable_name                 | Value | 
  4. +-------------------------------+-------+ 
  5. | Innodb_buffer_pool_pages_data | 33    | 
  6. +-------------------------------+-------+ 
  7. 1 row in set (0.00 sec) 

#调用XTRA_LRU_RESTORE可以恢复重启前的BP数据

  
  
  
  
  1. mysql> select * from information_schema.XTRADB_ADMIN_COMMAND /*!XTRA_LRU_RESTORE*/; 
  2. +---------------------------------+ 
  3. | result_message                  | 
  4. +---------------------------------+ 
  5. | XTRA_LRU_RESTORE was succeeded. | 
  6. +---------------------------------+ 
  7. 1 row in set (0.17 sec) 


#再看是不是跟以前的是一样的啦

  
  
  
  
  1. mysql> show status like 'Innodb_buffer_pool_pages_data'
  2. +-------------------------------+-------+ 
  3. | Variable_name                 | Value | 
  4. +-------------------------------+-------+ 
  5. | Innodb_buffer_pool_pages_data | 5067  | 
  6. +-------------------------------+-------+ 
  7. 1 row in set (0.00 sec) 



err日志里会有以下信息显示

091217 11:49:16 InnoDB: administration command 'XTRA_LRU_DUMP' was detected.
....
091217 11:51:44 InnoDB: administration command 'XTRA_LRU_RESTORE' was detected.
091217 11:51:45 InnoDB: reading pages based on the dumped LRU list was done. (requested: 6231, read: 6209)

你可能感兴趣的:(mysql,InnoDB,休闲,percona,XtraDB)