README 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. Introduction/Notes
  2. ==================
  3. This module manages your mysql resources.
  4. Requirements
  5. ------------
  6. The puppetlabs-stdlib module is required for some functions used in this module.
  7. If you are wanting munin integration, you will need the munin module installed.
  8. If you are wanting shorewall integration, you will need the shorewall module
  9. installed.
  10. If you are wanting nagios integration, you will need the nagios module
  11. installed, specifically it must have nagios::plugin::deploy functionality.
  12. You will need to have activated storedconfigs on the puppetmaster.
  13. You need to ensure that the PATH environment variable contains the appropriate
  14. directories else the root password will not be set correctly to the requested
  15. value. Since the variable is empty by default when running puppet, you need to
  16. have something similar to this somewhere in your manifests:
  17. Exec { path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' }
  18. Special Notes
  19. =============
  20. By using this module, the following users will be automatically removed, if they
  21. exist: "root@${fqdn}", "root@127.0.0.1", "@${fqdn}", "@localhost", "@%"
  22. Mysql Server
  23. ============
  24. On a node where you wish to have a mysql server installed, you should include
  25. mysql::server, for example:
  26. node foo {
  27. class{'mysql::server':
  28. root_password => 'foo',
  29. }
  30. }
  31. This will manage the necessary directories and configuration files, it will
  32. install the mysql client program and set the root password to 'foo',
  33. along with setting a /root/.my.cnf for various module operations. It will also
  34. make sure the mysql service is running, and setup all the databases, users and
  35. grant tables.
  36. The my.cnf file will installed from one of many possible places, see
  37. manifests/server/base.pp for possible locations for managing this.
  38. Configuration snippets
  39. ----------------------
  40. To make managing mysql configuration easier, you can use the define
  41. mysql::conf. Note, though that there currently is only the Debian default
  42. configuration file that includes files in /etc/mysql/conf.d/.
  43. For example:
  44. mysql::conf { 'test':
  45. ensure => present,
  46. section => 'mysqld',
  47. config => {
  48. table_cache => '15000',
  49. skip_slave => '',
  50. something => '""',
  51. }
  52. }
  53. The above example shows two possibilities for empty values.
  54. * If a value only has an empty value in the hash passed to the config
  55. parameter, that will define a boolean option in mysql by simply mentioning
  56. the option name with no equal sign. So in the above, you'd have a line that
  57. contains only "skip_slave".
  58. * If you need to declare a variable with an empty value (e.g. with the equal
  59. sign), you can use two quotes as the option's value. In the above example,
  60. you'd have a line that looks like "something=".
  61. Backups
  62. -------
  63. If you wish to automatically setup a cronjob to backup your databases, you can
  64. set the "$mysql_backup_cron = true" variable. This will setup a cronjob to do a
  65. mysqldump at 1am of all the databases on the system and put them in
  66. /var/backups/mysql by default. You can override this location by specifying
  67. $mysql_backup_dir.
  68. Optimizing tables
  69. -----------------
  70. If you wish mysql to periodically optimize tables, set the
  71. "$mysql_optimize_cron = true" variable before you include mysql::server.
  72. By default, time of execution for the optimization script will be randomly
  73. chosen (and will stay consistant for a server) any day between midnight and
  74. 7:00 AM. If you wish to force at least one value, you can use the following
  75. parameters to the mysql::server class (all values are used directly as a
  76. cronjob value so they should be set within cron value space):
  77. * optimize_day => sets the day of the week (integer value) during which the script will run.
  78. * optimize_hour => sets the hour at which the optimization script will run.
  79. * optimize_minute => sets the minute in the hour at which the script will run.
  80. Munin
  81. -----
  82. If you wish to use munin you need to set the variables use_munin to "true" in
  83. hiera, before you include mysql::server. This will be used to
  84. setup a mysql user for munin, with reduced privileges to allow for the various
  85. munin graphs to be setup and queried. The munin graphs are: mysql_bytes,
  86. mysql_queries, mysql_slowqueries and mysql_threads. NOTE: The
  87. munin_mysql_password will be taken from what you passed to the mysql::server
  88. class, but it is not necessary on Debian systems as it will handled with
  89. Debian's /etc/mysql/debian.cnf.
  90. Nagios
  91. ------
  92. If you wish nagios to check mysql, you can set the variable "manage_nagios" to
  93. "true" in hiera along with the "nagios_check_mysql" variable to "true". A
  94. password for the nagios mysql user will be created for you with reduced privileges
  95. used only for nagios checks. This will be what you passed as nagios_password_hash
  96. to mysql::server and should be a mysql md5 hash. These should be set before you
  97. include mysql::server.
  98. Unless you specify otherwise, the default nagios check which will be performed
  99. is the basic 'check_mysql' nagios plugin which simply tests connectivity to a
  100. MySQL server. You can specify more advanced mysql health checks as follows:
  101. mysql::server::nagios::check_health { [ 'connection-time', 'uptime', 'threads-connected',
  102. 'slave-lag', 'slave-io-running', 'slave-sql-running' ]: }
  103. See the files/nagios/check_mysql_health script for the various mysql health
  104. checks that you can perform. Additionally, see the define "check_health" in
  105. manifests/server/nagios.pp for various options that you can pass to check_health.
  106. Note that if you need to use some specific logic to decide whether or not to
  107. create a nagios service check, you should set $manage_nagios to false, and
  108. include mysql::server::nagios from within your own manifests.
  109. Firewall
  110. --------
  111. If you wish to have firewall rules setup automatically for you, using shorewall,
  112. you will need to set the hiera variable "use_shorewall" to "true". See the
  113. shorewall module for more information about how this works.
  114. Client
  115. ======
  116. On a node where you wish to have the mysql client managed, you can 'include
  117. mysql::client' in the node definition. This will install the appropriate
  118. package.
  119. You can also 'include mysql::client::ruby' if you want the 'libmysql-ruby'
  120. libraries installed.