Статьи

VoltDB: Создание Openshift Cartridge, часть 1

Этот пост был написан Джеффом Маккормиком 25 марта и первоначально опубликован здесь .

Вступление

В этом блоге описывается новый картридж Openshift, разработанный для базы данных VoltDB ( www.voltdb.com ). Я изучал VoltDB и подумал, что другим может быть полезен быстрый доступ к размещенному в Openshift экземпляру базы данных. VoltDB действительно впечатляет как по производительности, так и по возможностям.

«Картридж» — это средство упаковки и развертывания приложения, в данном случае базы данных VoltDB, на платформе Openshift PaaS.

Картридж VoltDB в бета-версии находится по адресу:

https://github.com/jmccormick2001/voltdb-cart

Комбинация Openshift PaaS и VoltDB делает для некоторых интересных идей проекта!

Примечание о производительности

Openshift работает либо в общедоступном облаке, размещенном Redhat по адресу http://openshift.redhat.com , либо вы можете установить Openshift на собственное оборудование.

Очевидно, что для обеспечения максимальной производительности использование VoltDB в собственной частной инфраструктуре обеспечит максимальную производительность. Но для простого тестирования VoltDB и изучения его различных функций инфраструктура публичного облака будет работать нормально.

Картридж, который мы разработали для VoltDB, будет работать в общедоступном облаке Openshift или в частных версиях Openshift, поэтому выбор за вами.

Сценарий установки

Для этого картриджа на этом бета-этапе я использовал предоставленный VoltDB пример VoltCache в качестве схемы базы данных и скомпилированного каталога приложений, который будет установлен картриджем. В последующих блогах вы узнаете, как заменить этот каталог приложений по умолчанию на собственный каталог приложений VoltDB.

Образец развертывания

Создайте публичную учетную запись Redhat Openshift по адресу http://openshift.redhat.com .
Войдите в свою учетную запись, определите свое доменное имя (например, voltdbtest):

snapshot1.png

загрузите ваш открытый ключ, который вы хотите использовать:

snapshot2.png

Нажмите кнопку Добавить приложение, чтобы начать:

Создайте приложение «Сделай сам», приложение «Сделай сам» находится внизу приложения.

snapshot3.png

Затем добавьте картридж VoltDB в свое приложение, щелкните ссылку « Перейти к странице обзора приложения» :

snapshot5.png

Затем укажите следующий URL-адрес в разделе «Установка собственного картриджа» на веб-странице:

https://raw.githubusercontent.com/jmccormick2001/voltdb-cart/master/metadata/manifest.yml

В этот момент, если вы нажмете кнопку «Добавить картридж», он установит картридж VoltDB в ваше приложение Openshift:

At this point, VoltDB should be running on your application host and is ready to test!

Install Openshift Client Utilities

On your client host, in this example a Fedora 20 desktop, you will run the client for the VoltDB VoltCache example. In order to do this, you will need to create networking tunnels to your Openshift application instance. For this, you will need to install the Redhat Openshift client tools called ‘rhc’.

The Openshift client installation is documented at the following location:

https://www.openshift.com/developers/rhc-client-tools-install

Test the rhc client tools by displaying information (using the rhc app show command) about your newly installed VoltDB application:

Also at this point, you can log into your new application by issuing the rhc ssh command as follows:

Start Port Forwarding

After the rhc installation, you will need to create the necessary port forwarding tunnels to your Openshift application instance as follows using the rhc port-forward command:

After the port forwarding has been started, you can now access from your local client (127.0.0.1) the various VoltDB ports that are running remotely on the Openshift cloud application you have installed.

Running the VoltCache Client

At this point, you will need to have downloaded the VoltDB community distribution to your client host. The cartridge is based upon the VoltDB 4.0.2.3 Community Edition. The VoltDB product can be downloaded from:

http://voltdb.com/download/software

The connectivity (at least from my home office) to the public Openshift is really tested by this example and I found that I needed to reduce the speed at which the VoltDB client sends work to the cloud hosted VoltDB instance, so I adjusted the examples/voltcache/run.sh script used to execute the client as follows:

function benchmark() {
srccompile
java -classpath obj:$APPCLASSPATH:obj -Dlog4j.configuration=file://$LOG4J \
voltcache.Benchmark \
–threads=10 \
–displayinterval=5 \
–duration=20 \
–servers=localhost \
–poolsize=1000 \
–preload=true \
–getputratio=0.90 \
–keysize=32 \
–minvaluesize=1024 \
–maxvaluesize=1024 \
–usecompression=false

Here is an example of running the VoltDB VoltCache example client which performs a benchmark:

snapshot13.png

VoltDB Studio Web Application

A nice utility that is shipped with VoltDB is their Studio web application, found at the following URL:

http://127.0.0.1:16000/studio/

snapshot14.png

Using Studio, you can issue a SQL query against the deployed VoltDB application. Notice that the URL here is based on the rhc port-forward command being issued.

Cartridge Development

Getting the cartridge to work in the Origin version of Openshift was a bit easier because you have the ability to bind to localhost (127.0.0.1). In the public Openshift, binding to localhost (127.0.0.1) is not allowed.

To get VoltDB to work in the public version of Openshift, there were a few steps required including:

adjusting ports

In the public Openshift, there are various port conflicts and protected ports, to avoid these problems, I’ve adjusted the VoltDB ports as follows:

  1. zookeeper port is 16300
  2. internal port is 16700
  3. http port is 16000

creating http host command line parameter

In this version of VoltDB, the internal HTTP server was binding to localhost by default and there was no way to specify a different host, so I modified the VoltDB code to allow for a new command line parameter called httphost to let me use the Openshift assigned internal IP address (e.g. OPENSHIFT_DIY_IP)

creating zookeeper host command line parameter

Also, in this version of VoltDB, the internal Zookeeper host was defined as localhost, so I created a new command line parameter called zkhost which allows me to override localhost with the Openshift internal IP address (e.g. OPENSHIFT_DIY_IP).

altering run.sh

To start VoltDB, I need to pass in various parameters to the voltdb command as follows:

voltdb create –internal 16700 –externalinterface $OPENSHIFT_DIY_IP –zookeeper 16300 –httphost $OPENSHIFT_DIY_IP -d $OPENSHIFT_VOLTDB_DIR/sample/deployment.xml –zkhost $OPENSHIFT_DIY_IP -H $OPENSHIFT_DIY_IP –internalinterface $OPENSHIFT_DIY_IP

To stop the VoltDB, I need to pass in the new server host IP address to the voltadmin command as follows:

voltadmin pause -H $OPENSHIFT_DIY_IP;
voltadmin shutdown -H $OPENSHIFT_DIY_IP;

bundling and installing 64 bit JRE

VoltDB requires a 64 bit JRE to run. Interestingly, the public Openshift does not include a 64 bit JRE but rather a 32 bit JRE even though it runs on 64 bit RHEL 6.5! So, I needed to bundle the 64 bit JRE within the cartridge in order to have a proper JRE for VoltDB to run with.

Next Steps

This initial blog shows you some very basic ways to deploy a VoltDB database to the Openshift PaaS. In upcoming blogs, I’ll show you how to modify the deployed VoltDB database schema / compiled catalog and also how to deploy it to Openshift web frameworks other than the DIY framework.