Provides recipies to:
- install CUBRID Database (version 9.1, 9.0, 8.4.3, and 8.4.1), CUBRID PDO, PHP, Perl, and Python drivers (see Recipies below), as well as CUBRID Web Manager;
- create the demodb or any number of other user defined databases;
- automatically configure CUBRID HA and CUBRID SHARD in multi VM environment;
- CUBRID SHARD can be configured with both CUBRID and MySQL backends.
- configure additional brokers.
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:
- Create a CUBRID Database VM with Vagrant and Chef Cookbook under 5 minutes
- Configure CUBRID HA with Vagrant and Chef Cookbook under 4 minutes
- Configure CUBRID SHARD with Vagrant and Chef Cookbook under 2 minutes
- Install CUBRID remotely with knife-solo and Chef Cookbook
Tested on:
- Ubuntu 10.04 LTS x86/x64
- Vagrant boxes: Ubuntu lucid 32 (261MB), Ubuntu lucid 64 (280MB)
- Ubuntu 12.04 LTS x86/x64
- Official Ubuntu Image: Ubuntu 12.04.1 LTS (657MB)
- Vagrant boxes: Ubuntu precise 32 (299MB), Ubuntu precise 64 (323MB)
- Ubuntu 13.04 LTS x86/x64
- Official Ubuntu Vagrant box: Ubuntu raring 64 (295MB)
- CentOS 5.6 x64
- Vagrant box: CentOS 5.6 minimal (240MB)
- CentOS 6.0 x64
- Vagrant box: CentOS 6.0 minimal (362MB)
- CentOS 6.3 x64
- Vagrant box: CentOS 6.3 minimal (296MB)
- CentOS 6.4 x86/x64
- Vagrant boxes: CentOS 6.4 x86 minimal (416MB), CentOS 6.4 x64 minimal (442MB)
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:
- Chef 10.14.0+. Make sure you have the latest version of Chef. If necessary, update by executing
sudo gem update chef --no-ri --no-rdoc
. - Ohai 6.14.0+. Make sure you have the latest version of Ohai. If necessary, update by executing
sudo gem update ohai --no-ri --no-rdoc
. - pdo_cubrid and php_driver depend on: php cookbook.
- perl_driver depends on: build-essential and perl cookbooks.
- python_driver depends on: build-essential and python cookbooks.
- shard_mysql depends on: mysql and database cookbooks.
cubrid cookbook provides the following recipes:
- broker: configures additional CUBRID Brokers.
- default: installs the specified version of CUBRID Database. Available versions: 8.4.1, 8.4.3, 9.0.0 (default).
- demodb: creates CUBRID's demodb database.
- ha: configures CUBRID HA in multi VM environment.
- new_dbs: create one or more databases defined by a user.
- pdo_cubrid: installs CUBRID PDO driver (same version as CUBRID Database, except when CUBRID 8.4.1 is installed in which case PDO driver 8.4.0 is installed as they are compatible).
- perl_driver: installs CUBRID Perl driver (same version as CUBRID Database).
- php_driver: installs CUBRID PHP driver (same version as CUBRID Database).
- python_driver: installs CUBRID Python driver (same version as CUBRID Database). On CentOS/RedHat < 6, the Python driver is installed from source. On other platforms, it is installed from pip.
- python_driver_pip: installs CUBRID Python driver from pip.
- python_driver_source: installs CUBRID Python driver from source.
- shard: configures CUBRID SHARD in multi VM environment.
- shard_mysql: configures MySQL as a backend database for CUBRID SHARD in multi VM environment.
- web_manager: installs CUBRID Web Manager.
Check the source code of the available attributes. All attributes are extensively commented.
- broker
- database
- default
- demodb
- ha
- new_dbs
- pdo_cubrid
- perl_driver
- php_driver
- python_driver
- shard
- web_manager
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:
- Add specified number of CUBRID Brokers and set
MIN_NUM_APPL_SERVER
andMAX_NUM_APPL_SERVER
parameters to each broker in Broker configuration file (cubrid_broker.conf). - Restart the CUBRID Broker Service if the configuration file has been updated.
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:
- Set envrionmental vartiables for CUBRID.
- Download the specified version of CUBRID (
tar.gz
) from CUBRID SF.net repository if it is not already installed at /opt/cubrid. - Extract it to /opt/cubrid.
- Remove the downloaded archive.
- Setup the startup script for a user to auto set environmental variables when the user logs in to the system.
- Override CUBRID configuration file (cubrid.conf) with user defined or default values.
- Start CUBRID Service.
- When installed on CentOS, this default recipe will auto configure the iptables firewall if iptables is installed. When iptables is installed, by default it
REJECT
's all incoming connections. The default recipe will addACCEPT
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:
- Create CUBRID's demodb database if it's not already created.
- Auto start demodb database.
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 anACCEPT
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:
- Create all databases defined in
new_dbs
attribute. - Optionally add a new database user with a defined username and a password. If a password is defined without a username, the password will be set for the default dba user, in case dba's password is still empty. If the password is non-empty, i.e. has already altered previously, the password will not be reset.
- Auto start all databases if they are set to auto start, which is the default behavior.
If you want to install CUBRID PDO driver, use pdo_cubrid recipe.
- php cookbook
- if you want to install the PDO driver < v9.1.0, the cubrid::default recipe is also required since earlier version require CUBRID to be installed to access the CCI library. Since CUBRID PDO 9.1.0.0003, CCI library is included in PDO driver source code, so doesn't require CUBRID to be installed.
chef.add_recipe "cubrid::pdo_cubrid"
This will:
- Install CUBRID for PDO driver < 9.1.0, in case CUBRID is not already installed.
- Install the
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. - Install CUBRID PDO driver from PHP PECL Repository if the PDO driver is not already installed (same version as the previously installed CUBRID Database). If no CUBRID version is specified, defaults to the latest available vesion.
- Create /etc/php5/conf.d/pdo_cubrid.ini to tell PHP to load CUBRID PDO driver.
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:
- Install DBI (Database Independent Interface) module which the CUBRID Perl driver is based on.
- Install CUBRID Perl driver from CPAN Repository if it is not already installed (same version as the previously installed CUBRID Database).
If you also want to install CUBRID PHP driver, use php_driver recipe.
- php cookbook
- if you want to install the PHP driver < v9.1.0, the cubrid::default recipe is also required since earlier version require CUBRID to be installed to access the CCI library. Since CUBRID PHP 9.1.0.0003, CCI library is included in PHP driver source code, so doesn't require CUBRID to be installed.
chef.add_recipe "cubrid::php_driver"
This will:
- Install CUBRID for PHP driver < 9.1.0, in case CUBRID is not already installed.
- Install the
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. - Install CUBRID PHP driver from PHP PECL Repository if it is not already installed (same version as the previously installed CUBRID Database). If no CUBRID version is specified, defaults to the latest available vesion.
- Create /etc/php5/conf.d/cubrid.ini to tell PHP to load CUBRID PHP driver.
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:
- python_driver: on CentOS 5.x installs the CUBRID Python driver using the python_driver_source recipe, otherwise using the python_driver_pip recipe.
- python_driver_pip: installs pip, virtualenv, and the CUBRID Python driver. pip requires at least Python 2.5 installed, therefore recommended on CentOS 6+/Ubuntu 10+.
- python_driver_source: installs the Python driver from source code. Works on Python 2.4+, therefore recommended on CentOS 5.x.
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:
- On CentOS 5.x include the python_driver_source recipe, otherwise include the python_driver_pip recipe.
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:
- Include Python cookbook which installs Python 2.5+, pip, and virtualenv.
- Install CUBRID Python driver using pip from PYPI if it is not already installed (same version as the previously installed CUBRID Database).
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:
- Install the Python Development Package.
- Download the CUBRID Python driver source archive from SF.net.
- Extract it.
- Build and install the driver library.
- Remove the extracted directory and the downloaded archive.
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:
- Check if
shard_db
andshard_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. Ifshard_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. - Create and auto start a
shard_db
database, if it is not already created, which will be sharded amongshard_hosts
. - Update /etc/hosts with new IP - host values defined in
shard_hosts
, if it is not already updated. - Update conf/shard.conf.
- Update conf/shard_key.txt.
- Update conf/shard_connection.txt.
- Start CUBRID SHARD Service on the last of the
shard_hosts
. This means that if you want a specific node to run CUBRID SHARD, list it as the last element of theshard_hosts
array. You can change the order of hosts anytime after you have started. - When installed on CentOS, this shard recipe will auto configure the iptables firewall if iptables is installed. When iptables is installed, by default it
REJECT
's all incoming connections. The shard recipe will add anACCEPT
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:
- Check if
shard_db
andshard_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. Ifshard_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. - Update /etc/hosts with new IP - host values defined in
shard_hosts
, if it is not already updated. - Install CUBRID and MySQL Servers if they are not installed.
- Override two MySQL parameters in my.cnf:
bind_address
to an empty string meaning disablebind-address
.wait_timeout
to MySQL's default 28800 for CUBRID SHARD to work as expected. See shard_mysql recipe source for comments.
- Create a
shard_db
database in MySQL Server, if it is not already created, which will be sharded amongshard_hosts
. - Create
shard_user
database user in MySQL and grant all rights toshard_db
database onlocalhost
as well as the remote node where CUBRID SHARD will be started. - Update conf/shard.conf.
- Update conf/shard_key.txt.
- Update conf/shard_connection.txt.
- Start CUBRID SHARD Service on the last of the
shard_hosts
. This means that if you want a specific node to run CUBRID SHARD, list it as the last element of theshard_hosts
array. - When installed on CentOS, this shard_mysql recipe will auto configure the iptables firewall if iptables is installed. When iptables is installed, by default it
REJECT
's all incoming connections. The shard_mysql recipe will add anACCEPT
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:
- Stop CUBRID Manager Server service.
- Check the version of the installed CUBRID Web Manager.
- If CWM is not installed or its patch version is older than a new available version, download the new package (
tar.gz
) from CUBRID SF.net repository. CWM version will remain the same as the main CUBRID Database. - Extract the downloaded package to /opt/cubrid/. This will override or add CWM binaries to /bin, /conf, and /share directories.
- If CUBRID files are not owned by root, change ownership to root.
- Remove the downloaded archive and extracted directory.
- Override the configuration file for CWM, if it is not already overriden.
- Start CUBRID Manager Server service.
- When installed on CentOS, this web_manager recipe will auto configure the iptables firewall if iptables is installed. When iptables is installed, by default it
REJECT
's all incoming connections. The web_manager recipe will add anACCEPT
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.
- Test on Fedora.
- Allow users to specify custom port for CUBRID HA.
- Test on a vanilla CentOS.
- Validate the database name.
- In shard_mysql check if Ubuntu version is 10.x.
- Add MySQL 5.5 support which is distributed in Ubuntu 12.04+.
- When setting
max_clients
in cubrid.conf, need to updated theulimit
of Linux because by defuault it allows to open 1024 files at a time. Depending on themax_clients
size,ulimit
has to be adjusted. See http://posidev.com/blog/2009/06/04/set-ulimit-parameters-on-ubuntu/ for more instructions. - Add an
init.d
script to start CUBRID service on reboot. - Add travis testing script.
Distributed under MIT License.
- Esen Sagynov ([email protected])