`
sillycat
  • 浏览: 2539141 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Play Raspberry Pi(8)Cassandra in Docker

 
阅读更多
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
分享到:
评论

相关推荐

    Raspberry Pi 4 Beginner’s Guide.pdf

    In our opinion, you will certainly adore the Raspberry Pi 4. Ultra-small, affordable, even cheaper than most video games, you can use the Pi to build robots, learn coding and create all sorts of...

    Raspberry Pi Zero Cookbook

    In his spare time, he is an Internet of Things enthusiast and has spoken on the wonders of the Raspberry Pi at conferences and user groups. He loves his Raspberry Pis. He has also built his own 3D ...

    Wiley Learning Python with Raspberry Pi 2014

    《Wiley Learning Python with Raspberry Pi 2014》是一本专为初学者设计的教程,旨在引导读者通过树莓派这一小型计算机平台学习Python编程。这本书由2014年出版,当时Python已是编程界的热门语言,而树莓派因其低...

    rpi-hubot-docker-template:Raspberry Pi上的Hubot Docker容器模板

    rpi-hubot-docker-template Raspberry Pi上的Hubot Docker容器模板如何在Raspberry Pi上使用Docker 上安装。 请参阅以设置环境。用法克隆此仓库 $ git clone https://github.com/knjcode/rpi-hubot-docker-template$...

    Adventures in Raspberry Pi (3rd edition).pdf

    《Raspberry Pi探险记(第三版)》是由Carrie Anne Philbin撰写,首次出版于2017年,并由John Wiley & Sons, Inc.出版。这本书旨在向读者介绍Raspberry Pi——一种由Raspberry Pi基金会推出的低成本、信用卡大小的...

    Raspberry Pi快速入门指南-奥松

    《Raspberry Pi快速入门指南》是一本面向初学者的实用手册,由Maik Schmidt撰写,国内译者王峰、王江伟、王汝波共同翻译。该书为读者详细介绍了Raspberry Pi这一款迷你Linux计算机的使用方法,并指导用户如何通过...

    Raspberry Pi LED Blueprints(PACKT,2015)

    Blinking LED is a popular ... a digital clock, a traffic light controller, a remote light controller, and an LED-based Internet of Things, so you get more practice in the art of Raspberry Pi development.

    Getting Started with Raspberry Pi Zero.pdf

    Raspberry Pi Zero is half the size of Raspberry Pi A, only with twice the utility. At just three centimeters wide, it packs in every utility required for full-fledged computing tasks. This practical ...

    raspberrypi-rstudio:用于Raspberry Pi的RStudio-Docker构建和运行时环境

    raspberrypi-rstudio:用于Raspberry Pi的RStudio-Docker构建和运行时环境

    Raspberry Pi Cookbook.pdf

    The world of Raspberry Pi is evolving quickly, with many new interface boards and software libraries becoming available all the time. In this cookbook, prolific hacker and author Simon Monk provides ...

    Raspberry.Pi.Home.Automation.with.Arduino.2nd.Edition.178439

    Any experience in using the Raspberry Pi would be an added advantage. In Detail Revolutionize the way you interact with your home and become part of the rapidly growing group of hobbyists and ...

    Raspberry.Pi.Computer.Architecture.Essentials.17843

    In this book, we explore Raspberry Pi 2's hardware through a number of projects in a variety of programming languages. We will start by exploring the various hardware components in detail, which will ...

    基于RaspberryPi实现的智能家居.docx

    ### 基于Raspberry Pi实现的智能家居 #### 1.1 课题背景与意义 随着信息技术的发展,智能家居成为越来越多人关注的焦点。本课题旨在探索利用Raspberry Pi这一低成本且功能强大的微型计算机来实现智能家居控制系统...

    linux-为RaspberryPi3B构建ChromiumOS

    在Linux世界中,Raspberry Pi是一款非常受欢迎的微型计算机,常用于各种DIY项目和教育用途。Chromium OS,作为Google Chrome OS的基础源代码,是一个轻量级的操作系统,主要设计用于快速启动和运行网络应用。本文将...

    docker-raspberrypi-4B.zip

    docker-arm_20.10.6 资源

    Raspberry Pi

    CHAPTER 1: INTRODUCTION TO RASPBERRY PI THE EVOLUTION OF RASPBERRY PI 2 THE UNIQUE FEATURES: MODEL A MODEL A+ MODEL B MODEL B+ SHOULD YOU BUY THE LATEST RASPBERRY PI 2, IF YOU HAVE PREVIOUS MODELS? ...

Global site tag (gtag.js) - Google Analytics