mysql_redolog配置变更实录

mysql redo与oracle redo原理一致。也是通过顺序写,记录数据变化 以便完成恢复。
不过mysql 想要完全实现oracle redo log archive log 功能,需要借助两种日志来完成 
分别为 redo log 与 binlog 
其中redo 只能实现实例级别的恢复。即MYSQL 异常宕机,进程被杀重启所需进行的恢复。

而完全恢复 不完全恢复 热备等还是需要binlog的配合

本文记录了mysql redo log 配置的方法与步骤

1 查看当前目录状态

[root@localhost mysql]# ll
total 110624
-rw-rw---- 1 mysql mysql       56 Nov 29 09:45 auto.cnf
drwx------ 2 mysql mysql     4096 Nov 29 09:48 dao
-rw-rw---- 1 mysql mysql 12582912 Nov 29 09:48 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Nov 29 09:48 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Nov 29 08:16 ib_logfile1
-rw-rw---- 1 mysql mysql        5 Nov 29 09:45 localhost.localdomain.pid
drwx------ 2 mysql mysql     4096 Nov 29 08:16 mysql
srwxrwxrwx 1 mysql mysql        0 Nov 29 09:45 mysql.sock
drwx------ 2 mysql mysql     4096 Nov 29 08:16 performance_schema
-rw-r--r-- 1 root  root       117 Nov 29 08:16 RPM_UPGRADE_HISTORY
-rw-r--r-- 1 mysql mysql      117 Nov 29 08:16 RPM_UPGRADE_MARKER-LAST
drwx------ 2 mysql mysql     4096 Nov 29 08:16 test

2 查看各个参数
mysql>  show variables like 'innodb_log%';
+-------------------------------+----------+
| Variable_name                 | Value    |
+-------------------------------+----------+
| innodb_log_arch_dir           | ./       |
| innodb_log_arch_expire_sec    | 0        |
| innodb_log_archive            | OFF      |
| innodb_log_block_size         | 512      |
| innodb_log_buffer_size        | 8388608  |
| innodb_log_checksum_algorithm | innodb   |
| innodb_log_compressed_pages   | ON       |
| innodb_log_file_size          | 50331648 |
| innodb_log_files_in_group     | 2        |
| innodb_log_group_home_dir     | ./       |
+-------------------------------+----------+
10 rows in set (0.00 sec)

3 创建目录 注:创建一个新的目录可以挂载一个不同的文件系统
[root@localhost mysql]# mkdir redolog  
[root@localhost mysql]# ll
total 110624
-rw-rw---- 1 mysql mysql       56 Nov 29 09:45 auto.cnf
drwx------ 2 mysql mysql     4096 Nov 29 09:48 dao
-rw-rw---- 1 mysql mysql 12582912 Nov 29 10:33 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Nov 29 10:33 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Nov 29 08:16 ib_logfile1
drwx------ 2 mysql mysql     4096 Nov 29 08:16 mysql
drwx------ 2 mysql mysql     4096 Nov 29 08:16 performance_schema
drwxr-xr-x 2 root  root      4096 Nov 29 11:19 redolog
-rw-r--r-- 1 root  root       117 Nov 29 08:16 RPM_UPGRADE_HISTORY
-rw-r--r-- 1 mysql mysql      117 Nov 29 08:16 RPM_UPGRADE_MARKER-LAST
drwx------ 2 mysql mysql     4096 Nov 29 08:16 test
[root@localhost mysql]# chown mysql:mysql redolog
4 修改参数 
[root@localhost mysql]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
innodb_log_group_home_dir=./redolog
innodb_log_file_size=536870912
innodb_log_buffer_size=33554432
innodb_log_files_in_group=2
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

5 重启mysql实例

[root@localhost ~]# service mysql stop
Shutting down MySQL (Percona Server)..[  OK  ]
[root@localhost mysql]# service mysql start
Starting MySQL (Percona Server).........[  OK  ]
6 查看修改后的参数
mysql> show variables like 'innodb_log%';
+-------------------------------+------------+
| Variable_name                 | Value      |
+-------------------------------+------------+
| innodb_log_arch_dir           | ./redolog/ |
| innodb_log_arch_expire_sec    | 0          |
| innodb_log_archive            | OFF        |
| innodb_log_block_size         | 512        |
| innodb_log_buffer_size        | 33554432   |
| innodb_log_checksum_algorithm | innodb     |
| innodb_log_compressed_pages   | ON         |
| innodb_log_file_size          | 536870912  |
| innodb_log_files_in_group     | 2          |
| innodb_log_group_home_dir     | ./redolog/ |
+-------------------------------+------------+

7 查看新的redolog 
[root@localhost mysql]# du -h ./redolog/*
512M    ./redolog/ib_logfile0
513M    ./redolog/ib_logfile1

你可能感兴趣的:(MYSQL)