Skip to content

Instantly share code, notes, and snippets.

@ScottEvil
Last active January 16, 2017 01:01
Show Gist options
  • Save ScottEvil/5ce17d5d349be11429c0 to your computer and use it in GitHub Desktop.
Save ScottEvil/5ce17d5d349be11429c0 to your computer and use it in GitHub Desktop.
Install Process for GeoServer, GeoMesa and Kafka on Ubuntu 14
#For this Virtual Machine, I used the basic Ubuntu 14.04 server iso with VirtualBox.
#I created the VM in VBox the standard way and then used that iso to install Ubuntu 14.04. The only option I used for the server was SSH server
#Set up the basic software needed for the machine
sudo apt-get update
#add static IP to eth1
sudo nano /etc/network/interfaes
#add the following lines
auto eth1
iface eth1 inet static
address xx.xx.xx.xx
netmask 255.255.255.0
network xx.xx.xx.xx
sudo shutdown -h now
#Set up adaptor #2 in VBox as Host Only and add the share folder. Then start up the VM
#ssh into the machine
#Install JDK
sudo apt-get install default-jdk
#install ant and git
sudo apt-get install ant git
#check to see what your path to java is: something like /usr/lib/jvm/java-7-openjdk-amd64/
#set JAVA_HOME
sudo nano /etc/bash.bashrc
#add the following lines:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
export PATH=$PATH:$JAVA_HOME/bin
#save and close
source /etc/bash.bashrc
echo $JAVA_HOME
#Install maven to support building GeoMesa later
sudo apt-cache search maven
sudo apt-get install maven
mvn -version
#Install Tomcat, I used this as a resource:
#https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-ubuntu-14-04-via-apt-get
sudo apt-get install tomcat7
sudo nano /etc/default/tomcat7
#Replace the JAVA_OPTS line with the following line
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC"
sudo service tomcat7 restart
#Make sure tomcat is working by going to http://IPaddress:8080
sudo apt-get install tomcat7-docs tomcat7-admin tomcat7-examples
sudo nano /etc/tomcat7/tomcat-users.xml
#add the following line in the <tomcat-users> tag
<user username="admin" password="password" roles="manager-gui,admin-gui"/>
#This is a good time to shutdown the machine and snapshot
#Install GeoServer 2.5.2
cd ~/
sudo mkdir Downloads
cd Downloads
sudo wget http://downloads.sourceforge.net/project/geoserver/GeoServer/2.5.2/geoserver-2.5.2-war.zip
sudo wget http://downloads.sourceforge.net/project/geoserver/GeoServer/2.5.2/extensions/geoserver-2.5.2-wps-plugin.zip
sudo unzip geoserver-2.5.2-war.zip
sudo cp geoserver.war /var/lib/tomcat7/webapps/
sudo service tomcat7 restart
#browse to :8080/geoserver to make sure the war deployed
sudo unzip geoserver-2.5.2-wps-plugin.zip
sudo cp *.jar /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/
cd /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/
#update permissions for the files so they're owned by the tomcat7 user
sudo chown tomcat7:tomcat7 *wps*jar
sudo chown tomcat7:tomcat7 gt-process-geometry-11.2.jar
sudo chown tomcat7:tomcat7 serializer-2.7.1.jar
ls -la
#If all of the files are set to tomcat7:tomcat7 and permissions are -rw-r--r-- then you can move on
#Install zookeeper using this as reference
#http://czcodezone.blogspot.com/2014/11/setup-zookeeper-on-single-machine.html
cd ~/Downloads
sudo mkdir zookeeper
cd zookeeper
sudo wget http://mirror.nus.edu.sg/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
sudo tar xvf zookeeper-3.4.6.tar.gz
cd /usr/
sudo mkdir zookeeper
sudo mv ~/Downloads/zookeeper/zookeeper-3.4.6/ /usr/zookeeper/
cd /usr/zookeeper/zookeeper-3.4.6/conf/
sudo nano zoo.cfg
#In the zoo.cfg file add the following lines
tickTime=2000
dataDir=/tmp/zookeeper
clientPort=2181
sudo nano /etc/bash.bashrc
#Add the ZK_HOME env variable
export ZK_HOME=/usr/zookeeper/zookeeper-3.4.6/
source /etc/bash.bashrc
echo $ZK_HOME
cd usr/zookeeper/zookeeper-3.4.6/
sudo ./bin/zkServer.sh start
sudo ./bin/zkServer.sh status
#Install and configure Kafka
cd ~/Downloads/
sudo mkdir kafka
cd kafka
sudo wget http://supergsego.com/apache/kafka/0.8.2.1/kafka_2.10-0.8.2.1.tgz
sudo tar xvzf kafka_2.10-0.8.2.1.tgz
cd ..
sudo mkdir scala
cd scala
sudo wget http://downloads.typesafe.com/scala/2.10.5/scala-2.10.5.tgz
sudo tar xvzf scala-2.10.5.tgz
sudo mkdir /usr/local/share/scala/
sudo mv ~/Downloads/scala/scala-2.10.5/* /usr/local/share/scala/
sudo nano /etc/bash.bashrc
#Add SCALA_HOME to the bashrc file
export SCALA_HOME=/usr/local/share/scala
export PATH=$PATH:$SCALA_HOME/bin
source /etc/bash.bashrc
echo $SCALA_HOME
sudo mkdir /usr/kafka/
sudo mv ~/Downloads/kafka/kafka_2.10-0.8.2.1/* /usr/kafka/
sudo nano /etc/bash.bashrc
#Add KAFKA_HOME to bashrc
export KAFKA_HOME=/usr/kafka/
source /etc/bash.bashrc
echo $KAFKA_HOME
sudo nano usr/kafka/config/server.properties
#find the line zookeeper.connect=localhost:2181 and put the correct IP in
#find log.dirs=/tmp/kafka-logs and change to log.dirs=/var/kafka-logs then save the changes and exit nano
sudo nano usr/kafka/config/producer.properties
#find the line metadata.broker.list=localhost:9092 and put in the machine ip
sudo nano usr/kafka/config/consuber.properties
#find the line for zookeeper.connect and give it the right value
sudo mkdir /var/kafka-logs
sudo chmod -R 777 /var/kafka-logs
#A test topic following the example at
#http://czcodezone.blogspot.com/2014/11/setup-kafka-in-single-machine-running.html
sudo ./kafka-topics.sh --create --zookeeper 192.168.2.2:2181 --topic verification-topic --partitions 1 --replication-factor 1
#check the topic
sudo ./kafka-topics.sh --zookeeper 192.168.2.2:2181 --list
#start up the producer in a second terminal
sudo ./kafka-console-producer.sh --broker-list localhost:9092 --topic verification-topic
#start up the consumer in a thrid termnial
sudo ./kafka-console-consumer.sh --zookeeper 192.168.56.80:2181 --topic verification-topic
#Set up geomesa kafka plugin
cd ~/Downloads
sudo git clone https://github.com/locationtech/geomesa.git
sudo cp ~/Downloads/geomesa/geomesa-kafka/geomesa-kafka-geoserver-plugin/target/geomesa-kafka-geoserver-plugin-1.1.0-rc.3-SNAPSHOT-geoserver-plugin.jar /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/
#Navigate to the folder where all of the Kafka jars were downloaded to, and copy the following jars over to GeoServer
cd ~/Downloads/kafka/kafka_2.10-0.8.2.1/libs/
sudo cp kafka-clients-0.8.2.1.jar /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/
sudo cp kafka_2.10-0.8.2.1.jar /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/
sudo cp metrics-core-2.2.0.jar /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/
sudo cp zkclient-0.3.jar /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/
sudo cp zookeeper-3.4.6.jar /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/
export CATALINA_OPTS="-Xms512M -Xmx1024M -XX:PermSize=256m -XX:MaxPermSize=256m"
cd /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/
ls -la
#Make sure permissions are set on all of the new jars to tomcat7:tomcat7
sudo chown tomcat7:tomcat7 zkclient-0.3.jar
sudo chown tomcat7:tomcat7 zookeeper-3.4.6.jar
sudo chown tomcat7:tomcat7 kafka*.jar
sudo chown tomcat7:tomcat7 metrics-core-2.2.0.jar
sudo chown tomcat7:tomcat7 geomesa-kafka-geoserver-plugin-1.1.0-rc.3-SNAPSHOT-geoserver-plugin.jar
#restart Tomcat and make sure the kafka data store is an option under add new stores in GeoServer admin UI
sudo service tomcat7 restart
#Test the Kafka plugin to make sure everything works
#run this command from the folder where the geomesa jars were built (making adjustments for the correct IP address:
java -cp ./geomesa-examples/geomesa-kafka-quickstart/target/geomesa-kafka-quickstart-1.1.0-rc.3-SNAPSHOT.jar org.locationtech.geomesa.examples.KafkaQuickStart -brokers "192.168.xx.xx:9092" -zookeepers "192.168.xx.xx:2181"
#Follow the instructions at http://www.geomesa.org/geomesa-kafka-quickstart/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment