• Stars
    star
    117
  • Rank 295,643 (Top 6 %)
  • Language
    Ruby
  • License
    Apache License 2.0
  • Created almost 13 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Development repository for the percona cookbook

Percona Cookbook

Cookbook Version OpenCollective OpenCollective License

Description

Installs the Percona MySQL client and/or server components. (We are attempting to leverage the Sous-Chefs MySQL cookbook as much as possible.)

Optionally installs:

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Requirements

Supported Platforms

We provide an expanding set of tests against the following 64-bit platforms which match what upstream supports:

  • CentOS 7+
  • Debian 10+
  • Ubuntu 18.04+ LTS

Cookbooks

Chef

This cookbook requires Chef >= 16.

Recipes

  • percona - The default which includes the client recipe.
  • percona::package_repo - Sets up the package repository and installs common packages.
  • percona::client - Installs the Percona MySQL client libraries.
  • percona::server - Installs and configures the Percona MySQL server daemon.
  • percona::backup - Installs and configures the Percona XtraBackup hot backup software.
  • percona::toolkit - Installs the Percona Toolkit software
  • percona::cluster - Installs the Percona XtraDB Cluster server components
  • percona::configure_server - Used internally to manage the server configuration.
  • percona::replication - Used internally to grant permissions for replication.
  • percona::access_grants - Used internally to grant permissions for recipes.
  • percona::ssl - Used internally to setup ssl certificates for server/client.

Resources

Usage

This cookbook installs the Percona MySQL components if not present, and pulls updates if they are installed on the system.

This cookbook uses inclusion terminology where applicable replacing terms such as master/slave to source/replica which matches the terminology decided upstream. Older releases of Percona still use the terms in their configuration so those will remain, however we will be using the newer terms with attributes, property and variable names. Currently both terms should work however the next major release of this cookbook will only use the new terminology.

Encrypted Passwords

This cookbook requires Encrypted Data Bags. If you forget to use them or do not use a node attribute to overwrite them empty passwords will be used.

To use encrypted passwords, you must create an encrypted data bag. This cookbook assumes a data bag named passwords, but you can override the name using the node['percona']['encrypted_data_bag'] attribute. You can also optionally specify a data bag secret file to be loaded for the secret key using the node['percona']['encrypted_data_bag_secret_file'] attribute.

This cookbook expects a mysql item and a system item. Please refer to the official documentation on how to get this setup. It actually uses a MySQL example so it can be mostly copied. Ensure you cover the data bag items as described below.

You also may set expected item names via attributes node['percona']['encrypted_data_bag_item_mysql'] and node['percona']['encrypted_data_bag_item_system'].

Skip passwords

Set the ['percona']['skip_passwords'] attribute to skip setting up passwords. Removes the need for the encrypted data bag if using chef-solo. Is useful for setting up development and ci environments where you just want to use the root user with no password. If you are doing this you may want to set ['percona']['server']['debian_username'] to be "root" also.

Skip Configure

Set the ['percona']['skip_configure'] attribute to skip having the server recipe include the configure_server recipe directly after install. This is mostly useful in a wrapper cookbook sort of context. Once skipped, you can then perform any pre-config actions your wrapper needs to, such as dropping a custom configuration file or init script or cleaning up incorrectly sized innodb logfiles. You can then include configure_server where necessary.

mysql item

The mysql item should contain entries for root, backup, and replication. If no value is found, the cookbook will fall back to the default non-encrypted password.

system item

The "system" item should contain an entry for the debian system user as specified in the node['percona']['server']['debian_username'] attribute. If no such entry is found, the cookbook will fall back to the default non-encrypted password.

Example: "passwords" data bag - this example assumes that node['percona']['server']['debian_username'] = spud

{
  "mysql" :
  {
    "root" : "trywgFA6R70NO28PNhMpGhEvKBZuxouemnbnAUQsUyo=\n"
    "backup" : "eqoiudfj098389fjadfkadf=\n"
    "replication" : "qwo0fj0213fm9020fm2023fjsld=\n"
  },
  "system" :
  {
    "spud" : "dwoifm2340f024jfadgfu243hf2=\n"
  }
}

Above shows the encrypted password in the data bag. Check out the encrypted_data_bag_secret setting in knife.rb to setup your data bag secret during bootstrapping.

Install client development package

To install the package including header files needed to compile software using the client library (percona-server-devel on Centos and libperconaserverclient-dev on Debian), set node['percona']['client']['install_devel_package'] to true. This will add those packages to the list to be installed when running the percona::client recipe. This attribute is disabled by default.

Replication over SSL

To enable SSL based replication, you will need to flip the attribute node['percona']['server']['replication']['ssl_enabled'] to true and add a new data_bag item to the percona encrypted data_bag (seenode['percona']['encrypted_data_bag'] attribute) with the id ssl_replication ( see node['percona']['encrypted_data_bag_item_ssl_replication'] attribute) that contains this data:

{
  "id": "ssl_replication",
  "ca-cert": "CA_CERTIFICATE_STRING",
  "server": {
    "server-cert": "SERVER_CERTIFICATE_STRING",
    "server-key": "SERVER_KEY_STRING"
  },
  "client": {
    "client-cert": "CLIENT_CERTIFICATE_STRING",
    "client-key": "CLIENT_KEY_STRING"
  }
}

All certificates and keys have to be converted to a string (easiest way is to use ruby: /usr/bin/env ruby -e 'p ARGF.read' <filename>) and placed instead of CA_CERTIFICATE_STRING, SERVER_CERTIFICATE_STRING, SERVER_KEY_STRING, CLIENT_CERTIFICATE_STRING, CLIENT_KEY_STRING.

Percona XtraDB Cluster

Below is a minimal example setup to bootstrap a Percona XtraDB Cluster. Please see the official documentation for more information. This is not a perfect example. It is just a sample to get you started.

Wrapper recipe recipes/percona.rb:

# Setup the Percona XtraDB Cluster
cluster_ips = []
unless Chef::Config[:solo]
  search(:node, 'role:percona').each do |other_node|
    next if other_node['private_ipaddress'] == node['private_ipaddress']
    Chef::Log.info "Found Percona XtraDB cluster peer: #{other_node['private_ipaddress']}"
    cluster_ips << other_node['private_ipaddress']
  end
end

cluster_ips.each do |ip|
  firewall_rule "allow Percona group communication to peer #{ip}" do
    source ip
    port 4567
    action :allow
  end

  firewall_rule "allow Percona state transfer to peer #{ip}" do
    source ip
    port 4444
    action :allow
  end

  firewall_rule "allow Percona incremental state transfer to peer #{ip}" do
    source ip
    port 4568
    action :allow
  end
end

cluster_address = "gcomm://#{cluster_ips.join(',')}"
Chef::Log.info "Using Percona XtraDB cluster address of: #{cluster_address}"
node.override['percona']['cluster']['wsrep_cluster_address'] = cluster_address
node.override['percona']['cluster']['wsrep_node_name'] = node['hostname']

include_recipe 'percona::cluster'
include_recipe 'percona::backup'
include_recipe 'percona::toolkit'

Example percona role roles/percona.rb:

name "percona"
description "Percona XtraDB Cluster"

run_list 'recipe[paydici::percona]'

default_attributes(
  "percona" => {
    "server" => {
      "role" => "cluster"
    },

    "cluster" => {
      "package"                     => "percona-xtradb-cluster-56",
      "wsrep_cluster_name"          => "percona_cluster_1",
      "wsrep_sst_receive_interface" => "eth1" # can be eth0, public, private, etc.
    }
  }
)

Now you need to bring three servers up one at a time with the percona role applied to them. By default the servers will sync up via rsync server state transfer (SST)

Explicit my.cnf templating

In some situations it is preferable to explicitly define the attributes needed in a my.cnf file. This is enabled by adding categories to the node['percona']['conf'] attributes. All keys found in the node['percona']['conf'] map will represent categories in the my.cnf file. Each category contains a map of attributes that will be written to the my.cnf file for that category. See the example for more details.

Example

node['percona']['conf']['mysqld']['slow_query_log_file'] = "/var/lib/mysql/data/mysql-slow.log"

This configuration would write the mysqld category to the my.cnf file and have an attribute slow_query_log_file whose value would be /var/lib/mysql/data/mysql-slow.log.

Example output (my.cnf)

[mysqld]
slow_query_log_file = /var/lib/mysql/data/mysql-slow.log

Dynamically setting the bind address

There's a special attribute node['percona']['server']['bind_to'] that allows you to dynamically set the bind address. This attribute accepts the values "public_ip", "private_ip", "loopback", or and interface name like "eth0". Based on this, the recipe will find a corresponding ipv4 address, and override the node['percona']['server']['bind_address'] attribute.

Goals

In no particular order:

  • Be the most flexible way to setup a MySQL distribution through Chef
    • Support for Chef Solo
    • Support for Chef Server
  • Support the following common database infrastructures:
    • Single server instance
    • Traditional Source/Replica replication
    • Multi-source cluster replication
  • Support the most recent Chef runtime environments
  • Be the easiest way to setup a MySQL distribution through Chef

TODO

  • Fully support all of the standard Chef-supported distributions

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Added some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

More Repositories

1

docker

Development repository for the docker cookbook
Ruby
1,344
star
2

elasticsearch

Development repository for the elasticsearch cookbook
Ruby
882
star
3

aws

Development repository for the aws cookbook
Ruby
594
star
4

nginx

Development repository for the nginx cookbook
Ruby
551
star
5

rvm

Development repository for the rvm cookbook
Ruby
516
star
6

php

Development repository for the php cookbook
HTML
433
star
7

jenkins

Development repository for the jenkins cookbook
Ruby
423
star
8

java

Development repository for the java cookbook
Ruby
397
star
9

postgresql

Development repository for the postgresql cookbook
Ruby
352
star
10

mysql

Development repository for the mysql cookbook
Ruby
335
star
11

ruby_rbenv

Development repository for the ruby_rbenv cookbook
Ruby
332
star
12

redisio

Development repository for the redisio cookbook
HTML
297
star
13

apache2

Development repository for the apache2 cookbook
Ruby
282
star
14

nodejs

Development repository for the nodejs cookbook
Ruby
227
star
15

apt

Development repository for the apt cookbook
Ruby
203
star
16

consul

Development repository for the consul cookbook
Ruby
190
star
17

haproxy

Development repository for the haproxy cookbook
Ruby
156
star
18

graphite

Development repository for the graphite cookbook
Ruby
154
star
19

homebrew

Development repository for the homebrew cookbook
Ruby
149
star
20

users

Development repository for the users cookbook
Ruby
138
star
21

nagios

Development repository for the nagios cookbook
Ruby
124
star
22

ruby_build

Development repository for the ruby_build cookbook
Ruby
123
star
23

git

Development repository for the git cookbook
Ruby
122
star
24

logrotate

Development repository for the logrotate cookbook
Ruby
122
star
25

openssh

Development repository for the openssh cookbook
Ruby
114
star
26

powershell

Development repository for the powershell cookbook
Ruby
110
star
27

postfix

Development repository for the postfix cookbook
Ruby
103
star
28

tomcat

Development repository for the tomcat cookbook
Ruby
99
star
29

line

Development repository for the line cookbook
Ruby
98
star
30

openvpn

Development repository for the openvpn cookbook
Ruby
98
star
31

ark

Development repository for the ark cookbook
Ruby
98
star
32

firewall

Development repository for the firewall cookbook
Ruby
95
star
33

yum

Development repository for the yum cookbook
Ruby
95
star
34

kafka

Development repository for the kafka cookbook
Ruby
91
star
35

erlang

Development repository for the erlang cookbook
Ruby
88
star
36

sublimechef

A Sublime Text 2 Package for authoring Chef related files
84
star
37

iis

Development repository for the iis cookbook
Ruby
82
star
38

etcd

Development repository for the etcd cookbook
Ruby
80
star
39

cron

Development repository for the cron cookbook
Ruby
77
star
40

grafana

Development repository for the grafana cookbook
Ruby
76
star
41

sc-mongodb

Development repository for the sc-mongodb cookbook
Ruby
75
star
42

chef-splunk

Development repository for the chef-splunk cookbook
Ruby
75
star
43

certificate

Development repository for the certificate cookbook
Ruby
73
star
44

ntp

Development repository for the ntp cookbook
Ruby
68
star
45

rsyslog

Development repository for the rsyslog cookbook
Ruby
65
star
46

sql_server

Development repository for the sql_server cookbook
Ruby
63
star
47

windows_ad

Development repository for the windows_ad cookbook
Ruby
59
star
48

fail2ban

Development repository for the fail2ban cookbook
Ruby
58
star
49

selinux

Development repository for the selinux cookbook
Ruby
58
star
50

vagrant

Development repository for the vagrant cookbook
Ruby
57
star
51

varnish

Development repository for the varnish cookbook
Ruby
56
star
52

lvm

Development repository for the lvm cookbook
Ruby
56
star
53

perl

Development repository for the perl cookbook
Ruby
52
star
54

memcached

Development repository for the memcached cookbook
Ruby
50
star
55

golang

Development repository for the golang cookbook
Ruby
49
star
56

mariadb

Development repository for the mariadb cookbook
Ruby
47
star
57

hashicorp-vault

Development repository for the hashicorp-vault cookbook
Ruby
46
star
58

rundeck

Development repository for the rundeck cookbook
Ruby
46
star
59

ufw

Development repository for the ufw cookbook
Ruby
44
star
60

ossec

Development repository for the ossec cookbook
Ruby
43
star
61

confluence

Development repository for the confluence cookbook
Ruby
43
star
62

openldap

Development repository for the openldap cookbook
Ruby
42
star
63

nfs

Development repository for the nfs cookbook
Ruby
40
star
64

kubernetes

Development repository for the kubernetes cookbook
Ruby
39
star
65

vim

Development repository for the vim cookbook
Ruby
38
star
66

maven

Development repository for the maven cookbook
Ruby
36
star
67

bind

Development repository for the bind cookbook
Ruby
36
star
68

passenger_apache2

Development repository for the passenger_apache2 cookbook
Ruby
36
star
69

keepalived

Development repository for the keepalived cookbook
Ruby
33
star
70

aptly

Development repository for the aptly cookbook
Ruby
31
star
71

samba

Development repository for the samba cookbook
Ruby
30
star
72

resolver

Development repository for the resolver cookbook
Ruby
28
star
73

squid

Development repository for the squid cookbook
Ruby
28
star
74

freebsd

Development repository for the freebsd cookbook
Ruby
27
star
75

snort

Development repository for the snort cookbook
Ruby
27
star
76

pyenv

Development repository for the pyenv cookbook
Ruby
27
star
77

dhcp

Development repository for the dhcp cookbook
Ruby
27
star
78

nrpe

Development repository for the nrpe cookbook
Ruby
25
star
79

yum-epel

Development repository for the yum-epel cookbook
Ruby
24
star
80

rsync

Development repository for the rsync cookbook
Ruby
24
star
81

github

Development repository for the github cookbook
Ruby
24
star
82

filesystem

Development repository for the filesystem cookbook
Ruby
24
star
83

network_interfaces

Development repository for the network_interfaces cookbook
Ruby
24
star
84

djbdns

Development repository for the djbdns cookbook
Ruby
19
star
85

drbd

Development repository for the drbd cookbook
Ruby
19
star
86

dpkg_autostart

Development repository for the dpkg_autostart cookbook
Ruby
18
star
87

sssd_ldap

Development repository for the sssd_ldap cookbook
Ruby
18
star
88

packagecloud

Development repository for the packagecloud cookbook
Ruby
17
star
89

webpi

Development repository for the webpi cookbook
Ruby
17
star
90

gems

Development repository for the gems cookbook
Ruby
17
star
91

language-chef

Development repository for the language-chef plugin for the Atom text editor
JavaScript
17
star
92

elixir

Development repository for the elixir cookbook
Ruby
17
star
93

htpasswd

Development repository for the htpasswd cookbook
Ruby
15
star
94

stunnel

Development repository for the stunnel cookbook
Ruby
14
star
95

apparmor

Development repository for the apparmor cookbook
Ruby
14
star
96

transmission

Development repository for the transmission cookbook
Ruby
14
star
97

smartmontools

Development repository for the smartmontools cookbook
HTML
13
star
98

gpg

Development repository for the gpg cookbook
Ruby
12
star
99

wix

Development repository for the wix cookbook
Ruby
12
star
100

tftp

Development repository for the tftp cookbook
Ruby
11
star