Getting Started Guide

dussab edited this page Feb 21, 2013 · 17 revisions
Clone this wiki locally

Prerequisite Software

The following software is required to build or run the SpringTrader application.

To Build

  • Git 1.7.10 or later
  • Groovy 1.8.1 or later
  • Java 1.6 or later

To deploy

  • Java 1.6 or later
  • Erlang R14B (required by RabbitMQ)
  • vFabric tc Server 2.7 or later
  • vFabric RabbitMQ Server 2.8 or later
  • vFabric SQLFire 1.0.x

Optional Software

  • vFabric RabbitMQ Management Plug-in (to view channel/queue stats)
  • vFabric EM4J Console Plug-in (to monitor JVMs running in VMs from the vSphere Web Client)

Software Installation and Configuration

Linux (CentOS/RHEL 5/6)

Add vFabric Suite Yum Repo for installing vFabric products using rpm package format. Following command will add appropriate repo on your linux system.

CentOS/RHEL 5

sudo rpm -ivhf http://repo.vmware.com/pub/rhel5/vfabric/5.1/vfabric-5.1-repo-5.1-1.noarch.rpm

CentOS/RHEL 6

sudo rpm -ivhf http://repo.vmware.com/pub/rhel6/vfabric/5.1/vfabric-5.1-repo-5.1-1.noarch.rpm

Once the repo is set you can use yum search vfabric to list all vFabric products. Next we will use yum to install vFabric products required to run SpringTrader.

Install tc Server

More details about tc Server installation and configuration are available here.

sudo yum install vfabric-tc-server-standard

More details about tc Server installation and configuration are available here.

Install SQLFire

sudo yum install vfabric-sqlfire

More details about SQLFire installation and configuration are available here.

Install Erlang

RabbitMQ depends on Erlang. Erlang must be installed before RabbitMQ.

CentOS/RHEL 5

sudo rpm -uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget -O /etc/yum.repos.d/epel-erlang.repo http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo
yum install erlang

CentOS/RHEL 6

sudo rpm -uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
yum install erlang

More details about installing Erlang are available here

Install RabbitMQ

yum install vfabric-rabbitmq-server

More details about RabbitMQ installation and configuration are available here.

Host Configuration

Add a definition of "nanodbserver" to your /etc/hosts file. We use this in jdbc url.

127.0.0.1 localhost nanodbserver

Define the JAVA_HOME environment variable and add java to your path. This is required by tc Server.

# Use appropriate path on your system
export JAVA_HOME=/usr/java/jdk1.6.0_X
export PATH=$PATH:/usr/java/jdk1.6.0_X/bin

Now that we have all required vFabric Products installed, lets start them.

Start RabbitMQ Server

RabbitMQ rpm added service scripts for root user. We will use that to start it.

sudo service rabbitmq-server start

Start SQLFire

cd /opt/vmware/vfabric-sqlfire/vFabric_SQLFire_103
mkdir locator1 server1
sqlf locator start -peer-discovery-address=127.0.0.1 -peer-discovery-port=3241 -dir=locator1 -client-port=1527 -client-bind-address=127.0.0.1
sqlf server start -dir=server1 -client-bind-address=127.0.0.1 -client-port=1528 -locators=127.0.0.1[3241]

Build SpringTrader Application

Clone springtrader repo

Clone SpringTrader github repo under your home directory. It should create ~/springtrader folder.

git clone git@github.com:vFabric/springtrader.git
Note: Please see github help for generating ssh keys: https://help.github.com/articles/generating-ssh-keys

As an alternative you can use the https method: https://github.com/vFabric/springtrader.git


Setup SQLFire Client jar

Copy the sqlfireclient.jar file from SQLFire installation to ~/springtrader/lib/
cp /opt/vmware/vfabric-sqlfire/vFabric_SQLFire_103/lib/sqlfireclient.jar ~/springtrader/lib/sqlfireclient-1.0.3.jar

Copy the sqlfireclient jar file into tc Server springtrader template
cp /opt/vmware/vfabric-sqlfire/vFabric_SQLFire_103/lib/sqlfireclient.jar ~/springtrader/templates/springtrader/lib/sqlfireclient-1.0.3.jar

Setup Gemfire jar

Download gemfire binaries in zip format here and unzip it
Copy the gemfire.jar from lib directory into ~/springtrader/lib/gemfire.jar

Build springtrader

export GRADLE_OPTS='-Xmx1024m -Xms256m -XX:MaxPermSize=512m'

If you are behind proxy, add proxy to GRADLE_OPTS

export GRADLE_OPTS=$GRADLE_OPTS" -Dhttp.proxyHost=http://proxy.vmware.com -Dhttp.proxyPort=3128"

Run gradle build

cd ~/springtrader
./gradlew clean build release

This should generate following files under dist folder

ls dist
spring-nanotrader-asynch-services-1.0.1.BUILD-SNAPSHOT.war
spring-nanotrader-services-1.0.1.BUILD-SNAPSHOT.war
spring-nanotrader-web-1.0.1.BUILD-SNAPSHOT.war
spring-nanotrader-web-1.0.1.BUILD-SNAPSHOT.tgz
DataGenerator.zip

Unzip dist/DataGenerator.zip and load SpringTrader schema

cp /opt/vmware/vfabric-sqlfire/vFabric_SQLFire_103/lib/sqlfireclient.jar ~/springtrader/dist/libs/sqlfireclient-1.0.3.jar
cd ~/springtrader/dist
unzip DataGenerator.zip
./createSqlfSchema
cd ..

Deploy SpringTrader in tc Server

Add springtrader template under tc Server. We will apply this template when creating tc Server instance next. The template contains jdbc driver for SQLFire as well as resource configuration and default properties to connect tc Server to SQLFire.

cp -r ~/springtrader/templates/springtrader /opt/vmware/vfabric-tc-server-standard/templates

Create a tc Server instance (with instance name = springtrader). Following will create an instance named springtrader.

cd /opt/vmware/vfabric-tc-server-standard # This is default tc Server home directory
./tcruntime-instance.sh create springtrader -t springtrader -f templates/springtrader/sqlfire.properties

Copy SpringTrader war files to the instance we just created.

cp ~/springtrader/dist/spring-nanotrader-asynch-services-1.0.1.BUILD-SNAPSHOT.war /opt/vmware/vfabric-tc-server-standard/springtrader/webapps/spring-nanotrader-asynch-services.war
cp ~/springtrader/dist/spring-nanotrader-services-1.0.1.BUILD-SNAPSHOT.war /opt/vmware/vfabric-tc-server-standard/springtrader/webapps/spring-nanotrader-services.war
cp ~/springtrader/dist/spring-nanotrader-web-1.0.1.BUILD-SNAPSHOT.war /opt/vmware/vfabric-tc-server-standard/springtrader/webapps/spring-nanotrader-web.war

Update JVM_OPTS for tc Server instance

cd /opt/vmware/vfabric-tc-server-standard/springtrader/bin
# Add following to setenv.sh
JVM_OPTS="-Xmx1024m -Xss192K -XX:MaxPermSize=192m"

Copy the sqlfireclient into the Tomcat/lib directory

Copy the sqlfireclient.jar to the tc Server /opt/vmware/vfabric-tc-server-standard/springtrader/lib directory
cp ~/springtrader/lib/sqlfireclient-1.0.3.jar /opt/vmware/vfabric-tc-server-standard/springtrader/lib/sqlfireclient-1.0.3.jar

Start springtrader tc Server instance

./tcruntime-ctl.sh springtrader start

Generate Sample Data

After the "springtrader" tc Server instance is running, you can optionally load sample data into the database.

cp /opt/vmware/vfabric-sqlfire/vFabric_SQLFire_103/lib/sqlfireclient.jar ~/springtrader/dist/libs/sqlfireclient-1.0.3.jar
cd ~/springtrader/dist
./generateData

With your Web browser, navigate to the following URL to view the SpringTrader login page: http://localhost:8080/spring-nanotrader-web

MAC

Install required sofware on mac.

Use brew to install groovy and RabbitMQ. Download and install tc Server and SQLFire evaluation versions manually.

brew install groovy
brew install rabbitmq

Host Configuration

Add a definition of "nanodbserver" to your /etc/hosts file. We use this in jdbc url.

127.0.0.1 localhost nanodbserver

Warning: On a MAC (seen on Lion and Snow Leopard), the /etc/hosts file can be reset by VPN connection software. See here

Define the JAVA_HOME environment variable and add java to your path. JAVA_HOME is required by tc Server.

export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

RabbitMQ Startup

rabbitmq-server &

Start SQLFire

Assuming you installed SQLFire version 1.0.3 under your home directory run following to create and start a SQLFire Locator and SQLFire Server.

export PATH=$PATH:~/vFabric_SQLFire_103/bin # Add SQLFire to path to run sqlf command
cd ~/vFabric_SQLFire_103
mkdir locator1 server1
sqlf locator start -peer-discovery-address=127.0.0.1 -peer-discovery-port=3241 -dir=locator1 -client-port=1527 -client-bind-address=127.0.0.1
sqlf server start -dir=server1 -client-bind-address=127.0.0.1 -client-port=1528 -locators=127.0.0.1[3241]

Clone springtrader repo

Clone SpringTrader github repo under your home directory. It should create ~/springtrader folder.

git clone git@github.com:vFabric/springtrader.git

Setup SQLFire Client jar

Copy the sqlfireclient.jar file from SQLFire installation to ~/springtrader/lib/
cp ~/vFabric_SQLFire_103/lib/sqlfireclient.jar ~/springtrader/lib/sqlfireclient-1.0.3.jar


Copy the sqlfireclient jar file into tc Server springtrader template
cp ~/vFabric_SQLFire_103/lib/sqlfireclient.jar ~/springtrader/templates/springtrader/lib/sqlfireclient-1.0.3.jar

Setup Gemfire jar

Download gemfire binaries in zip format here and unzip it
Copy the gemfire.jar from lib directory into ~/springtrader/lib/gemfire.jar

Build springtrader

export GRADLE_OPTS='-Xmx1024m -Xms256m -XX:MaxPermSize=512m'

If you are behind proxy, add proxy to GRADLE_OPTS

export GRADLE_OPTS=$GRADLE_OPTS" -Dhttp.proxyHost=http://proxy.vmware.com -Dhttp.proxyPort=3128"

Run gradle build

cd ~/springtrader
./gradlew clean build release

This should generate following files under dist folder

ls dist
spring-nanotrader-asynch-services-1.0.1.BUILD-SNAPSHOT.war
spring-nanotrader-services-1.0.1.BUILD-SNAPSHOT.war
spring-nanotrader-web-1.0.1.BUILD-SNAPSHOT.war
spring-nanotrader-web-1.0.1.BUILD-SNAPSHOT.tgz
DataGenerator.zip

Unzip dist/DataGenerator.zip and load SpringTrader schema

cd ~/springtrader/dist
unzip DataGenerator.zip
./createSqlfSchema
cd ..

Deploy SpringTrader in tc Server

Add springtrader template under tc Server. We will apply this template when creating tc Server instance next. The template contains jdbc driver for SQLFire as well as resource configuration and default properties to connect tc Server to SQLFire. Assuming you installed tc Server 2.7.1 RELEASE version under you home directory run following.

cp -r ~/springtrader/templates/springtrader ~/vfabric-tc-server-developer-2.7.1.RELEASE/templates

Create a tc Server instance (with instance name = springtrader). Following will create an instance named springtrader.

cd ~/vfabric-tc-server-developer-2.7.1.RELEASE
./tcruntime-instance.sh create springtrader -t springtrader -f templates/springtrader/sqlfire.properties

Copy springtrader war files to the instance we just created.

cp ~/springtrader/dist/spring-nanotrader-asynch-services-1.0.1.BUILD-SNAPSHOT.war ~/vfabric-tc-server-developer-2.7.1.RELEASE/springtrader/webapps/spring-nanotrader-asynch-services.war
cp ~/springtrader/dist/spring-nanotrader-services-1.0.1.BUILD-SNAPSHOT.war ~/vfabric-tc-server-developer-2.7.1.RELEASE/springtrader/webapps/spring-nanotrader-services.war
cp ~/springtrader/dist/spring-nanotrader-web-1.0.1.BUILD-SNAPSHOT.war ~/vfabric-tc-server-developer-2.7.1.RELEASE/springtrader/webapps/spring-nanotrader-web.war

Update JVM_OPTS for tc Server instance

cd /opt/vmware/vfabric-tc-server-standard/springtrader/bin
# Add following to setenv.sh
JVM_OPTS="-Xmx1024m -Xss192K -XX:MaxPermSize=192m"

Copy the sqlfireclient into the Tomcat/lib directory

Copy the sqlfireclient.jar to the tc Server /opt/vmware/vfabric-tc-server-standard/springtrader/lib directory
cp ~/springtrader/lib/sqlfireclient-1.0.3.jar /opt/vmware/vfabric-tc-server-standard/springtrader/lib/sqlfireclient-1.0.3.jar

Start springtrader tc Server instance

./tcruntime-ctl.sh springtrader start

Generate Sample Data

After the "springtrader" tc Server instance is running, you can optionally load sample data into the database.

cd ~/springtrader/dist
./generateData

With your Web browser, navigate to the following URL to view the SpringTrader login page: http://localhost:8080/spring-nanotrader-web

Run springtrader under STS

Update ~/springtrader/templates/springtrader-sqlfire-sts/lib directory with sqlfireclient-1.0.3.jar
Copy springtrader-sqlfire-sts template directory into tc server templates directory ~/vfabric-tc-server-developer-2.7.1.RELEASE/templates

In STS, right click on blank area in Servers pane, select New --> Server.
On the first page, "Define a New Server", edit the "Server name" field to be something unique, like "tc Server springtrader"; click Next.
On the 2nd page, "tc Server Configuration", leave the default "Create new instance" selected; click Next.
On the 3rd page, "Create tc Server Instance": give the instance a unique "Name" like "springtrader-sqlfire"
    select desired Templates including "springtrader-sqlfire-sts"
    click Next
On the "Add and Remove" page, select desired resources from the Available and Add them to the Configured column; click Finish.

Use "springtrader-postgres-sts" template instead of "springtrader-sqlfire-sts" if you want to setup postgres as the database