Changes between Version 2 and Version 3 of MysqlConfig


Ignore:
Timestamp:
Apr 25, 2007, 10:51:02 AM (17 years ago)
Author:
Nicolas
Comment:

Required manual changes to automatic conversion.

Legend:

Unmodified
Added
Removed
Modified
  • MysqlConfig

    v2 v3  
    11= Configuring MySQL for BOINC =
    22
    3        A fast-and-easy script that makes recommendations for tuning server variables is [http://www.day32.com/MySQL/ here].  The mysqlreport utility gives a variety of information that can be useful for adjusting buffer pool allocations. It's available at [http://www.hackmysql.com/mysqlreport http://www.hackmysql.com/mysqlreport].
    4 
     3A fast-and-easy script that makes recommendations for tuning server variables is [http://www.day32.com/MySQL/ here].  The mysqlreport utility gives a variety of information that can be useful for adjusting buffer pool allocations. It's available at [http://www.hackmysql.com/mysqlreport http://www.hackmysql.com/mysqlreport].
    54
    65----
    76
    87== Introduction ==
    9   The note discusses how MySQL may be configured for BOINC Projects. BOINC-based projects have varying DB traffic characteristics and this note relates to our experiences with SETI@home, so it may not be entirely applicable to all projects. SETI@home currently uses MySQL 4.0+ and we expect to upgrade to 4.1 shortly and 5.0 later. Our project uses only a single instantiation of the MySQL code file and this note does not discuss the operation of multiple instances of MySQL on a single server.  All MySQL products and documentation are available at http://www.mysql.com/. Our experience has been of using MySQL with Sun Solaris and Linux OSes. MySQL on MS Windows or Mac OS X may be somewhat different.
    10 
     8
     9The note discusses how MySQL may be configured for BOINC Projects. BOINC-based projects have varying DB traffic characteristics and this note relates to our experiences with SETI@home, so it may not be entirely applicable to all projects. SETI@home currently uses MySQL 4.0+ and we expect to upgrade to 4.1 shortly and 5.0 later. Our project uses only a single instantiation of the MySQL code file and this note does not discuss the operation of multiple instances of MySQL on a single server.  All MySQL products and documentation are available at http://www.mysql.com/. Our experience has been of using MySQL with Sun Solaris and Linux OSes. MySQL on MS Windows or Mac OS X may be somewhat different.
    1110
    1211== MySQL DB Engines (or Table Types) ==
    1312
    1413=== General ===
    15   The MySQL software comprises a number of DB engines. For SETI@home DB only 2 are used, Innodb and MyISAM. They have different features and are used according to the performance requirements of the project. One can use all of the different engines (or table types) or just a single one in a MySQL DB, just depending on the query activity against each table in the project among other.  MySQL software  is available in 32 bit and 64 bit binaries for downloading. Using 32 bit MySQL requires that all RAM resources that are assigned to the various DB engines, must sum to no more than 2GB of RAM. There is no such limitation with 64 bit MySQL and large amounts of RAM help Innodb performance.
    16 
     14
     15The MySQL software comprises a number of DB engines. For SETI@home DB only 2 are used, Innodb and MyISAM. They have different features and are used according to the performance requirements of the project. One can use all of the different engines (or table types) or just a single one in a MySQL DB, just depending on the query activity against each table in the project among other. MySQL software is available in 32 bit and 64 bit binaries for downloading. Using 32 bit MySQL requires that all RAM resources that are assigned to the various DB engines, must sum to no more than 2GB of RAM. There is no such limitation with 64 bit MySQL and large amounts of RAM help Innodb performance.
    1716
    1817=== MyISAM ===
    19   The MyISAM engine requires the least amount of computer resources can be used where there is a low DB activity requirement. For example with query rates lower that 5/sec this table type may be adequate. Also if one does not have a dedicated DB server this may be a good choice for all the tables since it consumes much less computer resources. It has the advantages of allowing long text indices against tables which Innodb does not allow.  MyISAM creates an OS file for each table and one for all the indices related to the specific table (and another for the table format info).
     18
     19The MyISAM engine requires the least amount of computer resources can be used where there is a low DB activity requirement. For example with query rates lower that 5/sec this table type may be adequate. Also if one does not have a dedicated DB server this may be a good choice for all the tables since it consumes much less computer resources. It has the advantages of allowing long text indices against tables which Innodb does not allow.  MyISAM creates an OS file for each table and one for all the indices related to the specific table (and another for the table format info).
    2020
    2121On the other hand it tends to suffer from consistency glitches so will occasionally trash indices and will need rebuilding. In commercial banking environments it would not be a good idea to keep account balances in this table type since there is no guarantee that transactions even if completed and printed will remain in the DB. MyISAM updates its tables synchronously and uses memory locks to avoid data collisions. In SETI@home, MyISAM  is used for the forum tables and logging that have relatively low query rates.
    2222
    23 
    2423=== Innodb ===
    25   The Innodb engine is used for most of the tables in SETI@home project. It processes multiple simultaneous queries against its tables. It is a versioning DB engine that holds an image of the table at the start of a query and maintains it until that query is completed. Other updates are allowed during queries and in general for short queries there is no problem. Innodb uses the Innodb log  to store changes to its tables until it flushes these changes to the actual tables at syncpoints. If for any reason there is a server event that causes a system failure, Innodb will use this log to recover the Innodb tables to consistency. There are a minimum of 2 transaction log files with a total maximum size of 4GB.  Innodb tables/indices are usually stored in large OS physical files and the tables and indices are managed internally within these OS/Innodb files. It is important that these files are located on high performance devices. The transaction log files should be located on independent high performance media (away from the Innodb files) for sustained high transaction rates. At DB shutdown all modified buffers have to be flushed into the transaction logs before MySQL goes away, so slow performance drives for the transaction log could delay shutdown for over 30 minutes when there are a large number of .modified buffers. to be flushed.
    26 
     24
     25The Innodb engine is used for most of the tables in SETI@home project. It processes multiple simultaneous queries against its tables. It is a versioning DB engine that holds an image of the table at the start of a query and maintains it until that query is completed. Other updates are allowed during queries and in general for short queries there is no problem. Innodb uses the Innodb log  to store changes to its tables until it flushes these changes to the actual tables at syncpoints. If for any reason there is a server event that causes a system failure, Innodb will use this log to recover the Innodb tables to consistency. There are a minimum of 2 transaction log files with a total maximum size of 4GB.  Innodb tables/indices are usually stored in large OS physical files and the tables and indices are managed internally within these OS/Innodb files. It is important that these files are located on high performance devices. The transaction log files should be located on independent high performance media (away from the Innodb files) for sustained high transaction rates. At DB shutdown all modified buffers have to be flushed into the transaction logs before MySQL goes away, so slow performance drives for the transaction log could delay shutdown for over 30 minutes when there are a large number of modified buffers to be flushed.
    2726
    2827== Physical Requirements ==
    2928
    3029=== CPU ===
    31   Assuming the need for more than 70,000 users and 250K hosts with an average workunit turnaround of about 10 hours then one should get an Opteron dual-core class CPU. It is a 64-bit architecture and can access up to 32GB of RAM. It is qualified to run Solaris, Linux and Windows XP 64-bit (?) . There are 64-bit versions of MySQL for Linux and Solaris OSes.  This is by no means the only hardware that will work with BOINC/MySQL, however SETI@home uses this type of hardware and serves over 350K user and over 630K hosts. If your requirements are smaller, then many 32bit hardware and OSes may be perfectly adequate.
     30
     31Assuming the need for more than 70,000 users and 250K hosts with an average workunit turnaround of about 10 hours then one should get an Opteron dual-core class CPU. It is a 64-bit architecture and can access up to 32GB of RAM. It is qualified to run Solaris, Linux and Windows XP 64-bit (?). There are 64-bit versions of MySQL for Linux and Solaris OSes.  This is by no means the only hardware that will work with BOINC/MySQL, however SETI@home uses this type of hardware and serves over 350K user and over 630K hosts. If your requirements are smaller, then many 32bit hardware and OSes may be perfectly adequate.
    3232
    3333
    3434=== RAM ===
    35   The RAM requirement is related to the number of active subscribers who are expected to volunteer for the project and the number of threads that will be connected to the MySQL server. We recommend a minimum of 2GB dedicated to MySQL for about 20,000 . 30,000 volunteers growing to servers with much larger RAM sizes, say 6GB for up to 450K volunteers. This is also related to disk IO rates that are available for use by the data and log files. For example Innodb will store modified data in RAM until a syncpoint at which time data is flushed to disk; during this time update transactions are paused until the flush is completed. If there is large RAM and slow disk IO, the pause can last for several minutes. A similar delay can be noted when attempting to shutdown the project database when all the modified buffers must be flushed to disk before MySQL will shutdown, this delay could be 30 minutes or more.
     35
     36The RAM requirement is related to the number of active subscribers who are expected to volunteer for the project and the number of threads that will be connected to the MySQL server. We recommend a minimum of 2GB dedicated to MySQL for about 20,000 . 30,000 volunteers growing to servers with much larger RAM sizes, say 6GB for up to 450K volunteers. This is also related to disk IO rates that are available for use by the data and log files. For example Innodb will store modified data in RAM until a syncpoint at which time data is flushed to disk; during this time update transactions are paused until the flush is completed. If there is large RAM and slow disk IO, the pause can last for several minutes. A similar delay can be noted when attempting to shutdown the project database when all the modified buffers must be flushed to disk before MySQL will shutdown, this delay could be 30 minutes or more.
     37
    3638=== IO Subsystem ===
    37   Assuming a high performance requirement of more than 200 DB queries/sec there should be separate controllers for for the data and the log files. In the case of Innodb log files it is very important that they are on very reliable media for example mirrored (RAID 1) drives. The tables and indices require wide band or high throughput disk configuration such as RAID 10.  Some consideration should be given to having online spare disk drives since this will help to minimize down times in case of failures.
    38 
     39
     40Assuming a high performance requirement of more than 200 DB queries/sec there should be separate controllers for for the data and the log files. In the case of Innodb log files it is very important that they are on very reliable media for example mirrored (RAID 1) drives. The tables and indices require wide band or high throughput disk configuration such as RAID 10.  Some consideration should be given to having online spare disk drives since this will help to minimize down times in case of failures.
    3941
    4042== Normal Operations ==
    4143
    4244=== General ===
    43   For normal operations or production there are some considerations that should be addressed to enable the project personnel to provide reliable service. For example there should be a reliable power supply with UPS protection to avoid uncontrolled shutdowns. The temperature of the hardware operations room should be regulated to hardware specifications to avoid premature aging/failure of hardware components.  And the MySQL software has to be set up to take advantage of the hardware resources that are available.
     45
     46For normal operations or production there are some considerations that should be addressed to enable the project personnel to provide reliable service. For example there should be a reliable power supply with UPS protection to avoid uncontrolled shutdowns. The temperature of the hardware operations room should be regulated to hardware specifications to avoid premature aging/failure of hardware components.  And the MySQL software has to be set up to take advantage of the hardware resources that are available.
    4447
    4548
    4649=== Config File (my.cnf) ===
    47    The config file needs to be set up for production environment.  MySQL has defaults for where it allocates the files that it needs;  where they are placed depends on the OS on which it is running.  For greater control, space management and performance the user should  define where these files are assigned.  For example the base data directory for MySQL tables etc  in Linux is /var/lib/MySQL.  For SETI@home we assigned this to directory to another data partition  /mydisks/a/apps/mysql/data/,  to ensure that there was enough space and performance.  It made it easy to do physical backups without including  additional files that were not related to the database.   Here are some other file directory assignments for the SETI@home environment:
    48 
     50
     51The config file needs to be set up for production environment. MySQL has defaults for where it allocates the files that it needs; where they are placed depends on the OS on which it is running. For greater control, space management and performance the user should define where these files are assigned.For example the base data directory for MySQL tables etc  in Linux is /var/lib/MySQL. For SETI@home we assigned this to directory to another data partition /mydisks/a/apps/mysql/data/, to ensure that there was enough space and performance. It made it easy to do physical backups without including additional files that were not related to the database. Here are some other file directory assignments for the SETI@home environment:
    4952
    5053{{{
     
    5659innodb_log_arch_dir = /mydisks/a/apps/mysql/mysql_logs/innodb_logs/
    5760}}}
    58     Example of a MySQL config file:
     61Example of a MySQL config file:
    5962{{{
    6063[mysqld]
     
    123126
    124127=== MYTOP ===
    125   During normal operations it is useful to monitor the MySQL IO traffic, memory usage and connection activity to various client applications. Mytop application script give useful realtime status for the MySQL engine. Here is a sample of the first lines of its output:
     128
     129During normal operations it is useful to monitor the MySQL IO traffic, memory usage and connection activity to various client applications. Mytop application script give useful realtime status for the MySQL engine. Here is a sample of the first lines of its output:
     130
    126131{{{
    127132MySQL on localhost (4.0.23-max-log)
     
    132137 Key Efficiency: 99.4%  Bps in/out:  1.7k/ 1.6k   Now in/out: 63.5k/338.1k
    133138}}}
    134    It shows the historic queries/sec is 432 qps and the current sample was measured at 382 qps. The query cache hit rate is 17.9% historically and for the current sample period it is 10.6% and the cache fulfillment rate is 39.2 qps.   Useful Innodb information from Mytop is shown towards the end of the display for Innodb. The buffer pools information in given in number of pages that are 16KB in size.  See example below:
    135 
     139
     140It shows the historic queries/sec is 432 qps and the current sample was measured at 382 qps. The query cache hit rate is 17.9% historically and for the current sample period it is 10.6% and the cache fulfillment rate is 39.2 qps. Useful Innodb information from Mytop is shown towards the end of the display for Innodb. The buffer pools information in given in number of pages that are 16KB in size. See example below:
    136141
    137142{{{
     
    191196
    192197=== IOSTAT: ===
    193   Iostat is the UNIX type utility that provides a display of the IO statistics for peripherals on a server or workstation. For continuous displays of extended information for all devices. Iostat should be invoke as follows:
     198
     199Iostat is the UNIX type utility that provides a display of the IO statistics for peripherals on a server or workstation. For continuous displays of extended information for all devices. Iostat should be invoke as follows:
    194200{{{
    195201Iostat .x .k 5
    196202}}}
    197  (this will produce an updated display every 5 seconds for all devices and give data in KB)
     203
     204(this will produce an updated display every 5 seconds for all devices and give data in KB``)
     205
    198206=== MySQLAdmin ===
    199   This program is making changes and getting the status of various MySQL parameters. It is not interactive but can be made to repeat a given function by using number repeat option.  For example
     207
     208This program is making changes and getting the status of various MySQL parameters. It is not interactive but can be made to repeat a given function by using number repeat option. For example
     209
    200210{{{
    201211mysqladmin  extended-status  10
    202212}}}
    203    This will show the status display and repeat the display every 10 seconds.  Adding the .r option will give followup displays that show delta  differences with the first display values.  Performance Tweaking
     213
     214This will show the status display and repeat the display every 10 seconds. Adding the .r option will give followup displays that show delta  differences with the first display values.
     215
     216== Performance Tweaking ==
     217
    204218=== General ===
    205   An often overlooked area of performance is the requirement for reliable power and air conditioning. Power failures can eliminate all the benefits accrued by careful planning for hardware and software installations. Experience is that unreliable power can lead to days of recovery with data loss and subscriber discontent. Similarly, insufficient cooling accelerates the aging of hardware components and can cause data corruption and downtime more frequently than the one would expect given the hardware specs.
     219
     220An often overlooked area of performance is the requirement for reliable power and air conditioning. Power failures can eliminate all the benefits accrued by careful planning for hardware and software installations. Experience is that unreliable power can lead to days of recovery with data loss and subscriber discontent. Similarly, insufficient cooling accelerates the aging of hardware components and can cause data corruption and downtime more frequently than the one would expect given the hardware specs.
    206221{{{
    207222There are several parameters in my.cnf that can be adjusted (within limits)
    208223for better throughput.
    209224Then the distribution of MySQL files to specified disk subsystems,
    210 allocation of RAM and   Config: my.cnf options for files, RAM, IO options
     225allocation of RAM and Config: my.cnf options for files, RAM, IO options
    211226}}}
    212227
    213228=== MySQL Configuration ===
    214   Multi threads, query caching
     229Multi threads, query caching
    215230=== Files. Distribution ===
    216   Innodb files, transaction log files, bin-log files, MyISAM data/index files
     231Innodb files, transaction log files, bin-log files, MyISAM data/index files
    217232=== Slow Query Log ===
    218   Turn on Slow Query log to monitor slow queries.
     233Turn on Slow Query log to monitor slow queries.
    219234=== RAM Allocation ===
    220   Innodb vs MyISAM
     235Innodb vs MyISAM