首頁 資料庫 mysql教程 Revisiting ZFS and MySQL_MySQL

Revisiting ZFS and MySQL_MySQL

Jun 01, 2016 pm 01:16 PM

While at Percona Live this year I was reminded about ZFS and running MySQL on top of a ZFS-based storage platform.

Now I’m a big fan of ZFS (although sadly I don’t get to use it as much as I used to after I shutdown my home server farm), and I did a lot of different testing back while at MySQL to ensure that MySQL, InnoDB and ZFS worked correctly together.

Of course today we have a completely new range of ZFS compatible environments, not least of which are FreeBSD andZFS on Linux, I think it’s time to revisit some of my original advice on using this combination.

Unfortunately the presentations and MySQL University sessions back then have all been taken down. But that doesn’t mean the advice is any less valid.

Some of the core advice for using InnoDB on ZFS:

  • Configure a single InnoDB tablespace, rather than configuring multiple tablespaces across different disks, and then let ZFS manage the underlying disk using stripes or mirrors or whatever configuration you want. This avoids you having to restart or reconfigure your tablespaces as your data grows, and moves that out to ZFS which can do it much more easily and while the filesystem and database remain online. That means we can do:
innodb_data_file_path = /zpool/data/ibdatafile:10G:autoextend
登入後複製
  • While we’re taking about the InnoDB data files, the best optimisation you can do is to set the ZFS block size to match the InnoDB block size. You should do this *before* you start writing data. That means creating the filesystem and then setting the block size:
zfs set recordsize=8K zpool/data
登入後複製
  • What you can also do is configure a separate filesystem for the InnoDB logs that has a ZPool record size of 128K. That’s less relevant in later versions of ZFS, but actually it does no harm.
  • Switch on I/O compression. Within ZFS this improves I/O time (because less data is read/written physically from/to disk), and therefore improves overall I/O times. The compression is good enough and passive to be able to handle the load while still reducing the overall time.
  • Disable the double-write buffer. The transactional nature of ZFS helps to ensure the validity of data written down to disk, so we don’t need two copies of the data to be written to ensure valid recovery in the case of failure that are normally caused by partial writes of the record data. The performance gain is small, but worth it.
  • Using direct IO (O_DIRECT in your my.cnf) also improves performance for similar reasons. We can be sure with direct writes in ZFS that the information is written down to the right place.
  • Limit the Adjustable Replacement Cache (ARC); without doing this you can end up with ZFS using a lot of cache memory that will be better used at the database level for caching record information. We don’t need the block data cache as well.
  • Configure a separate ZFS Intent Log (ZIL), really a Separate Intent Log (SLOG) – if you are not using SSD throughout, this is a great place to use SSD to speed up your overall disk I/O performance. Using SLOG stores immediate writes out to SSD, enabling ZFS to manage the more effective block writes of information out to slower spinning disks. The real difference is that this lowers disk writes, lowers latency, and lowers overall spinning disk activity, meaning they will probably last longer, not to mention making your system quieter in the process. For the sake of $200 of SSD, you could double your performance and get an extra year or so out the disks.

Surprisingly not much has changed in these key rules, perhaps the biggest different is the change in price of SSD between when I wrote these original rules and today. SSD is cheap(er) today so that many people can afford SSD as their main disk, rather than their storage format, especially if you are building serious machines.

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章

兩個點博物館:邦格荒地地點指南
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章

兩個點博物館:邦格荒地地點指南
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章標籤

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

減少在Docker中使用MySQL內存的使用 減少在Docker中使用MySQL內存的使用 Mar 04, 2025 pm 03:52 PM

減少在Docker中使用MySQL內存的使用

如何使用Alter Table語句在MySQL中更改表? 如何使用Alter Table語句在MySQL中更改表? Mar 19, 2025 pm 03:51 PM

如何使用Alter Table語句在MySQL中更改表?

mysql無法打開共享庫怎麼解決 mysql無法打開共享庫怎麼解決 Mar 04, 2025 pm 04:01 PM

mysql無法打開共享庫怎麼解決

在 Linux 中運行 MySQl(有/沒有帶有 phpmyadmin 的 podman 容器) 在 Linux 中運行 MySQl(有/沒有帶有 phpmyadmin 的 podman 容器) Mar 04, 2025 pm 03:54 PM

在 Linux 中運行 MySQl(有/沒有帶有 phpmyadmin 的 podman 容器)

什麼是 SQLite?全面概述 什麼是 SQLite?全面概述 Mar 04, 2025 pm 03:55 PM

什麼是 SQLite?全面概述

在MacOS上運行多個MySQL版本:逐步指南 在MacOS上運行多個MySQL版本:逐步指南 Mar 04, 2025 pm 03:49 PM

在MacOS上運行多個MySQL版本:逐步指南

如何保護MySQL免受常見漏洞(SQL注入,蠻力攻擊)? 如何保護MySQL免受常見漏洞(SQL注入,蠻力攻擊)? Mar 18, 2025 pm 12:00 PM

如何保護MySQL免受常見漏洞(SQL注入,蠻力攻擊)?

如何為MySQL連接配置SSL/TLS加密? 如何為MySQL連接配置SSL/TLS加密? Mar 18, 2025 pm 12:01 PM

如何為MySQL連接配置SSL/TLS加密?

See all articles