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 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:
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:
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:
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:
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.
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:
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.

MySQL在数据库和编程中的地位非常重要,它是一个开源的关系型数据库管理系统,广泛应用于各种应用场景。1)MySQL提供高效的数据存储、组织和检索功能,支持Web、移动和企业级系统。2)它使用客户端-服务器架构,支持多种存储引擎和索引优化。3)基本用法包括创建表和插入数据,高级用法涉及多表JOIN和复杂查询。4)常见问题如SQL语法错误和性能问题可以通过EXPLAIN命令和慢查询日志调试。5)性能优化方法包括合理使用索引、优化查询和使用缓存,最佳实践包括使用事务和PreparedStatemen

MySQL适合小型和大型企业。1)小型企业可使用MySQL进行基本数据管理,如存储客户信息。2)大型企业可利用MySQL处理海量数据和复杂业务逻辑,优化查询性能和事务处理。

InnoDB通过Next-KeyLocking机制有效防止幻读。1)Next-KeyLocking结合行锁和间隙锁,锁定记录及其间隙,防止新记录插入。2)在实际应用中,通过优化查询和调整隔离级别,可以减少锁竞争,提高并发性能。

MySQL不是一门编程语言,但其查询语言SQL具备编程语言的特性:1.SQL支持条件判断、循环和变量操作;2.通过存储过程、触发器和函数,用户可以在数据库中执行复杂逻辑操作。

MySQL是一种开源的关系型数据库管理系统,主要用于快速、可靠地存储和检索数据。其工作原理包括客户端请求、查询解析、执行查询和返回结果。使用示例包括创建表、插入和查询数据,以及高级功能如JOIN操作。常见错误涉及SQL语法、数据类型和权限问题,优化建议包括使用索引、优化查询和分表分区。

MySQL是一个开源的关系型数据库管理系统,适用于数据存储、管理、查询和安全。1.它支持多种操作系统,广泛应用于Web应用等领域。2.通过客户端-服务器架构和不同存储引擎,MySQL高效处理数据。3.基本用法包括创建数据库和表,插入、查询和更新数据。4.高级用法涉及复杂查询和存储过程。5.常见错误可通过EXPLAIN语句调试。6.性能优化包括合理使用索引和优化查询语句。

选择MySQL的原因是其性能、可靠性、易用性和社区支持。1.MySQL提供高效的数据存储和检索功能,支持多种数据类型和高级查询操作。2.采用客户端-服务器架构和多种存储引擎,支持事务和查询优化。3.易于使用,支持多种操作系统和编程语言。4.拥有强大的社区支持,提供丰富的资源和解决方案。

InnoDB的锁机制包括共享锁、排他锁、意向锁、记录锁、间隙锁和下一个键锁。1.共享锁允许事务读取数据而不阻止其他事务读取。2.排他锁阻止其他事务读取和修改数据。3.意向锁优化锁效率。4.记录锁锁定索引记录。5.间隙锁锁定索引记录间隙。6.下一个键锁是记录锁和间隙锁的组合,确保数据一致性。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

WebStorm Mac版
好用的JavaScript开发工具

禅工作室 13.0.1
功能强大的PHP集成开发环境

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

Atom编辑器mac版下载
最流行的的开源编辑器

Dreamweaver CS6
视觉化网页开发工具