docker session 7.2 bdc - copy
Post on 17-Jan-2017
26 Views
Preview:
TRANSCRIPT
Use this title slide only with an image
Part 9 BDC Cassandra dBDawood Sayyed/GLDS June 21st , 2016 Internal
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 2Internal
Few questions before we start
What is fixed schema and Dynamic schema?
What is SQL dB ?
What is NoSQL dB ?
Any advantages of No SQL dB over SQL dB ?
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 3Internal
SQL vs NoSQL
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 4Internal
Apache Cassandra
Apache Cassandra is a wide-column, open source most commonly used NoSQL database . The container of data, equivalent to a database schema in a relational database, in Apache Cassandra is a Keyspace.
The basic unit of storage is a column family (also called table), and each record in a table is stored in a row with the data being stored in columns. A column has a name, a value, and a timestamp associated with it. A column is not required to store a value and the column could be empty.
Apache Cassandra is based on a flexible schema (or schema-free or dynamic schema) data model in which different rows could have different columns and the columns are not required to be pre-specified in a table definition. Apache Cassandra supports data types for column names (called comparators) and column values (called validators), but does not require the data types (validators and comparators) to be specified.
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 5Internal
Apache Casandra
The validators and comparators may be added or modified after a table (column family) has been defined.
Apache Cassandra provides a Cassandra Query Language (CQL) for CRUD (add, get, update, delete)operations on a table.
Apache Cassandra installation includes a cqlsh utility, which is an interactive shell , from which CQL commands may be run.
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 6Internal
Graphical of Apache Cassandra
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 7Internal
Setting Environment for Apache Casandra
Starting Apache Cassandra
Starting the TTY
Connecting to CQL Shell
Creating a Keyspace
Altering A Keyspace
Using A Keyspace
Creating a Table
Adding Table Data
Querying a Table
Deleting from a Table
Truncating a Table
Dropping A Table
Dropping a Keyspace
Exiting CQLSh
Stopping Apache Cassandra
Starting Multiple Instances of Apache Cassandra
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 8Internal
Commands
sudo docker pull cassandra:latest
sudo docker images
docker run --name some-cassandra -d cassandra:tag
Start the Apache Cassandra server process in a Docker container with the following command in which the inter-node Apache Cassandra cluster communication port is specified as 7000 and the directory in which Apache Cassandra stores data is /cassandra/data. The container name is specified with the –name option as cassandradb
sudo docker run -t -i -v /cassandra/data:/var/lib/cassandra/data --name cassandradb -d –p 7000:7000 Cassandra
sudo docker ps
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 9Internal
Commands for TTY and connecting to CQL shell
sudo docker exec -it cassandradb bash
cqlsh
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 10Internal
Creating a Keyspace Apache Cassandra
A Keyspace is the container of application data and is used to group column families. Replication is set at a per-keyspace basis. The DDL command for creating a Keyspace is as follows.
CREATE KEYSPACE (IF NOT EXISTS)? <identifier> WITH <properties>
Case-insensitive and may consist exclusively of alpha-numeric characters with a maximum length of 32. To make a keyspace name case-sensitive add quotes.
The supported properties by the CREATE KEYSPACE statement, which creates a top-level keyspace, are replication for specifying the replication strategy and options and durable_writes for whether a commit log is to be used for updates on the keyspace, with the replication property being mandatory.
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 11Internal
Creating a Keyspace Apache Cassandra
CREATE KEYSPACE (IF NOT EXISTS)? <identifier> WITH <properties>
As an example, create a keyspace called CatalogKeyspace with replication strategy class as SimpleStrategy and replication factor as 3.
CREATE KEYSPACE CatalogKeyspace
WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 12Internal
Stopping Apache Cassandra
To stop Apache Cassandra, stop the Docker container running the Apache Cassandra server.
sudo docker stop cassandradb
Subsequently, run the following command to list the running containers.
sudo docker ps
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 13Internal
Multiple Docker Containers for Instances of Apache Cassandra
sudo docker run -t -i -v /cassandra/data:/var/lib/cassandra/data --name cassandradb -d -p
7000:7000 Cassandra
sudo docker run -t -i -v /cassandra/data:/var/lib/cassandra/data --name cassandradb2 -d -p
7000:7000 Cassandra
sudo docker run -t -i -v /cassandra/data:/var/lib/cassandra/data --name cassandradb3 -d -p
7000:7000 -e CASSANDRA_SEEDS=52.91.214.50,54.86.243.122,54.86.205.95 Cassandra
Start a third container and specify the CASSANDRA_SEEDS environment variable for the IP address/es to be used to run multiple nodes in the cluster if required.
top related