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

Apache Cassandra 2019 Version in Docker

 
阅读更多
Apache Cassandra 2019 Version in Docker

I think the conf/cassandra.yaml should be from the sample
Important Makefile will be as follow:
IMAGE=sillycat/public
TAG=ubuntu-cassandra
NAME=ubuntu-cassandra
prepare:
    wget http://apache.osuosl.org/cassandra/3.11.4/apache-cassandra-3.11.4-bin.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 127.0.0.1:7000-7001:7000-7001 -p 127.0.0.1:7199:7199 -p 127.0.0.1:9042:9042 -p 127.0.0.1:9160:9160 -v $(shell pwd)/data:/tool/cassandra/data -v $(shell pwd)/logs:/tool/cassandra/logs --name $(NAME) $(IMAGE):$(TAG)
debug:
    docker run -ti -p 7000-7001:7000-7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 -v $(shell pwd)/data:/tool/cassandra/data -v $(shell pwd)/logs:/tool/cassandra/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}
The start.sh will detect the IP for running machine.
#!/bin/sh -ex
#prepare config
INTERNAL_IP="$(hostname --ip-address)"
sed -ri 's/(listen_address:).*/\1 "'"$INTERNAL_IP"'"/' "/tool/cassandra/conf/cassandra.yaml"

#start the cassandra
/tool/cassandra/bin/cassandra -Dcassandra.config=file:///tool/cassandra/conf/cassandra.yaml -R -f
tail -f /tool/cassandra/logs/debug.log
Here is the Dockerfile shows all the steps
#Set up Cassandra in Docker
#Prepare the OS
FROM            ubuntu:16.04
MAINTAINER      Rachel Kang <yiyikangrachel@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
ENV JAVA_HOME       /usr/lib/jvm/java-8-oracle
ENV LANG            en_US.UTF-8
ENV LC_ALL          en_US.UTF-8
RUN apt-get -qq update
RUN apt-get -qqy dist-upgrade
#Prepare the denpendencies
RUN apt-get install -qy wget unzip vim
RUN apt-get install -qy iputils-ping
#Install SUN JAVA
RUN apt-get update && \
  apt-get install -y --no-install-recommends locales && \
  locale-gen en_US.UTF-8 && \
  apt-get dist-upgrade -y && \
  apt-get --purge remove openjdk* && \
  echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections && \
  echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" > /etc/apt/sources.list.d/webupd8team-java-trusty.list && \
  apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886 && \
  apt-get update && \
  apt-get install -y --no-install-recommends oracle-java8-installer oracle-java8-set-default && \
  apt-get clean all
#Install the application
WORKDIR     /tool/
ADD            install/apache-cassandra-3.11.4-bin.tar.gz /tool/
RUN            ln -s /tool/apache-cassandra-3.11.4 /tool/cassandra
RUN         mkdir /tool/cassandra/logs
RUN         mkdir /tool/cassandra/data
ADD         conf/cassandra.yaml /tool/cassandra/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” ]

Put the command tool in class path
sudo ln -s /Users/hluo/tool/apache-cassandra-3.11.4 /opt/cassandra-3.11.4
Check Version
> cqlsh --version
cqlsh 5.0.1
Connect to localhost
> cqlsh localhost 9042
Verify with an easy sample
Create Database
cqlsh> create keyspace mykeyspace with replication = { 'class': 'SimpleStrategy', 'replication_factor':1};
cqlsh> use mykeyspace;
Create Table
> cqlsh:mykeyspace> create table users ( user_id int primary key, firstname text, lastname text );
Insert Some Data
cqlsh:mykeyspace> insert into users(user_id, firstname, lastname) values (1,'carl','luo');
cqlsh:mykeyspace> insert into users(user_id, firstname, lastname) values (2,'ray','luo');
cqlsh:mykeyspace> insert into users(user_id, firstname, lastname) values (3,'kiko','kang');
Search
select * from users;
user_id | firstname | lastname
---------+-----------+----------
       1 |      carl |      luo
       2 |       ray |      luo
       3 |      kiko |     kang
Create Index
cqlsh:mykeyspace> create index on users (lastname);
Search on Index
select * from users where lastname = 'luo';
user_id | firstname | lastname
---------+-----------+----------
       1 |      carl |      luo
       2 |       ray |      luo
Search with primary key
select * from users where user_id = 1;
user_id | firstname | lastname
---------+-----------+----------
       1 |      carl |      luo

References:
http://cassandra.apache.org/download/


分享到:
评论

相关推荐

    Spring Data for Apache Cassandra API(Spring Data for Apache Cassandra 开发文档).CHM

    Spring Data for Apache Cassandra API。 Spring Data for Apache Cassandra 开发文档

    Mastering Apache Cassandra

    ### Apache Cassandra 掌控指南 #### 一、引言 在大数据时代,高效的数据存储与管理变得至关重要。《Mastering Apache Cassandra》这本书旨在帮助读者掌握 Apache Cassandra 的核心技术和最佳实践,使其能够在处理...

    Mastering.Apache.Cassandra.2nd.Edition.1784392618

    Title: Mastering Apache Cassandra, 2nd Edition Author: Nishant Neeraj Length: 322 pages Edition: 2 Language: English Publisher: Packt Publishing Publication Date: 2015-02-27 ISBN-10: 1784392618 ISBN-...

    Beginning Apache Cassandra Development

    In Beginning Apache Cassandra Development, author and Cassandra expert Vivek Mishra takes you through using Apache Cassandra from each of these primary languages. Mishra also covers the Cassandra ...

    Learning Apache Cassandra 2015

    ### 学习Apache Cassandra 2015:深入理解NoSQL数据库系统 #### 一、了解Apache Cassandra及其特性 **Apache Cassandra**是一款分布式NoSQL数据库系统,由Facebook开发并在2008年作为开源项目发布。它以Amazon的...

    Learning_Apache_Cassandra

    在本文档中,标题“Learning_Apache_Cassandra”透露了内容的主题,即学习Apache Cassandra。Cassandra是一个开源的NoSQL分布式数据库管理系统,它以高可用性和分布式架构著称。该书详细介绍了Cassandra的基本概念、...

    Expert Apache Cassandra Administration.pdf

    Apache Cassandra是一个分布式的NoSQL数据库管理系统,它被设计用来处理大量的数据跨越多个数据中心。Cassandra对高性能、高可用性、可扩展性有着出色的支持,因此它特别适合于那些需要不断增长和变化的数据集的应用...

    Learning Apache Cassandra - Second Edition

    Learning Apache Cassandra - Second Edition by Sandeep Yarabarla English | 25 Apr. 2017 | ASIN: B01N52R0B5 | 360 Pages | AZW3 | 10.68 MB Key Features Install Cassandra and set up multi-node clusters ...

    NoSQL Web Development with Apache Cassandra(2015)

    Apache Cassandra is the most commonly used NoSQL database written in Java and is renowned in the industry as the only NoSQL solution that can accommodate the complex requirements of today’s modern ...

    docker-cassandra-cluster:使用docker的Cassandra的基本集群脚本

    docker-cassandra-群集使用docker的Cassandra的基本集群脚本。 尽管您可以将其启动到docker-machine集群上,但这是为本地开发而设计的。 如果您确实踏上了那趟旅程,请特别注意compose yaml中的端口规格。 它可能...

    docker-cassandra, 在 Docker的快速启动中,Cassandra.zip

    docker-cassandra, 在 Docker的快速启动中,Cassandra Docker 中的Cassandra这个库提供了在 Docker 中运行Cassandra所需的一切,并为快速的容器启动而调整。为什么?虽然天真的Cassandra图像大约需要 30秒的时间,...

    Cassandra(apache-cassandra-3.11.11-bin.tar.gz)

    Cassandra(apache-cassandra-3.11.11-bin.tar.gz)是一套开源分布式NoSQL数据库系统。它最初由Facebook开发,用于储存收件箱等简单格式数据,集GoogleBigTable的数据模型与Amazon Dynamo的完全分布式的架构于一身...

    Apache Cassandra

    Apache Cassandra是一个开源的分布式NoSQL数据库管理系统,它最初由Facebook开发,并在2008年被捐献给了Apache软件基金会。Cassandra旨在解决大规模数据存储的问题,特别适用于那些需要高性能、可伸缩性以及高可用性...

    apache-cassandra-3.11.13

    Apache Cassandra 是一个分布式数据库系统,特别设计用于处理大规模数据,具备高可用性、线性可扩展性和优秀的性能。在这个"apache-cassandra-3.11.13"版本中,我们探讨的是Cassandra项目的其中一个稳定版本,它包含...

    Mastering Apache Cassandra(PACKT,2013)

    Apache Cassandra is the perfect choice for building fault tolerant and scalable databases. Implementing Cassandra will enable you to take advantage of its features which include replication of data ...

Global site tag (gtag.js) - Google Analytics