修改innodb redo log的大小组数

1、

If for any reason you need to change the size of InnoDB log files (also known as transaction logs), but not sure how to do it, this post will guide you through the steps.

Step 1: Preflight checks

Something to keep in mind

Database restart is needed as part of this process.

Locate your MySQL configuration file

If you don’t know where the configuration file is, you can follow one of my previous posts on How to find MySQL configuration file?.

Find the existing logs and check their size

If database is running, you can simply use a tool called lsof:

db01 ~ # lsof -c mysqld | grep ib_logfile

mysqld    15153 mysql    9uW     REG                8,3 5242880 19350809 /var/lib/mysql/ib_logfile0

mysqld    15153 mysql   10uW     REG                8,3 5242880 19350810 /var/lib/mysql/ib_logfile1

lsof not only shows paths, but also the file sizes (marked in red).

Check InnoDB shutdown mode

Check the value of SHOW GLOBAL VARIABLES LIKE 'innodb_fast_shutdown'. The setting determines how InnoDB performs shutdown. If you are running on MySQL 5.0 or newer, it is a very important step, so do not forget about it.

innodb_fast_shutdown can be configured one of three different values:

    - 0 – InnoDB will clean up old and redundant data and perform insert buffer merge before shutting down.

    - 1 – A fast shutdown which skips the above tasks. Its also the default one.

    - 2 – Performs a controlled crash.

If innodb_fast_shutdown is set either to 0 or 1, you can proceed to the next step. Otherwise change it:

mysql> SET GLOBAL innodb_fast_shutdown=1;

Query OK, 0 rows affected (0.00 sec)

Remember! You must not proceed with innodb_fast_shutdown set to 2!

Now you are ready to go.

Step 2: InnoDB log files resize procedure

Shut down MySQL

db01 ~ # /etc/init.d/mysql stop

 * Stopping mysql ...

 * Stopping mysqld (0)              [ ok ]

Check database error log to ensure that there were no problems with shut down. Specifically you are interested seeing the following sequence:

120403 13:47:04  InnoDB: Starting shutdown...

120403 13:47:06  InnoDB: Shutdown completed; log sequence number 1091449

120403 13:47:06 [Note] /usr/sbin/mysqld: Shutdown complete

Rename the existing transaction logs

For safety reasons you don’t want to remove the existing files at this point. If anything goes wrong, restoring them may be the only way to resurrect your database. So instead you should just rename them:

db01 ~ # find /var/lib/mysql -type f -name "ib_logfile?" -exec mv {} {}_OLD \;

In find specify the path where lsof showed the logs were. Verify that they were indeed renamed:

db01 ~ # ls -la /var/lib/mysql/ib_logfile*

-rw-rw---- 1 mysql mysql 5242880 Apr  3 01:24 /var/lib/mysql/ib_logfile0_OLD

-rw-rw---- 1 mysql mysql 5242880 Jan 31  2010 /var/lib/mysql/ib_logfile1_OLD

Reconfigure MySQL

Use your favorite editor to update the MySQL configuration file. Either add or set innodb_log_file_size parameter to the desired value. If you do not know what value to use, 64M is often a good default. Here is how it looks in my configuration file:

db01 ~ # grep innodb_log_file_size /etc/my.cnf

innodb_log_file_size = 64M

Restart MySQL instance

During start InnoDB will create new set of logs.

db01 ~ # /etc/init.d/mysql start

 * Starting mysql ...

 * Starting mysql (/etc/mysql/my.cnf)             [ ok ]

As usual, please monitor database error log. You should see output similar to this one:

[..]

120403  1:34:18  InnoDB: Log file ./ib_logfile0 did not exist: new to be created

InnoDB: Setting log file ./ib_logfile0 size to 64 MB

InnoDB: Database physically writes the file full: wait...

120403  1:34:19  InnoDB: Log file ./ib_logfile1 did not exist: new to be created

InnoDB: Setting log file ./ib_logfile1 size to 64 MB

InnoDB: Database physically writes the file full: wait...

[..]

Step 3: Done!

Your database should now be running on a new set of InnoDB logs.

修改组数也是一样需要添加

innodb_log_files_in_group =3

 操作过程和上面一模一样

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26764973/viewspace-1449856/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26764973/viewspace-1449856/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值