Play Raspberry Pi(8)Cassandra in Docker
1 Installation Cassandra
Exception:
Cassandra 3.0 and later require Java 8u40 or later.
Solution:
Install JDK8 with arm version there, I am using 32 bit.
> java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) Client VM (build 25.91-b14, mixed mode)
Exception:
bin/cqlsh localhost 9042
No appropriate python interpreter found.
Solution:
On my master machine on Local MAC OS
>python -V
Python 2.7.10
> java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Install latest cassandra on my master machine as well.
> wget http://mirror.cc.columbia.edu/pub/software/apache/cassandra/3.7/apache-cassandra-3.7-bin.tar.gz
> sudo ln -s /Users/carl/tool/apache-cassandra-3.7 /opt/cassandra-3.7
> sudo ln -s /opt/cassandra-3.7 /opt/cassandra
> cat ~/.profile
PATH="/opt/cassandra/bin:$PATH"
Exception:
Exception (org.apache.cassandra.exceptions.ConfigurationException) encountered during startup: If rpc_address is set to a wildcard address (0.0.0.0), then you must set broadcast_rpc_address to a value other than 0.0.0.0
If rpc_address is set to a wildcard address (0.0.0.0), then you must set broadcast_rpc_address to a value other than 0.0.0.0
ERROR 21:30:19 Exception encountered during startup: If rpc_address is set to a wildcard address (0.0.0.0), then you must set broadcast_rpc_address to a value other than 0.0.0.0
ERROR 22:15:18 Exception encountered during startup
java.lang.RuntimeException: Unable to gossip with any seeds
at org.apache.cassandra.gms.Gossiper.doShadowRound(Gossiper.java:1386) ~[apache-cassandra-3.7.jar:3.7]
at org.apache.cassandra.service.StorageService.checkForEndpointCollision(StorageService.java:561) ~[apache-cassandra-3.7.jar:3.7]
Solution:
I have an IP for docker container, one IP for the master machine. So the final configuration will be as follow:
Dockerfile
cat Dockerfile
#Set up Cassandra in Docker
#Prepre the OS
FROM resin/rpi-raspbian:jessie
MAINTAINER Carl Luo <luohuazju@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update
RUN apt-get -y dist-upgrade
#prepare env
RUN mkdir /tool/
ADD install/jdk-8u91-linux-arm32-vfp-hflt.tar.gz /tool/
RUN update-alternatives --install /usr/bin/java java /tool/jdk1.8.0_91/bin/java 1
#Install the application
WORKDIR /tool/
ADD install/apache-cassandra-3.7-bin.tar.gz /tool/
RUN mkdir /tool/apache-cassandra-3.7/logs
RUN mkdir /tool/apache-cassandra-3.7/data
ADD conf/cassandra.yaml /tool/apache-cassandra-3.7/conf/
#Start the Application
# 7000: intra-node communication
# 7001: TLS intra-node communication
# 7199: JMX
# 9042: CQL
# 9160: thrift service
EXPOSE 7000 7001 7199 9042 9160
RUN mkdir -p /app/
ADD start.sh /app/
WORKDIR /app
CMD [ "./start.sh" ]
Makefile
cat Makefile
IMAGE=sillycat/public
TAG=raspberrypi-cassandra
NAME=raspberrypi-cassandra
prepare:
wget http://apache.claz.org/cassandra/3.7/apache-cassandra-3.7-bin.tar.gz -P install/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-arm32-vfp-hflt.tar.gz" -P install/
mkdir logs
mkdir data
docker-context:
build: docker-context
# docker build --no-cache -t $(IMAGE):$(TAG) .
docker build -t $(IMAGE):$(TAG) .
run:
docker run -d -p 7000-7001:7000-7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 -v /opt/cassandra/data:/tool/apache-cassandra-3.7/data -v /opt/cassandra/logs:/tool/apache-cassandra-3.7/logs --name $(NAME) $(IMAGE):$(TAG)
debug:
docker run -ti -p 7000-7001:7000-7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 -v /opt/cassandra/data:/tool/apache-cassandra-3.7/data -v /opt/cassandra/logs:/tool/apache-cassandra-3.7/logs --name $(NAME) $(IMAGE):$(TAG) /bin/bash
clean:
docker stop ${NAME}
docker rm ${NAME}
logs:
docker logs ${NAME}
publish:
docker push ${IMAGE}:${TAG}
fetch:
docker pull ${IMAGE}:${TAG}
Some important part in cassandra.yaml
> cat conf/cassandra.yaml
seed_provider:
# Addresses of hosts that are deemed contact points.
# Cassandra nodes use this list of hosts to find each other and learn
# the topology of the ring. You must change this if you are running
# multiple nodes!
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
# seeds is actually a comma-delimited list of addresses.
# Ex: "<ip1>,<ip2>,<ip3>"
- seeds: "192.168.0.198"
listen_address: 172.17.0.3
broadcast_address: 192.168.0.198
rpc_address: 0.0.0.0
broadcast_rpc_address: 192.168.0.198
> cat start.sh
#!/bin/sh -ex
#start the cassandra
/tool/apache-cassandra-3.7/bin/cassandra -Dcassandra.config=file:///tool/apache-cassandra-3.7/conf/cassandra.yaml -R
It works
> cqlsh 192.168.0.198 9042
> cqlsh raspberrypi1 9042
one way to pass the parameters is -e in the command line in Makefile, then in start.sh, we can write the value to YAML file before we start the cassandra DB
>sed -ri 's/(- seeds:).*/\1 "'"$CASSANDRA_SEEDS"'"/' "$CASSANDRA_CONFIG/cassandra.yaml"
Issues with the disk, I guess there is some issues with that because of I am using an external USB driver.
ERROR 18:03:18 Fatal exception during initialization
org.apache.cassandra.exceptions.ConfigurationException: Found system keyspace files, but they couldn't be loaded!
at org.apache.cassandra.db.SystemKeyspace.checkHealth(SystemKeyspace.java:921) ~[apache-cassandra-3.7.jar:3.7]
at org.apache.cassandra.service.StartupChecks$9.execute(StartupChecks.java:325) ~[apache-cassandra-3.7.jar:3.7]
Finally, found that it may not be a good choice for me, because I want to store the data in USB driver. My main storage on raspberryPI is 8G sd card. I do not want to store my data on SD card.
It may relate to this one
http://www.tuxera.com/community/open-source-ntfs-3g/
Some other DB options
http://www.raspberrypiblog.com/2012/11/getting-started-with-databases-on-pi.html Sqlite3
https://github.com/orientechnologies/orientdb orientDB
References:
Cassandra 1 ~ 8
http://sillycat.iteye.com/blog/1870661 v1.2.4 installation and client check
http://sillycat.iteye.com/blog/2011524 source installation and hector java driver
http://sillycat.iteye.com/blog/2011525 hector scala implementation
http://sillycat.iteye.com/blog/2011526 kryo, convert Objects to bytes, bytes to Object
http://sillycat.iteye.com/blog/2011991 v2.0.4 Csql and datastax driver, example easycassandraserver
http://sillycat.iteye.com/blog/2011992 multinode Cluster, ccm
http://sillycat.iteye.com/blog/2213029
http://sillycat.iteye.com/blog/2170328 v2.1.2 and OpsCenter 5.0.2
http://sillycat.iteye.com/blog/2213025 cassandra sync issues
docker
https://hub.docker.com/_/cassandra/
https://github.com/docker-library/cassandra
cassandra client
https://docs.datastax.com/en/cql/3.1/cql/cql_using/start_cql_linux_t.html
https://docs.datastax.com/en/cassandra/3.x/cassandra/tools/toolsCUtility.html
http://stackoverflow.com/questions/29121904/cassandra-cqlsh-connection-refused
http://stackoverflow.com/questions/26892330/cassandra-datastax-enterprise-using-amazon-elastic-ip
https://github.com/docker-library/docs/tree/master/cassandra
1 Installation Cassandra
Exception:
Cassandra 3.0 and later require Java 8u40 or later.
Solution:
Install JDK8 with arm version there, I am using 32 bit.
> java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) Client VM (build 25.91-b14, mixed mode)
Exception:
bin/cqlsh localhost 9042
No appropriate python interpreter found.
Solution:
On my master machine on Local MAC OS
>python -V
Python 2.7.10
> java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Install latest cassandra on my master machine as well.
> wget http://mirror.cc.columbia.edu/pub/software/apache/cassandra/3.7/apache-cassandra-3.7-bin.tar.gz
> sudo ln -s /Users/carl/tool/apache-cassandra-3.7 /opt/cassandra-3.7
> sudo ln -s /opt/cassandra-3.7 /opt/cassandra
> cat ~/.profile
PATH="/opt/cassandra/bin:$PATH"
Exception:
Exception (org.apache.cassandra.exceptions.ConfigurationException) encountered during startup: If rpc_address is set to a wildcard address (0.0.0.0), then you must set broadcast_rpc_address to a value other than 0.0.0.0
If rpc_address is set to a wildcard address (0.0.0.0), then you must set broadcast_rpc_address to a value other than 0.0.0.0
ERROR 21:30:19 Exception encountered during startup: If rpc_address is set to a wildcard address (0.0.0.0), then you must set broadcast_rpc_address to a value other than 0.0.0.0
ERROR 22:15:18 Exception encountered during startup
java.lang.RuntimeException: Unable to gossip with any seeds
at org.apache.cassandra.gms.Gossiper.doShadowRound(Gossiper.java:1386) ~[apache-cassandra-3.7.jar:3.7]
at org.apache.cassandra.service.StorageService.checkForEndpointCollision(StorageService.java:561) ~[apache-cassandra-3.7.jar:3.7]
Solution:
I have an IP for docker container, one IP for the master machine. So the final configuration will be as follow:
Dockerfile
cat Dockerfile
#Set up Cassandra in Docker
#Prepre the OS
FROM resin/rpi-raspbian:jessie
MAINTAINER Carl Luo <luohuazju@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update
RUN apt-get -y dist-upgrade
#prepare env
RUN mkdir /tool/
ADD install/jdk-8u91-linux-arm32-vfp-hflt.tar.gz /tool/
RUN update-alternatives --install /usr/bin/java java /tool/jdk1.8.0_91/bin/java 1
#Install the application
WORKDIR /tool/
ADD install/apache-cassandra-3.7-bin.tar.gz /tool/
RUN mkdir /tool/apache-cassandra-3.7/logs
RUN mkdir /tool/apache-cassandra-3.7/data
ADD conf/cassandra.yaml /tool/apache-cassandra-3.7/conf/
#Start the Application
# 7000: intra-node communication
# 7001: TLS intra-node communication
# 7199: JMX
# 9042: CQL
# 9160: thrift service
EXPOSE 7000 7001 7199 9042 9160
RUN mkdir -p /app/
ADD start.sh /app/
WORKDIR /app
CMD [ "./start.sh" ]
Makefile
cat Makefile
IMAGE=sillycat/public
TAG=raspberrypi-cassandra
NAME=raspberrypi-cassandra
prepare:
wget http://apache.claz.org/cassandra/3.7/apache-cassandra-3.7-bin.tar.gz -P install/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-arm32-vfp-hflt.tar.gz" -P install/
mkdir logs
mkdir data
docker-context:
build: docker-context
# docker build --no-cache -t $(IMAGE):$(TAG) .
docker build -t $(IMAGE):$(TAG) .
run:
docker run -d -p 7000-7001:7000-7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 -v /opt/cassandra/data:/tool/apache-cassandra-3.7/data -v /opt/cassandra/logs:/tool/apache-cassandra-3.7/logs --name $(NAME) $(IMAGE):$(TAG)
debug:
docker run -ti -p 7000-7001:7000-7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 -v /opt/cassandra/data:/tool/apache-cassandra-3.7/data -v /opt/cassandra/logs:/tool/apache-cassandra-3.7/logs --name $(NAME) $(IMAGE):$(TAG) /bin/bash
clean:
docker stop ${NAME}
docker rm ${NAME}
logs:
docker logs ${NAME}
publish:
docker push ${IMAGE}:${TAG}
fetch:
docker pull ${IMAGE}:${TAG}
Some important part in cassandra.yaml
> cat conf/cassandra.yaml
seed_provider:
# Addresses of hosts that are deemed contact points.
# Cassandra nodes use this list of hosts to find each other and learn
# the topology of the ring. You must change this if you are running
# multiple nodes!
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
# seeds is actually a comma-delimited list of addresses.
# Ex: "<ip1>,<ip2>,<ip3>"
- seeds: "192.168.0.198"
listen_address: 172.17.0.3
broadcast_address: 192.168.0.198
rpc_address: 0.0.0.0
broadcast_rpc_address: 192.168.0.198
> cat start.sh
#!/bin/sh -ex
#start the cassandra
/tool/apache-cassandra-3.7/bin/cassandra -Dcassandra.config=file:///tool/apache-cassandra-3.7/conf/cassandra.yaml -R
It works
> cqlsh 192.168.0.198 9042
> cqlsh raspberrypi1 9042
one way to pass the parameters is -e in the command line in Makefile, then in start.sh, we can write the value to YAML file before we start the cassandra DB
>sed -ri 's/(- seeds:).*/\1 "'"$CASSANDRA_SEEDS"'"/' "$CASSANDRA_CONFIG/cassandra.yaml"
Issues with the disk, I guess there is some issues with that because of I am using an external USB driver.
ERROR 18:03:18 Fatal exception during initialization
org.apache.cassandra.exceptions.ConfigurationException: Found system keyspace files, but they couldn't be loaded!
at org.apache.cassandra.db.SystemKeyspace.checkHealth(SystemKeyspace.java:921) ~[apache-cassandra-3.7.jar:3.7]
at org.apache.cassandra.service.StartupChecks$9.execute(StartupChecks.java:325) ~[apache-cassandra-3.7.jar:3.7]
Finally, found that it may not be a good choice for me, because I want to store the data in USB driver. My main storage on raspberryPI is 8G sd card. I do not want to store my data on SD card.
It may relate to this one
http://www.tuxera.com/community/open-source-ntfs-3g/
Some other DB options
http://www.raspberrypiblog.com/2012/11/getting-started-with-databases-on-pi.html Sqlite3
https://github.com/orientechnologies/orientdb orientDB
References:
Cassandra 1 ~ 8
http://sillycat.iteye.com/blog/1870661 v1.2.4 installation and client check
http://sillycat.iteye.com/blog/2011524 source installation and hector java driver
http://sillycat.iteye.com/blog/2011525 hector scala implementation
http://sillycat.iteye.com/blog/2011526 kryo, convert Objects to bytes, bytes to Object
http://sillycat.iteye.com/blog/2011991 v2.0.4 Csql and datastax driver, example easycassandraserver
http://sillycat.iteye.com/blog/2011992 multinode Cluster, ccm
http://sillycat.iteye.com/blog/2213029
http://sillycat.iteye.com/blog/2170328 v2.1.2 and OpsCenter 5.0.2
http://sillycat.iteye.com/blog/2213025 cassandra sync issues
docker
https://hub.docker.com/_/cassandra/
https://github.com/docker-library/cassandra
cassandra client
https://docs.datastax.com/en/cql/3.1/cql/cql_using/start_cql_linux_t.html
https://docs.datastax.com/en/cassandra/3.x/cassandra/tools/toolsCUtility.html
http://stackoverflow.com/questions/29121904/cassandra-cqlsh-connection-refused
http://stackoverflow.com/questions/26892330/cassandra-datastax-enterprise-using-amazon-elastic-ip
https://github.com/docker-library/docs/tree/master/cassandra