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.高基数索引能更有效地缩小数据范围,提高查询效率;2.低基数索引可能导致全表扫描,降低查询性能;3.在联合索引中,应将高基数列放在前面以优化查询。

MySQL學習路徑包括基礎知識、核心概念、使用示例和優化技巧。 1)了解表、行、列、SQL查詢等基礎概念。 2)學習MySQL的定義、工作原理和優勢。 3)掌握基本CRUD操作和高級用法,如索引和存儲過程。 4)熟悉常見錯誤調試和性能優化建議,如合理使用索引和優化查詢。通過這些步驟,你將全面掌握MySQL的使用和優化。

MySQL在現實世界的應用包括基礎數據庫設計和復雜查詢優化。 1)基本用法:用於存儲和管理用戶數據,如插入、查詢、更新和刪除用戶信息。 2)高級用法:處理複雜業務邏輯,如電子商務平台的訂單和庫存管理。 3)性能優化:通過合理使用索引、分區表和查詢緩存來提升性能。

MySQL中的SQL命令可以分為DDL、DML、DQL、DCL等類別,用於創建、修改、刪除數據庫和表,插入、更新、刪除數據,以及執行複雜的查詢操作。 1.基本用法包括CREATETABLE創建表、INSERTINTO插入數據和SELECT查詢數據。 2.高級用法涉及JOIN進行表聯接、子查詢和GROUPBY進行數據聚合。 3.常見錯誤如語法錯誤、數據類型不匹配和權限問題可以通過語法檢查、數據類型轉換和權限管理來調試。 4.性能優化建議包括使用索引、避免全表掃描、優化JOIN操作和使用事務來保證數據一致性

InnoDB通過undolog實現原子性,通過鎖機制和MVCC實現一致性和隔離性,通過redolog實現持久性。 1)原子性:使用undolog記錄原始數據,確保事務可回滾。 2)一致性:通過行級鎖和MVCC確保數據一致。 3)隔離性:支持多種隔離級別,默認使用REPEATABLEREAD。 4)持久性:使用redolog記錄修改,確保數據持久保存。

MySQL在數據庫和編程中的地位非常重要,它是一個開源的關係型數據庫管理系統,廣泛應用於各種應用場景。 1)MySQL提供高效的數據存儲、組織和檢索功能,支持Web、移動和企業級系統。 2)它使用客戶端-服務器架構,支持多種存儲引擎和索引優化。 3)基本用法包括創建表和插入數據,高級用法涉及多表JOIN和復雜查詢。 4)常見問題如SQL語法錯誤和性能問題可以通過EXPLAIN命令和慢查詢日誌調試。 5)性能優化方法包括合理使用索引、優化查詢和使用緩存,最佳實踐包括使用事務和PreparedStatemen

MySQL適合小型和大型企業。 1)小型企業可使用MySQL進行基本數據管理,如存儲客戶信息。 2)大型企業可利用MySQL處理海量數據和復雜業務邏輯,優化查詢性能和事務處理。

InnoDB通過Next-KeyLocking機制有效防止幻讀。 1)Next-KeyLocking結合行鎖和間隙鎖,鎖定記錄及其間隙,防止新記錄插入。 2)在實際應用中,通過優化查詢和調整隔離級別,可以減少鎖競爭,提高並發性能。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

Dreamweaver CS6
視覺化網頁開發工具

WebStorm Mac版
好用的JavaScript開發工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

禪工作室 13.0.1
強大的PHP整合開發環境