Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Install CUBRID remotely with knife-solo and Chef Cookbook


This tutorial is a part of CUBRID Chef Cookbook series where I show how to install CUBRID Database, its drivers and tools, and configure High-Availability and Database Sharding with a single command.

Unlike in previuos tutorials, in this tutorial I will not use Vagrant. Instead, I will show how to install CUBRID on a remote Linux server using knife-solo, another great command line tool which allows to cook (i.e. install) cookbooks on remote machines. It's really easy, you will see!

Requirements

  1. A remote Linux server which you can SSH. It can be a local virtual machine.
  2. knife-solo installed via gem or source code on your working machine.

Getting Started

I will assume that you have already created a remote Linux server which you can connect to via SSH. Therefore I will directly show how to install knife-solo on your local development machine.

Install knife-solo prerequisites

knife-solo is available in RubyGems repository, therefore it can be installed via gem. But in this tutorial we will install knife-solo from its source code because the knife-solo gem on RubyGems is old. Actually it's just because the latest code in Github has not been released yet.

To build and install knife-solo from the source code, we need gem and bundler programs. If they are already installed on your working machine, you can proceed to the next step. If they are not, you can install them as shown below.

Debian based Linux

sudo apt-get install rubygems libxslt-dev libxml2-dev unzip git
sudo gem install bundler rdoc-data
sudo rdoc-data --install

This will install gem program, XML libraries which bundler program depends on, unzip necessary to extract knife-solo source code from ZIP archive, git necessary to download cookbooks, bundler and rdoc-data gems.

RPM based Linux

sudo yum install rubygems ruby-devel libxslt-devel libxml2-devel unzip git wget
 sudo gem install bundler rdoc-data
 sudo rdoc-data --install

Build knife-solo

wget https://github.com/matschaffer/knife-solo/archive/master.zip
unzip master*
cd knife-solo-master
sudo bundle
sudo bundle exec rake install

This will download the source ZIP from knife-solo Github repo, etract it, build the source, and install the generated knife-solo gem.

Check knife-solo

Type the following command to check if knife-solo has been successfully installed. You should see something like:

~$ gem list | grep knife
knife-solo (0.2.0.pre2)

Prepare the working directory structure

Once knife-solo is ready, we go and create a directory structure where we will be working.

cd
mkdir cubrid-knife
cd cubrid-knife
knife solo init .

This will create a cubrid-knife directory in your user home directory where knife-solo will initialize the working directory. The directory structure that knife-solo will create looks as follows:

/cookbooks
/data_bags
/nodes
/roles
/site-cookbooks
solo.rb

Prepare the remote server

Once we have initialized the working directory on our local working machine, we need to prepare our remote server. For this run knife solo prepare command by specifying your remote server username and IP. In this case, my remote server username is user, and remote server IP is 192.168.85.138. By default SSH port number which knife-solo will use to connect to your remote server is 22. If it is different from the default value, you can specify it with additional -p option.

~$ knife solo prepare user@192.168.85.138
WARNING: No knife configuration file found
Bootstrapping Chef...
Enter the password for user@192.168.85.138: 
--2013-02-11 23:02:58--  https://www.opscode.com/chef/install.sh
Resolving www.opscode.com (www.opscode.com)... 184.106.28.83
Connecting to www.opscode.com (www.opscode.com)|184.106.28.83|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6471 (6.3K) application/x-sh
Saving to: `install.sh'

100%======================================> 6,471       --.-K/s   in 0s      

2013-02-11 23:02:59 (956 MB/s) - `install.sh' saved 6471/6471


Downloading Chef  for ubuntu...
Installing Chef 
Selecting previously unselected package chef.
(Reading database ... 24087 files and directories currently installed.)
Unpacking chef (from .../tmp.Afy1f2L1/chef__amd64.deb) ...
Setting up chef (11.2.0-1.ubuntu.11.04) ...
Thank you for installing Chef!
Generating node config 'nodes/192.168.85.138.json'...

This will:

  1. prepare the remote Linux server by installing a Chef Client;
  2. generate a nodes/192.168.85.138.json configuration file for this particular remote server with an empty runlist which means no cookbook will be installed until we populate the runlist manually.
    {"run_list":[]} 

Download necessary cookbooks

Now we can go and download all cookbooks we want to install on our remote Linux server. In this tutorial we will install the latest version of CUBRID Database Server, PHP, Python, and Perl drivers.

cd ~/cubrid-knife
git init
git submodule add https://github.com/kadishmal/cubrid-cookbook.git cookbooks/cubrid
git submodule add https://github.com/opscode-cookbooks/build-essential.git cookbooks/build-essential
git submodule add https://github.com/opscode-cookbooks/mysql.git cookbooks/mysql
git submodule add https://github.com/opscode-cookbooks/openssl.git cookbooks/openssl
git submodule add https://github.com/opscode-cookbooks/perl.git cookbooks/perl
git submodule add https://github.com/opscode-cookbooks/php.git cookbooks/php
git submodule add https://github.com/opscode-cookbooks/python.git cookbooks/python
git submodule add https://github.com/opscode-cookbooks/yum.git cookbooks/yum
git submodule add https://github.com/opscode-cookbooks/xml.git cookbooks/xml

This will clone each cookbook under cookbooks/ directory.

Choose which cookbook to install

Once we have downloaded the cookbook, we need to tell knife-solo that we want to cook a particular cookbook. For this we need to add the cookbook name to the runlist. Edit the nodes/192.168.85.138.json file as shown below.

{"run_list":
  "cubrid",
  "cubrid::demodb",
  "cubrid::pdo_cubrid",
  "cubrid::perl_driver",
  "cubrid::php_driver",
  "cubrid::python_driver",
  "cubrid::web_manager"
}

This will tell knife-solo, which will tell to Chef installed on the remote server, to install CUBRID Database, its demodb database, PHP/PDO, Perl, and Python drivers, as well as CUBRID Web Manager, all from cubrid cookbook that we have downloaded.

Cook the remote server

Now as we are ready to cook our remote Linux server, let's do it.

~$ knife solo cook user@192.168.85.138
Checking Chef version...
Enter the password for user@192.168.85.138: 
user@192.168.85.138's password: 
user@192.168.85.138's password: 
user@192.168.85.138's password: 

Starting Chef Client, version 11.2.0
Compiling Cookbooks...
Converging 58 resources
...
Chef Client finished, 48 resources updated

Bingo! You have installed CUBRID and all the necessary drivers and even a Web Manager on your remote server.

Testing CUBRID Web Manager

Let's access CUBRID Web Manager at https://192.168.85.138:8282. Notice HTTPS and 8282 port. 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.

Questions?

If you have questions, feel free to ask at CUBRID Q&A site, forum, our Facebook page, Twitter, or online chat.

If you have issues or feature requests to cubrid-cookbook, create a new issue at its Github repo.

comments powered by Disqus
Page info
viewed 7427 times
translations en
Author
posted last year by
Esen Sagynov
Contributors
updated last year by
View revisions
Share this article