MySQL Best Practices On NetApp SolidFire
MySQL Best Practices On NetApp SolidFire
Abstract
MySQL is widely used for many online applications, from global social networking sites and
massive e-commerce systems to SMB hosting systems containing thousands of database
instances. Managing the sprawl of commodity hardware that is associated with large-scale
MySQL deployments can be a massive operational undertaking. Supporting various service
and performance levels creates a complex hardware environment in which one size might
not fit all. This document describes using the capabilities of NetApp® SolidFire® storage to
solve business problems associated with streamlining MySQL operations.
TABLE OF CONTENTS
1 Introduction ........................................................................................................................................... 4
1.1 Thin Provisioning ............................................................................................................................................4
8 Conclusion .......................................................................................................................................... 16
2 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
Appendix A: Master my.cnf ..................................................................................................................... 17
3 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
1 Introduction
NetApp SolidFire storage systems were born out of some of the largest cloud infrastructures in the world.
They are designed to serve next-generation data center needs, including scaling with multitenancy, set-
and-forget management, and guaranteed performance. Adopting the SolidFire architecture provides you
with greater predictability for your shared storage infrastructure. SolidFire storage optimizes solid-state
drive (SSD) capacity to create high utilization and volume performance.
NetApp SolidFire storage systems have the following features to support next-generation data center
needs:
• Thin provisioning
• Compression and deduplication
• Quality of service (QoS)
These features reduce the amount of storage space that is required without affecting performance. You
can use these features with various database use cases.
4 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
1.3 Quality of Service
SolidFire storage arrays present performance and capacity as dynamic, independent pools. This feature
enables administrators to set the performance requirements for all the databases or tenants that are
hosted on the same cluster. The minimum, maximum, and burst control settings in QoS guarantee
required performance levels and can be dynamically changed anytime. If the SolidFire hardware
resources are pushed to their physical limits, more nodes can be added to the existing cluster. SolidFire
Helix data distribution automatically redistributes data for optimal load balancing over all hardware
resources. This process is transparent to upstream applications.
3 Storage Configuration
This section shows how to configure SolidFire volumes to support a MySQL database application.
NetApp recommends that you have all the MySQL database components on the SolidFire storage array.
5 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
NetApp supports presenting the storage in a 4K sector size (native mode) and in a traditional 512-byte
sector size (512e). Tests conducted in NetApp labs have demonstrated that there is no performance
effect for choosing emulation mode as long as there is no partition misalignment at the host level.
6 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
3. Click Create Volume. The Create a New Volume window opens.
4. Enter the volume name (1 to 64 characters in length). For example, enter the name MySQL-Data1.
5. Enter the size of the volume.
6. Click the Account drop-down list and select the account that should have access to the volume. In
this case, select MySQL.
7. Set the Quality of Service Settings values according to your requirements.
Note: The sliders may be used to adjust the IOPS values, or click the number field to enter the
desired IOPS values. For MySQL-Data1, use the following values: maximum = 100,000,
minimum = 15,000, and burst = 100,000.
8. Click Create Volume.
9. Repeat steps 1 through 7 for all volumes that are part of the MySQL database.
7 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
• A single volume can belong to a maximum of four access groups.
To create volume access groups, complete the following steps:
1. Log in to the Element OS web UI.
2. Select Management Access Groups. The Access Group window opens.
3. Click Create Access Group. The Create a New Access Group window opens.
8 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
11. Scroll to the bottom and click Add to Volume Access Group. The Add to Volume Access Group
window opens.
12. Select the previously created volume access group from the drop-down list.
13. Click Add to join the selected volumes to the target group.
The MySQL database volumes are now listed as part of the selected volume access group and are ready
to be mapped to the host operating system.
Note: For this configuration, two SolidFire volumes were chosen for the MySQL database, and an LVM
configuration was used to stripe data across both volumes. For a web-scale deployment that
involves hundreds of databases, NetApp recommends that you configure one volume for
individual databases and that you control performance through the QoS settings.
9 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
4.3 Optimize Network Performance
Consider the following guidelines for optimal network performance:
• Enable jumbo frames for all host network interfaces.
• To isolate the data traffic, configure the interface that is used for the MySQL data traffic with a
different subnet from the public network.
10 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
4.6 Configure the Multipath Driver
Configure the Linux multipath driver (multipathd) by making the following changes to the
/etc/multipath.conf file.
defaults {
user_friendly_names yes
}
devices {
device {
vendor "SolidFir"
product "SSD SAN"
path_grouping_policy multibus
path_checker tur
hardware_handler "0"
failback immediate
rr_weight uniform
rr_min_io 10
rr_min_io_rq 10
features "0"
no_path_retry 24
prio const
}
}
Optionally, you can enable persistent mapping of /dev/mapper entries by associating the NetApp
SolidFire storage system device's worldwide ID (WWID) with a specific operating system alias. For this
option, make the following additions to the /etc/multipath.conf file.
multipaths {
multipath {
wwid 36f47acc100000000707a646c000003b1
alias mysql-disk1
}
multipath {
wwid 36f47acc100000000707a646c00000003
alias mysql-disk2
}
}
You can check the status of the multipath daemon with the following command:
systemctl list-unit-files|grep multipath
multipathd.service enabled
11 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
2. Create a logical volume on this volume group.
lvcreate -l 100%FREE -n mysqldatalv mysqldatavg
Before you install MySQL, you should set appropriate permissions so that the MySQL user can access
the devices on the SolidFire system. You can set permissions on multipath devices by creating a udev
rule file that allows appropriate access to the devices.
5 MySQL Configuration
Note: This step is used in step 18 of the section “Clone a Volume” to initiate slave replication.
3. To put the MySQL database into a consistent state to take an application-consistent storage
snapshot, run the following commands. These commands make sure that the database is in a
consistent state before a snapshot is taken at the SolidFire storage array. Step 2 provides the binary
location entered in this step.
FLUSH TABLES WITH READ LOCK;
PURGE BINARY LOGS TO LOCATION ‘XXXX’;
4. Run the command to flush the file system buffers. This step flushes all changes to storage.
sync
12 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
9. In the Create Group Snapshot of Volumes window, enter a name for the snapshot (Snap1 in this
case).
10. Set the desired retention time.
11. Select Take Group Snapshot Now or Create Group Snapshot Schedule.
12. Scroll to the bottom and click Create Group Snapshot.
13 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
2. Log in to the SolidFire Element OS UI.
3. Select Data ProtectionGroup Snapshots. The Group Snapshot list opens.
14 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
consume extra disk space at the time of creation. Users can connect to the newly created slave copies
after they are activated and work completely independently of the master copy.
3. From the Actions button, select Clone Volumes from Group Snapshot.
4. The Clone Volumes from Group Snapshot window opens.
5. Enter a prefix (CL for this example).
6. Give the account and access information, depending on what access you need for the clone volumes.
15 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
iscsiadm -m node -L all
mount -t xfs -o nobarrier,discard,noatime /dev/mysqlvg/mysqllv /var/lib/mysql
12. Edit the /etc/my.cnf file to change the server-id from master to slave. In this case, the server
ID was changed to 2 from 1. A sample slave my.cnf file is provided in Appendix B.
Server-id = 2
13. Remove the auto.cnf file that has the server UUID referencing to the original master server. This
file is under the data directory (for example, /var/lib/mysql/auto.cnf).
14. Start the MySQL instance.
systemctl start mysql
15. To verify that the server ID is different on the slave server, run the following command in the MySQL
shell.
show variables like 'server_id';
16. Create a replication user on the master server and grant the privilege.
CREATE USER repl@localhost;
GRANT REPLICATION SLAVE ON *.* TO repl@slavehost IDENTIFIED BY 'password';
17. Check the log file and log position on the master provided in step 18.
SHOW MASTER STATUS;
18. To initiate the replication between the master and the slave, log in to the MySQL shell and run the
following commands. The bin log information is captured from section 6.1, step 4.
CHANGE MASTER TO
-> MASTER_HOST = 'master-ip', IP address of the master server
-> MASTER_USER = 'repl', Replication user
-> MASTER_PASSWORD = 'password', Replication password
-> MASTER_LOG_FILE = 'bin-log-file-name', Bin log file name from
-> MASTER_LOG_POS = bin-log-position-number; Bin log position during the snapshot
START SLAVE;
19. To check the status of the slave, run the following command. A sample output is given in Appendix A.
SHOW SLAVE STATUS;
8 Conclusion
SolidFire provides an optimal storage system for database applications that use all-flash media,
improving performance and providing significant storage savings. This architecture benefits system
planners deploying and maintaining MySQL databases, as can be seen in the use cases outlined in this
document. For additional information, you can contact SolidFire directly at [email protected].
16 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
Appendix A: Master my.cnf
[mysqld]
server-id = 1
# INNODB CONFIG
innodb_buffer_pool_size = 4G
innodb_log_buffer_size = 64M
innodb_log_file_size = 1G
innodb_file_per_table = 1
innodb_flush_method = O_DIRECT
innodb_write_io_threads = 64
innodb_read_io_threads = 64
innodb_lock_wait_timeout = 5
innodb_adaptive_flushing = 1
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_thread_concurrency = 0
character-set-server=utf8
wait_timeout = 86400
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
skip-external-locking
max_allowed_packet = 1024M
thread_stack = 192K
thread_cache_size = 1000
max_connections = 2048
query_cache_limit = 1M
query_cache_size = 16M
general_log_file = /var/log/mysql.log
general_log = 1
long_query_time = 2
log-bin=mysql-bin
expire_logs_days = 5
max_binlog_size = 1G
server_id = 1
binlog_do_db = include_database_name
binlog_ignore_db = include_database_name
binlog_format = STATEMENT
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
server-id = 2
# INNODB CONFIG
innodb_buffer_pool_size = 4G
innodb_log_buffer_size = 64M
innodb_log_file_size = 1G
innodb_file_per_table = 1
innodb_flush_method = O_DIRECT
innodb_write_io_threads = 64
innodb_read_io_threads = 64
innodb_lock_wait_timeout = 5
innodb_adaptive_flushing = 1
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_thread_concurrency = 0
17 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
character-set-server=utf8
wait_timeout = 86400
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
skip-external-locking
#key_buffer = 16M
max_allowed_packet = 1024M
thread_stack = 192K
thread_cache_size = 1000
max_connections = 2048
query_cache_limit = 1M
query_cache_size = 16M
general_log_file = /var/log/mysql.log
general_log = 1
long_query_time = 2
log-bin=mysql-bin
expire_logs_days = 5
max_binlog_size = 1G
server_id = 2
binlog_do_db = include_database_name
binlog_ignore_db = include_database_name
binlog_format = STATEMENT
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
18 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
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
Master_UUID: 10496bb5-f2c3-11e6-8f91-005056bb5fd7
Master_Info_File: /var/lib/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
Version History
Version Date Document Version History
Version 1.0 June 2014 Initial document creation
Version 2.1 November 2017 Changed the "References" section to "Where to Find
Additional Information." Minor edits.
19 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.
Copyright Information
Copyright © 2014–2017 NetApp, Inc. All rights reserved. Printed in the U.S. No part of this document
covered by copyright may be reproduced in any form or by any means—graphic, electronic, or
mechanical, including photocopying, recording, taping, or storage in an electronic retrieval system—
without prior written permission of the copyright owner.
Software derived from copyrighted NetApp material is subject to the following license and disclaimer:
THIS SOFTWARE IS PROVIDED BY NETAPP “AS IS” AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WHICH ARE HEREBY
DISCLAIMED. IN NO EVENT SHALL NETAPP BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
NetApp reserves the right to change any products described herein at any time, and without notice.
NetApp assumes no responsibility or liability arising from the use of products described herein, except as
expressly agreed to in writing by NetApp. The use or purchase of this product does not convey a license
under any patent rights, trademark rights, or any other intellectual property rights of NetApp.
The product described in this manual may be protected by one or more U.S. patents, foreign patents, or
pending applications.
RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the government is subject to
restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software
clause at DFARS 252.277-7103 (October 1988) and FAR 52-227-19 (June 1987).
Trademark Information
NETAPP, the NETAPP logo, and the marks listed at http://www.netapp.com/TM are trademarks of
NetApp, Inc. Other company and product names may be trademarks of their respective owners.
20 MySQL Best Practices on NetApp SolidFire © 2017 NetApp, Inc. All Rights Reserved.