Chef Recipes for CUBRID Database, its drivers, tools, and HA/SHARD configuration.
Provides recipies to:
This cubrid cookbook is tested on Vagrant boxes as well as plain vanilla Linux (see Platform below).
For those familiar with Vagrant, the following tutorials will help you to quickly get up and running with cubrid cookbook:
Tested on:
Note: in order to use MySQL database sharding with CUBRID SHARD through shard_mysql recipe, CentOS 5.6~6.3 or Ubuntu 10.x is required as they provide MySQL 5.1. Ubuntu 12.04+ has removed MySQL 5.1 from their repositories. Support for MySQL 5.5 in shard_mysql recipe is expected to be implemented when CUBRID 10.x is released.
##Requirements
This cubrid cookbook has the following dependencies:
sudo gem update chef --no-ri --no-rdoc
.sudo gem update ohai --no-ri --no-rdoc
.cubrid cookbook provides the following recipes:
Check the source code of the available attributes. All attributes are extensively commented.
If you want to configure additional Brokers, use broker recipe.
chef.json = {
"cubrid" => {
"broker_count" => 1,
"min_num_appl_server" => 5,
"max_num_appl_server" => 40
}
}
chef.add_recipe "cubrid::broker"
This will:
MIN_NUM_APPL_SERVER
and MAX_NUM_APPL_SERVER
parameters to each broker in Broker configuration file (cubrid_broker.conf).If you want to install the default 9.0.0 version of CUBRID, use default recipe.
chef.add_recipe "cubrid"
To install another version of CUBRID like 8.4.1 or 8.4.3, override the version
attribute in Chef JSON.
chef.json = {
"cubrid" => {
"version" => "8.4.3"
}
}
chef.add_recipe "cubrid"
This will:
tar.gz
) from CUBRID SF.net repository if it is not already installed at /opt/cubrid.REJECT
’s all incoming connections. The default recipe will add ACCEPT
rules for CUBRID ports (but not all; HA port will be opened by ha recipe, Web Manager port by web_manager recipe, SHARD port by shard recipe) such as 30000:30100, 33000:33100, 8001:8003, 1523. Detailed explanation of all ports used by CUBRID can be found at http://www.cubrid.org/port_iptables_configuration.Note: the cubrid cookbook will be installed by root user. For this reason in order to work with CUBRID once installed, you need to be logged in as a root. To login as a root, run the following command:
sudo su -
Then run any cubrid command such as:
cubrid service status
If you want to install CUBRID demodb database, use demodb recipe. This recipe depends on cubrid::default recipe.
chef.add_recipe "cubrid::demodb"
This will:
If you want to have CUBRID HA configured for you automatically on multi VM environment, use ha recipe. With CUBRID HA you can have very reliable and predictable automatic failover between your database nodes.
This recipe depends on cubrid::default recipe.
chef.add_recipe "cubrid::ha"
This will:
Check if ha_hosts
attribute is provided by a user. That is, you must pass a list of hosts to join CUBRID HA group. ha_hosts
should be a hash of host=>IP key-values:
chef.json = {
"cubrid" => {
"ha_hosts" => {"node1" => "10.11.12.13", "node2" => "10.11.12.14"}
}
}
If ha_hosts
is not provided, an error will be raise saying: Cannot configure CUBRID HA without ha_hosts. Refer to “ha_hosts” attribute in /cubrid/attributes/ha.rb for the syntax.
Create all databases listed in ha_dbs
array which need to be replicated between master:slave nodes in HA environment, if they are not already created. If user doesn’t override this attribute, ha_dbs=["testdb"]
.
Update /opt/cubrid/databases/databases.txt file to set ha_hosts
for each database, if it is not already updated.
Update /etc/hosts with new IP - host values defined in ha_hosts
, if it is not already updated.
Update conf/cubrid.conf configuration file to turn on CUBRID HA.
Update conf/cubrid_ha.conf with new configurations for CUBRID HA.
Restart CUBRID Service.
Start CUBRID Heartbeat.
When installed on CentOS, this ha recipe will auto configure the iptables firewall if iptables is installed. When iptables is installed, by default it REJECT
’s all incoming connections. The ha recipe will add an ACCEPT
rule for CUBRID HA port which is 59901 by default.
If you also want to create multiple databases, use new_dbs recipe. This recipe depends on the cubrid::default recipe.
chef.json = {
"cubrid" => {
"new_dbs" => ["apple_db", "banana_db"],
}
}
chef.add_recipe "cubrid::new_dbs"
This will:
new_dbs
attribute.If you want to install CUBRID PDO driver, use pdo_cubrid recipe.
chef.add_recipe "cubrid::pdo_cubrid"
This will:
libgcrypt-devel
dependency library, which is required to build PECL packages, because in PHP 5.3.3 installed via YUM this library does not get installed by default.Note: this recipe as well as php_driver do not restart your Web server automatically because they do not know which Web server you use. So, if necessary, restart your Web server manually.
If you also want to install CUBRID Perl driver, use perl_driver recipe. This recipe depends on the cubrid::default and perl::default recipes.
chef.add_recipe "cubrid::perl_driver"
This will:
If you also want to install CUBRID PHP driver, use php_driver recipe.
chef.add_recipe "cubrid::php_driver"
This will:
libgcrypt-devel
dependency library, which is required to build PECL packages, because in PHP 5.3.3 installed via YUM this library does not get installed by default.Note: this recipe as well as pdo_cubrid do not restart your Web server automatically because they do not know which Web server you use. So, if necessary, restart your Web server manually.
If you also want to install CUBRID Python driver, there are three recipes to choose from:
If you have no prefereces, use the python_driver recipe which will detect the preferred recipe for you to install the Python driver. This recipe depends on the cubrid::default recipe.
chef.add_recipe "cubrid::python_driver"
This will:
Recommended on non-CentOS 5.x.
Use the python_driver_pip recipe to install the Python driver via pip. This recipe depends on the cubrid::default and python::default recipes.
chef.add_recipe "cubrid::python_driver_pip"
This will:
Recommended on CentOS 5.x.
Use the python_driver_source recipe to install the Python driver from the source code. This recipe depends on the cubrid::default and build-essential::default recipes.
chef.add_recipe "cubrid::python_driver_source"
This will:
Note: this python_driver_source recipe does not install pip and virtualenv. If necessary, use python cookbook to install them.
If you want to have your databases sharded by CUBRID SHARD on multi VM environment, use shard recipe.
chef.json = {
"cubrid" => {
"shard_db" => "sharddb",
"shard_user" => "shard",
"shard_user_password" => "shard123",
"shard_hosts" => [
{"node1" => "10.11.12.13"},
{"node2" => "10.11.12.14"}
],
"shard_broker_port" => 45011
}
}
chef.add_recipe "cubrid::shard"
This will:
shard_db
and shard_hosts
attributes are provided by a user. That is, you must specify the database name and a list of hosts you want to shard this database among.shard_hosts
is not provided, an error will be raise saying: Cannot configure CUBRID SHARD without shard_db and shard_hosts. Refer to “shard_db” and “shard_hosts” attributes in /cubrid/attributes/shard.rb for the syntax.shard_db
database, if it is not already created, which will be sharded among shard_hosts
.shard_hosts
, if it is not already updated.shard_hosts
. This means that if you want a specific node to run CUBRID SHARD, list it as the last element of the shard_hosts
array. You can change the order of hosts anytime after you have started.REJECT
’s all incoming connections. The shard recipe will add an ACCEPT
rule for CUBRID SHARD port which is 45011 by default.CUBRID SHARD allows to configure CUBRID or MySQL as a backend database. If you want to use MySQL as a backend for CUBRID SHARD on multi VM environment, use shard_mysql recipe.
This recipe depends on mysql and database cookbooks.
chef.json = {
"cubrid" => {
"shard_db" => "sharddb",
"shard_user" => "shard",
"shard_user_password" => "shard123",
"shard_hosts" => [
{"node1" => "10.11.12.13"},
{"node2" => "10.11.12.14"}
],
"shard_broker_port" => 45011
},
"mysql" => {
"server_root_password" => "your_root_password",
"server_repl_password" => "your_root_password",
"server_debian_password" => "your_root_password"
}
}
chef.add_recipe "cubrid::shard_mysql"
This will:
shard_db
and shard_hosts
attributes are provided by a user. That is, you must specify the database name and a list of hosts you want to shard this database among.shard_hosts
is not provided, an error will be raise saying: Cannot configure CUBRID SHARD without shard_db and shard_hosts. Refer to “shard_db” and “shard_hosts” attributes in /cubrid/attributes/shard.rb for the syntax.shard_hosts
, if it is not already updated.bind_address
to an empty string meaning disable bind-address
.wait_timeout
to MySQL’s default 28800 for CUBRID SHARD to work as expected. See shard_mysql recipe source for comments.shard_db
database in MySQL Server, if it is not already created, which will be sharded among shard_hosts
.shard_user
database user in MySQL and grant all rights to shard_db
database on localhost
as well as the remote node where CUBRID SHARD will be started.shard_hosts
. This means that if you want a specific node to run CUBRID SHARD, list it as the last element of the shard_hosts
array.REJECT
’s all incoming connections. The shard_mysql recipe will add an ACCEPT
rule for CUBRID SHARD port which is 45011 by default, and MySQL 3306 port.If you also want to install CUBRID Web Manager, use web_manager recipe. This recipe depends on the cubrid::default recipe.
chef.add_recipe "cubrid::web_manager"
This will:
tar.gz
) from CUBRID SF.net repository. CWM version will remain the same as the main CUBRID Database.REJECT
’s all incoming connections. The web_manager recipe will add an ACCEPT
rule for CUBRID Web Manager port which is 8282 by default.After CWM is installed, you can access it at https://your_vm_ip_address:8282. Notice HTTPS and 8282 port are used by default. These and other configurations can be adjusted. See CUBRID Manager HTTPD Variables.
The default username and password to connect to CUBRID Manager Server are admin/admin. Once you login for the first time, CWM will prompt you to change the password. Visit CWM Wiki for more information and tutorials.
cubrid cookbook is tested on multiple VMs with Test Kitchen. To run the tests locally, refer to the README in the cubrid_test cookbook which is distributed together with this cubrid cookbook.
max_clients
in cubrid.conf, need to updated the ulimit
of Linux because by defuault it allows to open 1024 files at a time. Depending on the max_clients
size, ulimit
has to be adjusted. See http://posidev.com/blog/2009/06/04/set-ulimit-parameters-on-ubuntu/ for more instructions.init.d
script to start CUBRID service on reboot.Distributed under MIT License.