search
HomeDatabaseMysql TutorialClusterControl Module for Puppet_MySQL

July 7, 2014

By Severalnines

If you are automating your infrastructure using Puppet, then this blog is for you. We are glad to announce the availability of a Puppet module for ClusterControl. For those using Chef, we already publishedChef cookbooksfor Galera Cluster and ClusterControl some time back.  

ClusterControl Module for Puppet_MySQL

ClusterControl on Puppet Forge

The ClusterControl module initial release is available on Puppet Forge , installing the module is as easy as:

$ puppet module install severalnines-clustercontrol

If you haven’t change the default module path, this module will be installed under /etc/puppet/modules/clustercontrol on your Puppet master host. ClusterControl supports following database clusters:

  • Galera Cluster
    • MySQL Galera Cluster by Codership
    • Percona XtraDB Cluster by Percona
    • MariaDB Galera Cluster by MariaDB
  • MySQL Cluster
  • MySQL Replication
  • MongoDB or TokuMX Clusters
    • Sharded Cluster
    • Replica Set

Severalnines Package Repository

This module makes use of the Severalnines repository for yum and apt packages. This repository hosts the latest stable release of ClusterControl and all of its components.

ClusterControl and all of its components requires post-installation procedures, like setting up MySQL, granting users, setting up Apache and etc. This module will automate most of these.

If you lookup the Severalnines package repository, you will find the following packages:

  • clustercontrol - Severalnines ClusterControl Web Application. Frontend for clustercontrol-controller. Previously known as cc-ui.
  • clustercontrol-cmonapi - Severalnines ClusterControl REST API. Previously known as cc-cmonapi.
  • cmon-agent - Agent for ClusterControl. Manage and monitor MySQL, MySQL Cluster and Galera Cluster for MySQL
  • cmon-controller - ClusterControl Controller. Manage and monitor MySQL, MySQL Cluster and Galera Cluster for MySQL

The Severalnines Repository installation instructions are available at http://repo.severalnines.com .

Installing ClusterControl with Puppet

We’ll now show you how to deploy ClusterControl on top of an existing database cluster using the ClusterControl Puppet module.

This module requires the following criteria to be met:

  • The node for ClusterControl must be a clean/dedicated host.
  • ClusterControl node must be running on 64bit OS platform and together with the same OS distribution with the monitored DB hosts. Mixing Debian with Ubuntu and CentOS with Red Hat is acceptable.
  • ClusterControl node must have an internet connection during the deployment. After the deployment, ClusterControl does not need internet access.
  • Make sure your database cluster is up and running before doing this deployment.

**Please review the module’s requirement available at Puppet Forge for more details.

Now we should have the Puppet module installed. The first thing that we need to do is to generate a SSH key. ClusterControl requires a proper configuration of passwordless SSH using SSH key. It also needs an API token. The following are two pre-deployment steps that you need to complete:

1. Generate a SSH key:

$ bash /etc/puppets/modules/clustercontrol/files/s9s_helper.sh --generate-key

** This step is compulsory. The above command will generate a RSA key (if not exists) to be used by the module and the key must exist in the Puppet master module's directory before the deployment begins.

2. Generate an API token:

$ bash /etc/puppets/modules/clustercontrol/files/s9s_helper.sh --generate-tokenb7e515255db703c659677a66c4a17952515dbaf5

** Copy the generated token and specify in the node definition under api_token .

Both steps described above need to be executed once (unless you intentionally want to regenerate them all). Now, we can configure the database nodes to be managed, as per example architectures below:

ClusterControl Module for Puppet_MySQL

As illustrated in the above figure, we have a three-node Percona XtraDB Cluster running on CentOS 6.5 64bit. The SSH user is root and the MySQL datadir is using the default /var/lib/mysql .

Therefore, the node definition in Puppet master would be as simple as:

# ClusterControl hostnode "clustercontrol.local" {	class { 'clustercontrol':		is_controller => true,		email_address => 'admin@localhost.xyz',		mysql_server_addresses => '192.168.1.11,192.168.1.12,192.168.1.13',		api_token => 'b7e515255db703c659677a66c4a17952515dbaf5'	}}# Monitored DB hostsnode "galera1.local", "galera2.local", "galera3.local" {	class {'clustercontrol':		is_controller => false,		mysql_root_password => 'r00tpassword',		clustercontrol_host => '192.168.1.10'	}}

Once done, you can either instruct the agent to pull the configuration from the Puppet master and apply it immediately:

$ puppet agent -t

Or, wait for the Puppet agent service to apply the catalog automatically (depending on the runinterval value, default is 30 minutes). Once completed, open the ClusterControl UI page at http://[ClusterControl IP address]/clustercontrol and login using the specified email address with default password ‘admin’.

You should see something similar to below:

ClusterControl Module for Puppet_MySQL

Take note that this module will install the RSA key at $HOME/.ssh/id_rsa_s9s . Details of this in the Puppet Forge readme page.

Example Node Definition for Other Clusters

MySQL Cluster

For MySQL Cluster, extra options are needed to allow ClusterControl to manage your management and data nodes. You may also need to add NDB data directory (e.g /mysql/data ) into the datadir list so ClusterControl knows which partition is to be monitored. In the following example, /var/lib/mysql is mysql API datadir and /mysql/data is NDB datadir.

The following figure shows our MySQL Cluster architecture running on Debian 7 (Wheezy) 64bit:

ClusterControl Module for Puppet_MySQL

The node definition would be:

# ClusterControl hostnode "clustercontrol.local" {	class { 'clustercontrol':		is_controller => true,		email_address => 'admin@localhost.xyz',		cluster_type => 'mysqlcluster',		mysql_server_addresses => '192.168.1.11,192.168.1.12',		mgmnode_addresses => '192.168.1.11,192.168.1.12',		datanode_addresses => '192.168.1.13,192.168.1.14',		datadir => '/var/lib/mysql,/mysql/data',		api_token => 'b7e515255db703c659677a66c4a17952515dbaf5'	}}# Monitored DB hostsnode "mysql1.local", "mysql2.local", "data1.local", "data2.local" {	class {'clustercontrol':		is_controller => false,		mysql_root_password => 'dpassword',		clustercontrol_host => '192.168.1.10'	}}

MySQL Replication

MySQL Replication node definition will be similar to Galera cluster’s. In following example, we have a three-node MySQL Replication running on RHEL 6.5 64bit on Amazon AWS. The SSH user is ec2-user with passwordless sudo:

ClusterControl Module for Puppet_MySQL

The node definition would be:

# ClusterControl hostnode "clustercontrol.local" {	class { 'clustercontrol':		is_controller => true,		email_address => 'admin@localhost.xyz',		ssh_user => 'ec2-user',		cluster_type => 'replication',		mysql_server_addresses => 'mysql-master.aws,mysql-slave1.aws,mysql-slave2.aws',		api_token => 'b7e515255db703c659677a66c4a17952515dbaf5'	}}# Monitored DB hostsnode "mysql-master.aws", "mysql-slave1.aws", "mysql-slave2.aws" {	class {'clustercontrol':		is_controller => false,		mysql_root_password => 'dpassword',		clustercontrol_host => 'clustercontrol.aws'	}}

MongoDB/TokuMX Replica Set

The MongoDB Replica Set runs on Ubuntu 12.04 LTS 64bit with sudo user ubuntu and password 'mySuDOpassXXX'. There is also an arbiter node running on mongo3.local . In MongoDB, the module does not require mysql_cmon_password and mysql_root_password which specifically for MySQL granting.

ClusterControl Module for Puppet_MySQL

The node definition would be:

# Monitored mongoDB hostsnode 'mongo1.local', 'mongo2.local', 'mongo3.local' {	class {'clustercontrol' :		is_controller => false,		ssh_user	=> 'ubuntu',		clustercontrol_host => '192.168.1.40'	}}# ClusterControl hostnode 'clustercontrol.local' {	class {'clustercontrol' :		is_controller => true,		ssh_user	=> 'ubuntu',		sudo_password => 'mySuDOpassXXX',		email_address => 'admin@localhost.xyz',		cluster_type=> 'mongodb',		mongodb_server_addresses => 'mongo1.local:27017,mongo2.local:27017',		mongoarbiter_server_addresses => 'mongo3.local:30000',		datadir => '/var/lib/mongodb',		api_token => 'b7e515255db703c659677a66c4a17952515dbaf5'	}}

MongoDB/TokuMX Sharded Cluster

MongoDB Sharded Cluster needs to have mongocfg_server_addresses and mongos_server_addresses options specified. The mongodb_server_addresses value should be to the list of shard servers in the cluster. In the below example, we have a three-node MongoDB Sharded Cluster running on CentOS 5.6 64bit with 2 mongos nodes, 3 shard servers and 3 config servers:

ClusterControl Module for Puppet_MySQL

The node definition would be:

# Monitored mongoDB hostsnode 'mongo1.local', 'mongo2.local', 'mongo3.local' {	class {'clustercontrol' :		is_controller => false,		clustercontrol_host => '192.168.1.40'	}}# ClusterControl hostnode 'clustercontrol.local' {	class {'clustercontrol' :		is_controller => true,		email_address => 'admin@localhost.xyz',		cluster_type=> 'mongodb',		mongodb_server_addresses => '192.168.1.41:27018,192.168.1.42:27018,192.168.1.43:27018',		mongocfg_server_addresses => '192.168.1.41:27019,192.168.1.42:27019,192.168.1.43:27019',		mongos_server_addresses => '192.168.1.41:27017,192.168.1.42:27017',		datadir => '/var/lib/mongodb',		api_token => 'b7e515255db703c659677a66c4a17952515dbaf5'	}}

Please have a look at the documentation at the ClusterControl Puppet Forge page for more details. In our upcoming post, we are going to elaborate on how to deploy new database clusters with ClusterControl using existing modules available in Puppet Forge.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to Grant Permissions to New MySQL UsersHow to Grant Permissions to New MySQL UsersMay 09, 2025 am 12:16 AM

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

How to Add Users in MySQL: A Step-by-Step GuideHow to Add Users in MySQL: A Step-by-Step GuideMay 09, 2025 am 12:14 AM

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

MySQL: Adding a new user with complex permissionsMySQL: Adding a new user with complex permissionsMay 09, 2025 am 12:09 AM

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

MySQL: String Data Types and CollationsMySQL: String Data Types and CollationsMay 09, 2025 am 12:08 AM

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

MySQL: What length should I use for VARCHARs?MySQL: What length should I use for VARCHARs?May 09, 2025 am 12:06 AM

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

MySQL BLOB : are there any limits?MySQL BLOB : are there any limits?May 08, 2025 am 12:22 AM

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

MySQL : What are the best tools to automate users creation?MySQL : What are the best tools to automate users creation?May 08, 2025 am 12:22 AM

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

MySQL: Can I search inside a blob?MySQL: Can I search inside a blob?May 08, 2025 am 12:20 AM

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools