datastax docker docs · dse cluster per docker host. if running multiple datastax containers on a...

49
DataStax Docker Docs Updated: 2018-12-07-08:00

Upload: vutruc

Post on 04-Jan-2019

272 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Docker Docs

Updated: 2018-12-07-08:00

Page 2: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

© 2018 DataStax, Inc. All rights reserved. DataStax, Titan, and TitanDB are registered trademark of DataStax,Inc. and its subsidiaries in the United States and/or other countries.

Apache Cassandra, Apache, Tomcat, Lucene, Solr, Hadoop, Spark,TinkerPop, and Cassandra are trademarks of the Apache Software Foundation

or its subsidiaries in Canada, the United States and/or other countries.

Page 3: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Docker Docs

Table of Contents

Contact DataStax......................................................................................................................6

Quick Start Guide..................................................................................................................... 7

DSE recommended settings for Docker...................................................................................8

DataStax Docker PDF............................................................................................................ 13

DataStax 6.7 Docker Guide................................................................................................... 14

Getting started with DataStax and Docker......................................................................14

Prerequisites.................................................................................................................... 14

Creating and starting Docker containers.........................................................................14

Creating a DataStax Enterprise container............................................................... 14

Creating an OpsCenter container............................................................................ 15

Creating a Studio container..................................................................................... 16

Docker run options...................................................................................................17

Managing the configuration............................................................................................. 17

Using the DSE configuration volume....................................................................... 18

Using environment variables....................................................................................18

Persisting data..........................................................................................................20

Exposing public ports...............................................................................................21

Volumes and data directories.................................................................................. 21

Attaching to a container and opening a command line...................................................22

Using Docker compose for automated provisioning........................................................22

Building custom Docker images......................................................................................24

Getting help with Docker.................................................................................................24

Docker known issues...................................................................................................... 24

Licensing terms............................................................................................................... 24

DataStax 6.0 Docker Guide................................................................................................... 26

Getting started with DataStax and Docker......................................................................26

Prerequisites.................................................................................................................... 26

Page 4: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Docker Docs

Creating and starting Docker containers.........................................................................26

Creating a DataStax Enterprise container............................................................... 26

Creating an OpsCenter container............................................................................ 27

Creating a Studio container..................................................................................... 28

Docker run options...................................................................................................29

Managing the configuration............................................................................................. 29

Using the DSE configuration volume....................................................................... 30

Using environment variables....................................................................................30

Persisting data..........................................................................................................32

Exposing public ports...............................................................................................33

Volumes and data directories.................................................................................. 33

Attaching to a container and opening a command line...................................................34

Using Docker compose for automated provisioning........................................................34

Building custom Docker images......................................................................................36

Getting help with Docker.................................................................................................36

Docker known issues...................................................................................................... 36

Licensing terms............................................................................................................... 36

DataStax 5.1 Docker Guide................................................................................................... 38

Getting started with DataStax and Docker......................................................................38

Prerequisites.................................................................................................................... 38

Creating and starting Docker containers.........................................................................38

Creating a DataStax Enterprise container............................................................... 38

Creating an OpsCenter container............................................................................ 39

Creating a Studio container..................................................................................... 40

Docker run options...................................................................................................40

Managing the configuration............................................................................................. 41

Using the DSE configuration volume....................................................................... 41

Using environment variables....................................................................................42

Page 5: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Docker Docs

Persisting data..........................................................................................................43

Exposing public ports...............................................................................................44

Volumes and data directories.................................................................................. 45

Attaching to a container and opening a command line...................................................45

Using Docker compose for automated provisioning........................................................46

Building custom Docker images......................................................................................47

Getting help with Docker.................................................................................................48

Docker known issues...................................................................................................... 48

Licensing terms............................................................................................................... 48

DataStax Docker Images........................................................................................................49

Page 6: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

Contact DataStax

Contact DataStaxWant more information about DataStax Enterprise? Click the following link and complete theform to learn more about the always-on, distributed cloud database that is designed for hybridcloud.

I want more information about DataStax Enterprise.

Page 6 DataStax Docker Docs

Page 7: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Enterprise on Docker Quick Start

DataStax Enterprise on Docker Quick StartUse DataStax-provided Docker images to create containers for production and non-productionenvironments.

Prerequisites

1. Download and install Docker from the Docker website.

2. Download the DataStax Docker images from Docker Hub.

Quick start examples

Create a DSE database container

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server

Create a DSE container with Analytics, Search, and Graph enabled

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server -k -s -g

Create a DSE OpsCenter container

$ docker run -e DS_LICENSE=accept -p 8888:8888 --name my-opscenter -d datastax/dse-opscenter

Create a DataStax Studio container

$ docker run -e DS_LICENSE=accept --name my-studio -p 9091:9091 -d datastax/dse-studio --link my-dse

Learn more

Use the following links to get more information beyond these examples.

• Contact us to learn more about DSE by completing this form.• Get sample Docker Compose scripts from the DataStax Docker repository on Github.• Go further by learning about managing the container configuration (page 29), including

working with environment variables, configuration management, and persisting data.• Ask questions in the DataStax Slack channel to get help from experts.• Report issues on Github to help improve the experience with DataStax Docker containers.

DataStax Docker Docs Page 7

Page 8: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Enterprise recommended settings for Docker

DataStax Enterprise recommended settings forDockerTo ensure your success when using Docker, follow the recommended guidance and settingsfor using DataStax Enterprise (DSE) with Docker.

Important: Although DataStax provides the following guidance, adaptations ofthese instructions might be necessary depending on the deployment. It is highlyrecommended to rigorously test the use cases under consideration before deploying aDSE installation on Docker in production environments.

General guidance

DSE achieves resilience and high availability through a cluster of nodes that replicate dataacross the cluster. This replication ensures that if any individual node fails, access to data isnot lost and performance is maintained. However, in a containerized environment, runningmultiple DSE nodes on the same physical hardware will introduce a single point of failure.

Important: To avoid a single point of failure, run only a single DataStax container on aDSE cluster per Docker host. If running multiple DataStax containers on a single Dockerhost, ensure that the containers are in different DSE clusters.

Software versionsDataStax Agent versions

The official DSE images include the latest Datastax Agent version at the time of official imagebuild. If you require a version of the Datastax Agent that differs from the one included with theofficial image, you must build an image (page 8) that includes the required versions.

Using specific DSE versions

The DSE version using the tag latest changes with each release. DataStax recommendsusing a specific DSE version in the docker run command to avoid mixing DSE versions.

For example, use the following command to use DSE 6.01:

$ docker run datastax/dse-server:6.0.1

Building images

To build an image, clone the DataStax Docker Github repository, make any necessarychanges (such as versions), and follow the instructions in the repository for building the imageusing Gradle.

Hardware settingsDocker container resource requirements

Page 8 DataStax Docker Docs

Page 9: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Enterprise recommended settings for Docker

For minimum container resource requirements, follow the guidance in Selecting hardware forDataStax Enterprise implementations for production environments.

Optimizing SSDs

The default SSD configurations on most Linux distributions are not optimal. See OptimizingSSDs to ensure the most optimal SSD settings.

Optimizing settings for RAID on SSD

The optimum readahead setting for RAID on SSDs (in Amazon EC2) is 8 KB, the same as it isfor non-RAID SSDs. For details, see Optimizing SSDs.

Optimizing RAID settings for spinning disks on the host

Typically, a readahead of 128 is recommended.

Check to ensure setra is not set to 65536:

$ sudo blockdev --report /dev/spinning_disk

To set setra:

$ sudo blockdev --setra 128 /dev/spinning_disk

Note: The recommended setting for RAID on SSDs is the same as that for SSDs thatare not being used in a RAID installation. For details, see Optimizing SSDs.

System settingsSynchronizing clocks

Because time is not namespaced in the Linux kernel, containers share the clock with theDocker host machine. Ensure that clocks are synchronized on the host machines andcontainers by configuring NTP or other methods on the host machines.

Disabling swap

Swapping must be disabled for performance and node stability. Run the following command onthe Docker host to disable swap. The Docker host passes this setting to the container.

See Disabling swap for more information.

$ sudo swapoff --all

• To disable swap per container, see Preventing a container from using SWAP in theDocker documentation.

• To make this change permanent, remove all swap file entries from /etc/fstab.

Disabling CPU frequency sequencing on the Docker host

DataStax Docker Docs Page 9

Page 10: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Enterprise recommended settings for Docker

To ensure optimal performance, do not use governors that lower the CPU frequency. Instead,reconfigure all CPUs to use the performance governor on the Docker hosts.

See Disabling CPU frequency scaling.

for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governordo [ -f $CPUFREQ ] || continue echo -n performance > $CPUFREQdone

Disabling THP on the Docker host

THP can cause performance issues in DSE when it defragments 4 K chunks into 2 MB chunks.To disable defrag run the following command on the Docker host:

$ echo never | sudo tee /sys/kernel/mm/transparent_hugepage/defrag

See Checking the Linux Hugepage settings.

Increasing user resource limits

All containers by default inherit user limits from the Docker daemon. In productionenvironments, DSE expects the following changes to ulimit:

ulimit -n 100000 # nofile: max number of open filesulimit -l unlimited # memlock: maximum locked-in-memory address space

1. Run the following command to check the Docker daemon defaults for ulimits:

$ docker run --rm ubuntu /bin/bash -c 'ulimit -a'

2. To set ulimit for Docker containers, run the docker run command with the followingulimit options:

$ --ulimit nofile=100000:100000 --ulimit nproc=32768 --ulimit memlock=-1:-1

DSE tries to lock memory using mlock. When running in Docker, that capability is disabled. Toenable mlock, add the following option to the docker run command:

$ --cap-add=IPC_LOCK

On the Docker host, check the value of vm.max_map_count, which should be set to 1048575.

$ cat /proc/sys/vm/max_map_count

Page 10 DataStax Docker Docs

Page 11: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Enterprise recommended settings for Docker

To set the value of vm.max_map_count, add the following line to /etc/sysctl.conf, andthen run sysctl -p to propagate the changes.

$ vi /etc/sysctl.conf

$ vm.max_map_count = 1048575

$ sudo sysctl -p

See Setting user resource limits.

Configuring heap settings

For each container in production environments, explicitly set the JVM heap size using theJVM_EXTRA_OPTS environment variable with the docker run command.

For example, to use 16 GB for the JVM heap, run the docker run command with the followingoption:

$ docker run -e JVM_EXTRA_OPTS="-Xms16g -Xmx16g"

Storage and resource requirementsMounting configuration volumes

For advanced configuration management, DataStax provides a mechanism for modifyingconfigurations without replacing or customizing DataStax Docker containers. When any of theapproved configuration files are mounted to a host volume, the files are mapped automaticallywithin the container. See Using the DSE configuration volume (page 30).

Mapping node data to a local folder on the host

The DSE Docker container writes all node-specific data in the directories under /var/lib/cassandra/ by default. To persist this data, map the data directories inside the container toa directory on the host file system using the -v option with the docker run command, or byusing a volume driver.

For example, to mount the DSE data volume to the /dse/data directory on the Docker host,run the docker run command with the following option:

$ docker run -v /dse/data:/var/lib/cassandra

Hosting the /var/lib/cassandra directory outside the container with the -v option allowsthe container to be deleted and recreated without losing data. See Persisting data (page32).

Configuring storage drivers

If using the Docker devicemapper storage driver, do not use the default loop-lvm mode,which is only appropriate for testing. Instead, configure docker-engine to use direct-lvmmode, which is suitable for production environments.

DataStax Docker Docs Page 11

Page 12: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Enterprise recommended settings for Docker

Network considerationsConfiguring network settings

Because the default network settings in Docker (via Linux bridge) slows networkingconsiderably, do not use these network settings in production environments. Instead, usedocker host networking by adding the --network host option to the docker run command, oruse a plugin that can manage IP ranges across clusters of hosts. The host networking limitsthe number of DSE nodes per Docker host to one, which is the recommended configuration touse in production.

$ docker run -d --network host --name container_name

Configuring ports

DSE communicates on many different ports. Account for these ports when binding ports to theDocker host.

Page 12 DataStax Docker Docs

Page 13: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Docker PDF

DataStax Docker PDFDownload the documentation for DataStax Docker containers in PDF format.

DataStax Docker Docs Page 13

Page 14: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

DataStax 6.7 Docker Guide

Use DataStax Docker images to create DataStax Enterprise (DSE) server, DSE OpsCenter,and DataStax Studio containers in production and non-production environments.

Getting started with DataStax and DockerUse DataStax-provided Docker images to create containers in production and non-productionenvironments for development, learn DataStax Enterprise (DSE), DataStax OpsCenter,and DataStax Studio, try new ideas, and test and demonstrate an application. The followingimages are available:

• DataStax Enterprise: The best distribution of Apache Cassandra™ with integratedSearch, Analytics, and Graph, and Advanced Security capabilities.

• DataStax Studio: An interactive developer’s tool for DataStax Enterprise which isdesigned to help your DSE database, Cassandra Query Language (CQL), DSE Graph,and Gremlin Query Language development.

• DSE OpsCenter: The web-based visual management and monitoring solution for DSE.

PrerequisitesTo use the Docker images, ensure the following requirements are met:

• Basic understanding of Docker images and containers.• Docker installed on your local system.• DataStax Academy account, if building custom images (page 24) from the DataStax

Github repository.

Creating and starting Docker containersUse the following information to create DataStax Enterprise (DSE) server, DSE OpsCenter,and DataStax Studio containers in production and non-production environments.

Creating a DataStax Enterprise container

Create a DataStax Enterprise (DSE) server container. For a list of the most commonly usedoptions, see Docker run options (page 17).

See the docker run command reference for a full list of options.

Enabling advanced functionality

By default, the DSE server image is configured as a transactional (database) node. Toconfigure the node with DSE advanced functionality, add the corresponding option thatenables the intended feature to the end of the docker run command.

Page 14 DataStax Docker Docs

Page 15: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

Combine startup options to run more than one feature.

Option Description

-g Enable and start DSE Graph.

-k Enable and start DSE Analytics.

-s Enable and start DSE Search.

Examples

Create a DSE database container

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server

Create a DSE container with Graph enabled

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server -g

Create a DSE container with Analytics (Spark) enabled

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server -k

Create a DSE container with Search enabled

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server -s

Creating an OpsCenter container

Create a DataStax Enterprise OpsCenter container and a connected DSE server containeron the same Docker host. For a list of the most commonly used options, see Docker runoptions (page 17).

See the docker run command reference for a full list of options.

1. Create an OpsCenter container.

$ docker run \-e DS_LICENSE=accept \-p 8888:8888 \--name my-opscenter \-d datastax/dse-opscenter

2. Create a DSE server container that is linked to the OpsCenter container.

$ docker run \

DataStax Docker Docs Page 15

Page 16: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

-e DS_LICENSE=accept \--link my-opscenter:opscenter \--name my-dse \-d datastax/dse-server

3. Get the DSE container IP address.

$ docker exec -it my-dse nodetool status

4. Open a browser and navigate to http://DSE_container_IP:8888, whereDSE_container_IP is the IP address of the DSE container.

a. Click Manage existing cluster.

b. Enter the DSE container IP address in the host name field.

c. Click Install agents manually. The agent is already installed on the DSE image,so no installation is required.

OpsCenter is ready to use with DSE.

What's next: See the OpsCenter User Guide for detailed usage and configurationinstructions.

Creating a Studio container

Create a DataStax Studio container. For a list of the most commonly used options, seeDocker run options (page 17).

See the docker run command reference for a full list of options.

1. Create a Studio container, using my-dse as the hostname.

$ docker run -e DS_LICENSE=accept \-p 9091:9091 \--link my-dse \--name my-studio \-d datastax/dse-studio

2. Open a browser and navigate to http://container_IP:9091, where container_IP isthe IP address of the container.

Studio is ready to use with DSE.

What's next:

Page 16 DataStax Docker Docs

Page 17: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

See the DataStax Studio documentation for detailed usage and configuration instructions.

Docker run options

The following options are the most commonly used when creating a DataStax container.

Option Description

-e Sets environment variables (page 18) to accept the licensingagreement and change the initial configuration. Required.

-d Starts the container in the background. Recommended.

-p Publish container ports on the host to allow remote access to DSE,OpsCenter, and Studio. See exposing public ports (page 21) for moreinformation.

-v Bind mount a directory on the local host to a DSE Volume to manageconfiguration or preserve data. See using exposed volumes (page 18)for more information.

--link Link a DSE container to OpsCenter, or Studio to DSE. For example, --link my-opscenter:opscenter or --link my-dse.

--name Assign a name to the container.

Managing the configurationManage the DataStax Enterprise (DSE) configuration using one of the following options:

• The DSE configuration volume (page 18) to get configuration files from a mountedhost directory without replacing or customizing configuration file in the container.

• Environment variables (page 18) to change the configuration at runtime.

• Docker file or directory volume mounts.

• Docker overlay file system.

DataStax Docker Docs Page 17

Page 18: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

Note: DSE uses the default values defined for the environment variables unlessexplicitly set at runtime. Custom configuration files will override the default or explicitlyset environment variables.

Using the DSE configuration volume

Docker images provided by DataStax include a startup script that swaps DataStaxEnterprise (DSE) configuration files found in the /config volume directory with theconfiguration file in the default location on the container.

1. Create a directory on your local host to store the configuration files.

2. Add the configuration files to replace in the container. The file name must match acorresponding configuration file in the image and include all required values. Forexample cassandra.yaml, dse.yaml, opscenterd.conf.

See the following Github pages for a full list of configuration files.

• DSE

• OpsCenter

• Studio

3. Mount the local directory to the exposed /config directory during startup, as shown inthe following example:

$ docker run -v /dse/conf:/config

4. Start the container. The following example illustrates starting a transactional node:

$ docker run -e DS_LICENSE=accept \--name my-dse \-v /dse/config:/config datastax/dse-server \-d datastax/dse-server

Using environment variables

Configure the DataStax Enterprise (DSE) Docker image by setting environment variableswhen the container is created. Use the docker run command -e option.

Page 18 DataStax Docker Docs

Page 19: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

Table 1: Environment variables

Variable Setting Description

DS_LICENSE accept Acknowledge agreement with the terms of theDataStax license. To show the license, set thevariable DS_LICENSE to the value accept.

Important: The image only starts if thisvariable is set to accept.

LISTEN_ADDRESS IP_address IP address to listen for connections from othernodes. Defaults to the container IP address.

BROADCAST_ADDRESS IP_address IP address to advertise to other nodes. Defaultsto the same value as LISTEN_ADDRESS.

NATIVE_TRANSPORT_ADDRESSIP_address IP address to list for client and driverconnections. Default: 0.0.0.0.

NATIVE_TRANSPORT_BROADCAST_ADDRESSIP_address IP address to advertise to clients anddrivers. Defaults to the same value asBROADCAST_ADDRESS.

SEEDS IP_address Comma-delimited list of seed nodesfor the cluster. Defaults to the nodeBROADCAST_ADDRESS.

START_NATIVE_TRANSPORTtrue | false Determines whether to start the Thrift RPCserver. If not set, the default value is preservedin the cassandra.yaml file.

CLUSTER_NAME string Name of the cluster. Default: Test Cluster.

NUM_TOKENS int Number of tokens randomly assigned to thenode. Default: 8.

DC string Datacenter name. Default: Cassandra.

RACK string Rack name. Default: rack1.

OPSCENTER_IP IP_address | string Address of the OpsCenter instance to use forDSE management. The value can be specifiedby linking the OpsCenter container usingopscenter as the name.

JVM_EXTRA_OPTS string Sets a custom value for the JVM heap using -Xmx and -Xms.

LANG string Sets a custom locale.

DataStax Docker Docs Page 19

Page 20: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

Variable Setting Description

SNITCH string Sets the snitch implementation this node willuse. The value is set in the endpoint_snitchparameter in cassandra.yaml.

Persisting data

To persist data, create directories on the local host and map the directory to thecorresponding volume using the docker run command with the -v option. For example:

$ docker run -v local_directory:container_volume

Warning: If the volumes are not mounted from the local host, all data is lost when thecontainer is removed.

DataStax exposes data volumes to preserve data. See volumes and data directories (page21) for a list of exposed volumes.

1. Create a directory on the Docker host.

2. Bind mount the local directory to the configuration file that will be persisted by starting thecontainer with the -v option.

For example, the following command mounts the opscenter.conf file.

$ docker run -e DS_LICENSE=accept \-v /dse/data/opscenter:/opt/opscenter/conf/opscenterd.conf \--name my-opscenter \-d datastax/dse-opscenter

Mounting a DSE configuration volume

Mount the host directory /dse/config to the DSE volume /config to manageconfiguration files.

$ docker run -e DS_LICENSE=accept \--name my-dse \-v /dse/conf:/config datastax/dse-server \-d datastax/dse-server

Mounting an OpsCenter configuration volume

Mount the local directory to the exposed volume /var/lib/opscenter by startingthe container with the -v option.

$ docker run -e DS_LICENSE=accept \-v /dse/data/opscenter:/var/lib/opscenter \

Page 20 DataStax Docker Docs

Page 21: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

--name my-opscenter \-d datastax/dse-opscenter

Exposing public ports

To allow remote hosts to access a DataStax Enterprise (DSE) node, DSE OpsCenter, orDataStax Studio, map the DSE public port to a host port using the docker run commandwith the -p option.

For a complete list of ports see Securing DataStax Enterprise ports.

Note: When mapping a container port to a local host port, ensure the host port is notalready in use by another container or the host.

Example

To allow access to OpsCenter from a browser on a remote host, open port 8888 as shown inthe following example.

$ docker run -e DS_LICENSE=accept \--name my-opscenter \-p 8888:8888 \-d datastax/dse-opscenter

Volumes and data directoriesVolumes exposed by DSE

DataStax exposes the following volumes so that underlying directories can be mounted.If these volumes are not mounted, then sub-directories will be unavailable. For example,by mounting the /var/lib/cassandra directory, the /data, /commit_logs, /saved_caches directories will be available.

See using volumes in the Docker documentation.

DSE

Directory Description

/var/lib/cassandra Database data

/var/lib/spark DSE Analytics with Spark data

/var/lib/dsefs DSEFS data

/var/log/cassandra Database logs

/var/log/spark Spark logs

/config Custom configuration files

DataStax Docker Docs Page 21

Page 22: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

Studio

Directory Description

/var/lib/datastax-studio DataStax Studio data

Attaching to a containerUse the docker exec -it <container_name> command to attach to a container and runDataStax Enterprise (DSE) tools and other operations.

Opening an interactive bash shell

If the container is running in the background (using the -d option), use the following commandto open an interactive bash shell:

$ docker exec -it <container_name> bash

To exit the shell without stopping the container, type exit.

Opening an interactive CQL shell (cqlsh)

Use the following command to open the cqlsh prompt.

$ docker exec -it <container_name> cqlsh

To exit the shell without stopping the container, use Ctrl + P + Q.

Viewing logs

View DSE logs using the docker log command.

$ docker logs my-dse

Using DSE tools

Use the docker exec command to run other tools. For example:

$ docker exec -it my-dse nodetool status

See the DSE documentation for further information.

Using Docker compose for automated provisioningUse Docker Compose to automate bootstrapping a multi-node cluster with DataStaxEnterprise (DSE), DSE OpsCenter, and DataStax Studio. Use the following links to getsample compose.yml files for different tools and services.

Page 22 DataStax Docker Docs

Page 23: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

• DSE

• DSE OpsCenter

• DataStax Studio

Three node configuration

When creating multiple nodes, use the node parameter to bootstrap one node at a time. Forexample, the first node is node=0, the second node is node=1, and the third node is node=2.

Wait for each node to finish bootstrapping before running docker-compose for the next node.

$ docker-compose -f docker-compose.yml up -d --scale node=0

$ docker-compose -f docker-compose.yml up -d --scale node=1

$ docker-compose -f docker-compose.yml up -d --scale node=2

Three node configuration with OpsCenter

$ docker-compose -f docker-compose.yml -f docker-compose.opscenter.yml \up -d --scale node=0

$ docker-compose -f docker-compose.yml up -d --scale node=1

$ docker-compose -f docker-compose.yml up -d --scale node=2

Three node configuration with OpsCenter and Studio

$ docker-compose -f docker-compose.yml -f docker-compose.opscenter.yml \-f docker-compose.studio.yml up -d --scale node=0

$ docker-compose -f docker-compose.yml up -d --scale node=1

$ docker-compose -f docker-compose.yml up -d --scale node=2

Single node configuration with Studio

$ docker-compose -f docker-compose.yml -f docker-compose.studio.yml \up -d --scale node=0

Single node configuration

To bootstrap a single-node cluster, use the docker run command and specify the version ofDSE to install, plus any additional options.

DataStax Docker Docs Page 23

Page 24: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

$ docker run -e DS_LICENSE=accept -d datastax/dse-server:version \options

Building custom Docker imagesDataStax provides a code repository on Github for building custom Docker images.

By default, Gradle downloads the DataStax tarballs from the DataStax Downloadspage. Enter DataStax Academy credentials either from the command line, or in thegradle.properties file, which is located in the project root.

To build all images, run the following command, entering DataStax Academy credentials forusername and password.

$ ./gradlew buildImages -PdownloadUsername=username \-PdownloadPassword=password

Run ./gradlew tasks to get the list of all available tasks.

Getting help with DockerUse the following links to get help with DataStax Docker images.

• Ask questions in the DataStax Slack channel.• Report issues on Github.• Send an email to [email protected] (page ).

Docker known issuesThe following issues are recognized.

• CFS is not supported.• Changing any file not included in the list of approved configuration files will require

an additional host volume or customization of the image. An example is SSL keymanagement.

• The JVM heap size must be set for DataStax Enterprise (DSE) running inside thecontainer using the JVM_EXTRA_OPTS variable or custom cassandra-env.sh. If notset, Java does not honor resource limits set for the container, and will peer through thecontainer to use resources (memory and CPU) of the host. See the JVM_EXTRA_OPTSvariable in Using environment variables (page 18) for more information.

Licensing termsReview the licensing terms for each of the following products and services:

• DataStax License Terms• DSE OpsCenter License Terms

Page 24 DataStax Docker Docs

Page 25: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.7 Docker Guide

• DataStax Studio License Terms

DataStax Docker Docs Page 25

Page 26: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

DataStax 6.0 Docker Guide

Use DataStax Docker images to create DataStax Enterprise (DSE) server, DSE OpsCenter,and DataStax Studio containers in production and non-production environments.

Getting started with DataStax and DockerUse DataStax-provided Docker images to create containers in production and non-productionenvironments for development, learn DataStax Enterprise (DSE), DataStax OpsCenter,and DataStax Studio, try new ideas, and test and demonstrate an application. The followingimages are available:

• DataStax Enterprise: The best distribution of Apache Cassandra™ with integratedSearch, Analytics, and Graph, and Advanced Security capabilities.

• DataStax Studio: An interactive developer’s tool for DataStax Enterprise which isdesigned to help your DSE database, Cassandra Query Language (CQL), DSE Graph,and Gremlin Query Language development.

• DSE OpsCenter: The web-based visual management and monitoring solution for DSE.

PrerequisitesTo use the Docker images, ensure the following requirements are met:

• Basic understanding of Docker images and containers.• Docker installed on your local system.• DataStax Academy account, if building custom images (page 36) from the DataStax

Github repository.

Creating and starting Docker containersUse the following information to create DataStax Enterprise (DSE) server, DSE OpsCenter,and DataStax Studio containers in production and non-production environments.

Creating a DataStax Enterprise container

Create a DataStax Enterprise (DSE) server container. For a list of the most commonly usedoptions, see Docker run options (page 29).

See the docker run command reference for a full list of options.

Enabling advanced functionality

By default, the DSE server image is configured as a transactional (database) node. Toconfigure the node with DSE advanced functionality, add the corresponding option thatenables the intended feature to the end of the docker run command.

Page 26 DataStax Docker Docs

Page 27: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

Combine startup options to run more than one feature.

Option Description

-g Enable and start DSE Graph.

-k Enable and start DSE Analytics.

-s Enable and start DSE Search.

Examples

Create a DSE database container

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server

Create a DSE container with Graph enabled

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server -g

Create a DSE container with Analytics (Spark) enabled

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server -k

Create a DSE container with Search enabled

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server -s

Creating an OpsCenter container

Create a DataStax Enterprise OpsCenter container and a connected DSE server containeron the same Docker host. For a list of the most commonly used options, see Docker runoptions (page 29).

See the docker run command reference for a full list of options.

1. Create an OpsCenter container.

$ docker run \-e DS_LICENSE=accept \-p 8888:8888 \--name my-opscenter \-d datastax/dse-opscenter

2. Create a DSE server container that is linked to the OpsCenter container.

$ docker run \

DataStax Docker Docs Page 27

Page 28: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

-e DS_LICENSE=accept \--link my-opscenter:opscenter \--name my-dse \-d datastax/dse-server

3. Get the DSE container IP address.

$ docker exec -it my-dse nodetool status

4. Open a browser and navigate to http://DSE_container_IP:8888, whereDSE_container_IP is the IP address of the DSE container.

a. Click Manage existing cluster.

b. Enter the DSE container IP address in the host name field.

c. Click Install agents manually. The agent is already installed on the DSE image,so no installation is required.

OpsCenter is ready to use with DSE.

What's next: See the OpsCenter User Guide for detailed usage and configurationinstructions.

Creating a Studio container

Create a DataStax Studio container. For a list of the most commonly used options, seeDocker run options (page 29).

See the docker run command reference for a full list of options.

1. Create a Studio container, using my-dse as the hostname.

$ docker run -e DS_LICENSE=accept \-p 9091:9091 \--link my-dse \--name my-studio \-d datastax/dse-studio

2. Open a browser and navigate to http://container_IP:9091, where container_IP isthe IP address of the container.

Studio is ready to use with DSE.

What's next:

Page 28 DataStax Docker Docs

Page 29: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

See the DataStax Studio documentation for detailed usage and configuration instructions.

Docker run options

The following options are the most commonly used when creating a DataStax container.

Option Description

-e Sets environment variables (page 30) to accept the licensingagreement and change the initial configuration. Required.

-d Starts the container in the background. Recommended.

-p Publish container ports on the host to allow remote access to DSE,OpsCenter, and Studio. See exposing public ports (page 33) for moreinformation.

-v Bind mount a directory on the local host to a DSE Volume to manageconfiguration or preserve data. See using exposed volumes (page 30)for more information.

--link Link a DSE container to OpsCenter, or Studio to DSE. For example, --link my-opscenter:opscenter or --link my-dse.

--name Assign a name to the container.

Managing the configurationManage the DataStax Enterprise (DSE) configuration using one of the following options:

• The DSE configuration volume (page 30) to get configuration files from a mountedhost directory without replacing or customizing configuration file in the container.

• Environment variables (page 30) to change the configuration at runtime.

• Docker file or directory volume mounts.

• Docker overlay file system.

DataStax Docker Docs Page 29

Page 30: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

Note: DSE uses the default values defined for the environment variables unlessexplicitly set at runtime. Custom configuration files will override the default or explicitlyset environment variables.

Using the DSE configuration volume

Docker images provided by DataStax include a startup script that swaps DataStaxEnterprise (DSE) configuration files found in the /config volume directory with theconfiguration file in the default location on the container.

1. Create a directory on your local host to store the configuration files.

2. Add the configuration files to replace in the container. The file name must match acorresponding configuration file in the image and include all required values. Forexample cassandra.yaml, dse.yaml, opscenterd.conf.

See the following Github pages for a full list of configuration files.

• DSE

• OpsCenter

• Studio

3. Mount the local directory to the exposed /config directory during startup, as shown inthe following example:

$ docker run -v /dse/conf:/config

4. Start the container. The following example illustrates starting a transactional node:

$ docker run -e DS_LICENSE=accept \--name my-dse \-v /dse/config:/config datastax/dse-server \-d datastax/dse-server

Using environment variables

Configure the DataStax Enterprise (DSE) Docker image by setting environment variableswhen the container is created. Use the docker run command -e option.

Page 30 DataStax Docker Docs

Page 31: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

Table 2: Environment variables

Variable Setting Description

DS_LICENSE accept Acknowledge agreement with the terms of theDataStax license. To show the license, set thevariable DS_LICENSE to the value accept.

Important: The image only starts if thisvariable is set to accept.

LISTEN_ADDRESS IP_address IP address to listen for connections from othernodes. Defaults to the container IP address.

BROADCAST_ADDRESS IP_address IP address to advertise to other nodes. Defaultsto the same value as LISTEN_ADDRESS.

NATIVE_TRANSPORT_ADDRESSIP_address IP address to list for client and driverconnections. Default: 0.0.0.0.

NATIVE_TRANSPORT_BROADCAST_ADDRESSIP_address IP address to advertise to clients anddrivers. Defaults to the same value asBROADCAST_ADDRESS.

SEEDS IP_address Comma-delimited list of seed nodesfor the cluster. Defaults to the nodeBROADCAST_ADDRESS.

START_NATIVE_TRANSPORTtrue | false Determines whether to start the Thrift RPCserver. If not set, the default value is preservedin the cassandra.yaml file.

CLUSTER_NAME string Name of the cluster. Default: Test Cluster.

NUM_TOKENS int Number of tokens randomly assigned to thenode. Default: 8.

DC string Datacenter name. Default: Cassandra.

RACK string Rack name. Default: rack1.

OPSCENTER_IP IP_address | string Address of the OpsCenter instance to use forDSE management. The value can be specifiedby linking the OpsCenter container usingopscenter as the name.

JVM_EXTRA_OPTS string Sets a custom value for the JVM heap using -Xmx and -Xms.

LANG string Sets a custom locale.

DataStax Docker Docs Page 31

Page 32: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

Variable Setting Description

SNITCH string Sets the snitch implementation this node willuse. The value is set in the endpoint_snitchparameter in cassandra.yaml.

Persisting data

To persist data, create directories on the local host and map the directory to thecorresponding volume using the docker run command with the -v option. For example:

$ docker run -v local_directory:container_volume

Warning: If the volumes are not mounted from the local host, all data is lost when thecontainer is removed.

DataStax exposes data volumes to preserve data. See volumes and data directories (page33) for a list of exposed volumes.

1. Create a directory on the Docker host.

2. Bind mount the local directory to the configuration file that will be persisted by starting thecontainer with the -v option.

For example, the following command mounts the opscenter.conf file.

$ docker run -e DS_LICENSE=accept \-v /dse/data/opscenter:/opt/opscenter/conf/opscenterd.conf \--name my-opscenter \-d datastax/dse-opscenter

Mounting a DSE configuration volume

Mount the host directory /dse/config to the DSE volume /config to manageconfiguration files.

$ docker run -e DS_LICENSE=accept \--name my-dse \-v /dse/conf:/config datastax/dse-server \-d datastax/dse-server

Mounting an OpsCenter configuration volume

Mount the local directory to the exposed volume /var/lib/opscenter by startingthe container with the -v option.

$ docker run -e DS_LICENSE=accept \-v /dse/data/opscenter:/var/lib/opscenter \

Page 32 DataStax Docker Docs

Page 33: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

--name my-opscenter \-d datastax/dse-opscenter

Exposing public ports

To allow remote hosts to access a DataStax Enterprise (DSE) node, DSE OpsCenter, orDataStax Studio, map the DSE public port to a host port using the docker run commandwith the -p option.

For a complete list of ports see Securing DataStax Enterprise ports.

Note: When mapping a container port to a local host port, ensure the host port is notalready in use by another container or the host.

Example

To allow access to OpsCenter from a browser on a remote host, open port 8888 as shown inthe following example.

$ docker run -e DS_LICENSE=accept \--name my-opscenter \-p 8888:8888 \-d datastax/dse-opscenter

Volumes and data directoriesVolumes exposed by DSE

DataStax exposes the following volumes so that underlying directories can be mounted.If these volumes are not mounted, then sub-directories will be unavailable. For example,by mounting the /var/lib/cassandra directory, the /data, /commit_logs, /saved_caches directories will be available.

See using volumes in the Docker documentation.

DSE

Directory Description

/var/lib/cassandra Database data

/var/lib/spark DSE Analytics with Spark data

/var/lib/dsefs DSEFS data

/var/log/cassandra Database logs

/var/log/spark Spark logs

/config Custom configuration files

DataStax Docker Docs Page 33

Page 34: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

Studio

Directory Description

/var/lib/datastax-studio DataStax Studio data

Attaching to a containerUse the docker exec -it <container_name> command to attach to a container and runDataStax Enterprise (DSE) tools and other operations.

Opening an interactive bash shell

If the container is running in the background (using the -d option), use the following commandto open an interactive bash shell:

$ docker exec -it <container_name> bash

To exit the shell without stopping the container, type exit.

Opening an interactive CQL shell (cqlsh)

Use the following command to open the cqlsh prompt.

$ docker exec -it <container_name> cqlsh

To exit the shell without stopping the container, use Ctrl + P + Q.

Viewing logs

View DSE logs using the docker log command.

$ docker logs my-dse

Using DSE tools

Use the docker exec command to run other tools. For example:

$ docker exec -it my-dse nodetool status

See the DSE documentation for further information.

Using Docker compose for automated provisioningUse Docker Compose to automate bootstrapping a multi-node cluster with DataStaxEnterprise (DSE), DSE OpsCenter, and DataStax Studio. Use the following links to getsample compose.yml files for different tools and services.

Page 34 DataStax Docker Docs

Page 35: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

• DSE

• DSE OpsCenter

• DataStax Studio

Three node configuration

When creating multiple nodes, use the node parameter to bootstrap one node at a time. Forexample, the first node is node=0, the second node is node=1, and the third node is node=2.

Wait for each node to finish bootstrapping before running docker-compose for the next node.

$ docker-compose -f docker-compose.yml up -d --scale node=0

$ docker-compose -f docker-compose.yml up -d --scale node=1

$ docker-compose -f docker-compose.yml up -d --scale node=2

Three node configuration with OpsCenter

$ docker-compose -f docker-compose.yml -f docker-compose.opscenter.yml \up -d --scale node=0

$ docker-compose -f docker-compose.yml up -d --scale node=1

$ docker-compose -f docker-compose.yml up -d --scale node=2

Three node configuration with OpsCenter and Studio

$ docker-compose -f docker-compose.yml -f docker-compose.opscenter.yml \-f docker-compose.studio.yml up -d --scale node=0

$ docker-compose -f docker-compose.yml up -d --scale node=1

$ docker-compose -f docker-compose.yml up -d --scale node=2

Single node configuration with Studio

$ docker-compose -f docker-compose.yml -f docker-compose.studio.yml \up -d --scale node=0

Single node configuration

To bootstrap a single-node cluster, use the docker run command and specify the version ofDSE to install, plus any additional options.

DataStax Docker Docs Page 35

Page 36: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

$ docker run -e DS_LICENSE=accept -d datastax/dse-server:version \options

Building custom Docker imagesDataStax provides a code repository on Github for building custom Docker images.

By default, Gradle downloads the DataStax tarballs from the DataStax Downloadspage. Enter DataStax Academy credentials either from the command line, or in thegradle.properties file, which is located in the project root.

To build all images, run the following command, entering DataStax Academy credentials forusername and password.

$ ./gradlew buildImages -PdownloadUsername=username \-PdownloadPassword=password

Run ./gradlew tasks to get the list of all available tasks.

Getting help with DockerUse the following links to get help with DataStax Docker images.

• Ask questions in the DataStax Slack channel.• Report issues on Github.• Send an email to [email protected] (page ).

Docker known issuesThe following issues are recognized.

• CFS is not supported.• Changing any file not included in the list of approved configuration files will require

an additional host volume or customization of the image. An example is SSL keymanagement.

• The JVM heap size must be set for DataStax Enterprise (DSE) running inside thecontainer using the JVM_EXTRA_OPTS variable or custom cassandra-env.sh. If notset, Java does not honor resource limits set for the container, and will peer through thecontainer to use resources (memory and CPU) of the host. See the JVM_EXTRA_OPTSvariable in Using environment variables (page 30) for more information.

Licensing termsReview the licensing terms for each of the following products and services:

• DataStax License Terms• DSE OpsCenter License Terms

Page 36 DataStax Docker Docs

Page 37: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 6.0 Docker Guide

• DataStax Studio License Terms

DataStax Docker Docs Page 37

Page 38: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

DataStax 5.1 Docker Guide

Use DataStax Docker images to create DataStax Enterprise (DSE) server, DSE OpsCenter,and DataStax Studio containers in production and non-production environments.

Getting started with DataStax and DockerUse DataStax-provided Docker images to create containers for production and non-production environments. The following images are available:

• DataStax Enterprise: The best distribution of Apache Cassandra™ with integratedSearch, Analytics, and Graph, and Advanced Security capabilities.

• DataStax Studio: An interactive developer’s tool for DataStax Enterprise which isdesigned to help your DSE database, Cassandra Query Language (CQL), DSE Graph,and Gremlin Query Language development.

• DSE OpsCenter: The web-based visual management and monitoring solution for DSE.

PrerequisitesTo use the Docker images, ensure the following requirements are met:

• Basic understanding of Docker images and containers.• Docker installed on your local system.• DataStax Academy account, if building custom images (page 47) from the DataStax

Github repository.

Creating and starting Docker containersUse the following information to create DataStax Enterprise (DSE) server, DSE OpsCenter,and DataStax Studio containers in production and non-production environments.

Creating a DataStax Enterprise container

Create a DataStax Enterprise (DSE) server container. For a list of the most commonly usedoptions, see Docker run options (page 40).

See the docker run command reference for a full list of options.

Enabling advanced functionality

By default, the DSE server image is configured as a transactional (database) node. Toconfigure the node with DSE advanced functionality, add the corresponding option thatenables the intended feature to the end of the docker run command.

Combine startup options to run more than one feature.

Page 38 DataStax Docker Docs

Page 39: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

Option Description

-g Enable and start DSE Graph.

-k Enable and start DSE Analytics.

-s Enable and start DSE Search.

Examples

Create a DSE database container

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server

Create a DSE container with Graph enabled

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server -g

Create a DSE container with Analytics (Spark) enabled

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server -k

Create a DSE container with Search enabled

$ docker run -e DS_LICENSE=accept --name my-dse -d datastax/dse-server -s

Creating an OpsCenter container

Create a DataStax Enterprise OpsCenter container and a connected DSE server containeron the same Docker host. For a list of the most commonly used options, see Docker runoptions (page 40).

See the docker run command reference for a full list of options.

1. Create an OpsCenter container.

$ docker run \-e DS_LICENSE=accept \-p 8888:8888 \--name my-opscenter \-d datastax/dse-opscenter

2. Create a DSE server container that is linked to the OpsCenter container.

$ docker run \-e DS_LICENSE=accept \--link my-opscenter:opscenter \--name my-dse \

DataStax Docker Docs Page 39

Page 40: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

-d datastax/dse-server

3. Get the DSE container IP address.

$ docker exec -it my-dse nodetool status

4. Open a browser and navigate to http://DSE_container_IP:8888, whereDSE_container_IP is the IP address of the DSE container.

a. Click Manage existing cluster.

b. Enter the DSE container IP address in the host name field.

c. Click Install agents manually. The agent is already installed on the DSE image,so no installation is required.

OpsCenter is ready to use with DSE.

What's next: See the OpsCenter User Guide for detailed usage and configurationinstructions.

Creating a Studio container

Create a DataStax Studio container. For a list of the most commonly used options, seeDocker run options (page 40).

See the docker run command reference for a full list of options.

1. Create a Studio container, using my-dse as the hostname.

$ docker run -e DS_LICENSE=accept \-p 9091:9091 \--link my-dse \--name my-studio \-d datastax/dse-studio

2. Open a browser and navigate to http://container_IP:9091, where container_IP isthe IP address of the container.

Studio is ready to use with DSE.

What's next:

See the DataStax Studio documentation for detailed usage and configuration instructions.

Docker run options

The following options are the most commonly used when creating a DataStax container.

Page 40 DataStax Docker Docs

Page 41: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

Option Description

-e Sets environment variables (page 42) to accept the licensingagreement and change the initial configuration. Required.

-d Starts the container in the background. Recommended.

-p Publish container ports on the host to allow remote access to DSE,OpsCenter, and Studio. See exposing public ports (page 44) for moreinformation.

-v Bind mount a directory on the local host to a DSE Volume to manageconfiguration or preserve data. See using exposed volumes (page 41)for more information.

--link Link a DSE container to OpsCenter, or Studio to DSE. For example, --link my-opscenter:opscenter or --link my-dse.

--name Assign a name to the container.

Managing the configurationManage the DataStax Enterprise (DSE) configuration using one of the following options:

• The DSE configuration volume (page 41) to get configuration files from a mountedhost directory without replacing or customizing configuration file in the container.

• Environment variables (page 42) to change the configuration at runtime.• Docker file or directory volume mounts.• Docker overlay file system.

Note: DSE uses the default values defined for the environment variables unlessexplicitly set at runtime. Custom configuration files will override the default or explicitlyset environment variables.

Using the DSE configuration volume

Docker images provided by DataStax include a startup script that swaps DataStaxEnterprise (DSE) configuration files found in the /config volume directory with theconfiguration file in the default location on the container.

1. Create a directory on your local host to store the configuration files.

2. Add the configuration files to replace in the container. The file name must match acorresponding configuration file in the image and include all required values. Forexample cassandra.yaml, dse.yaml, opscenterd.conf.

See the following Github pages for a full list of configuration files.

• DSE

DataStax Docker Docs Page 41

Page 42: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

• OpsCenter

• Studio

3. Mount the local directory to the exposed /config directory during startup, as shown inthe following example:

$ docker run -v /dse/conf:/config

4. Start the container. The following example illustrates starting a transactional node:

$ docker run -e DS_LICENSE=accept \--name my-dse \-v /dse/config:/config datastax/dse-server \-d datastax/dse-server

Using environment variables

Configure the DataStax Enterprise (DSE) Docker image by setting environment variableswhen the container is created. Use the docker run command -e option.

Table 3: Environment variables

Variable Setting Description

DS_LICENSE accept Acknowledge agreement with the terms of theDataStax license. To show the license, set thevariable DS_LICENSE to the value accept.

Important: The image only starts if thisvariable is set to accept.

LISTEN_ADDRESS IP_address IP address to listen for connections from othernodes. Defaults to the container IP address.

BROADCAST_ADDRESS IP_address IP address to advertise to other nodes. Defaultsto the same value as LISTEN_ADDRESS.

RPC_ADDRESS IP_address IP address to listen for client/driverconnections. Default: 0.0.0.0.

BROADCAST_RPC_ADDRESS IP_address IP address to advertise to clients/drivers. Defaults to the same value asBROADCAST_ADDRESS.

SEEDS IP_address Comma-delimited list of seed nodesfor the cluster. Defaults to the nodeBROADCAST_ADDRESS.

Page 42 DataStax Docker Docs

Page 43: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

Variable Setting Description

START_RPC true | false Determines whether to start the Thrift RPCserver. If not set, the default value is preservedin the cassandra.yaml file.

CLUSTER_NAME string Name of the cluster. Default: Test Cluster.

NUM_TOKENS int Number of tokens randomly assigned to thenode. Default: 8.

DC string Datacenter name. Default: Cassandra.

RACK string Rack name. Default: rack1.

OPSCENTER_IP IP_address | string Address of the OpsCenter instance to use forDSE management. The value can be specifiedby linking the OpsCenter container usingopscenter as the name.

JVM_EXTRA_OPTS string Sets a custom value for the JVM heap using -Xmx and -Xms.

LANG string Sets a custom locale.

SNITCH string Sets the snitch implementation this node willuse. The value is set in the endpoint_snitchparameter in cassandra.yaml.

Persisting data

To persist data, create directories on the local host and map the directory to thecorresponding volume using the docker run command with the -v option. For example:

$ docker run -v local_directory:container_volume

Warning: If the volumes are not mounted from the local host, all data is lost when thecontainer is removed.

DataStax exposes data volumes to preserve data. See volumes and data directories (page45) for a list of exposed volumes.

1. Create a directory on the Docker host.

2. Bind mount the local directory to the configuration file that will be persisted by starting thecontainer with the -v option.

For example, the following command mounts the opscenter.conf file.

$ docker run -e DS_LICENSE=accept \-v /dse/data/opscenter:/opt/opscenter/conf/opscenterd.conf datastax/dse-opscenter \--name my-opscenter \

DataStax Docker Docs Page 43

Page 44: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

-d datastax/dse-opscenter

Mounting a DSE configuration volume

Mount the host directory /dse/config to the DSE volume /config to manageconfiguration files.

$ docker run -e DS_LICENSE=accept \--name my-dse \-v /dse/conf:/config datastax/dse-server \-d datastax/dse-server

Mounting an OpsCenter configuration volume

Mount the local directory to the exposed volume /var/lib/opscenter by startingthe container with the -v option.

$ docker run -e DS_LICENSE=accept \-v /dse/data/opscenter:/var/lib/opscenter \--name my-opscenter \-d datastax/dse-opscenter

Exposing public ports

To allow remote hosts to access a DataStax Enterprise (DSE) node, DSE OpsCenter, orDataStax Studio, map the DSE public port to a host port using the docker run commandwith the -p option.

For a complete list of ports see Securing DataStax Enterprise ports.

Note: When mapping a container port to a local host port, ensure the host port is notalready in use by another container or the host.

Example

To allow access to OpsCenter from a browser on a remote host, open port 8888 as shown inthe following example.

$ docker run -e DS_LICENSE=accept \--name my-opscenter \-p 8888:8888 \

Page 44 DataStax Docker Docs

Page 45: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

-d datastax/dse-opscenter

Volumes and data directoriesVolumes exposed by DSE

DataStax exposes the following volumes so that underlying directories can be mounted.If these volumes are not mounted, then sub-directories will be unavailable. For example,by mounting the /var/lib/cassandra directory, the /data, /commit_logs, /saved_caches directories will be available.

See using volumes in the Docker documentation.

DSE

Directory Description

/var/lib/cassandra Database data

/var/lib/spark DSE Analytics with Spark data

/var/lib/dsefs DSEFS data

/var/log/cassandra Database logs

/var/log/spark Spark logs

/config Custom configuration files

Studio

Directory Description

/var/lib/datastax-studio DataStax Studio data

Attaching to a containerUse the docker exec -it <container_name> command to attach to a container and runDataStax Enterprise (DSE) tools and other operations.

Opening an interactive bash shell

If the container is running in the background (using the -d option), use the following commandto open an interactive bash shell:

$ docker exec -it <container_name> bash

To exit the shell without stopping the container, type exit.

DataStax Docker Docs Page 45

Page 46: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

Opening an interactive CQL shell (cqlsh)

Use the following command to open the cqlsh prompt.

$ docker exec -it <container_name> cqlsh

To exit the shell without stopping the container, use Ctrl + P + Q.

Viewing logs

View DSE logs using the docker log command.

$ docker logs my-dse

Using DSE tools

Use the docker exec command to run other tools. For example:

$ docker exec -it my-dse nodetool status

See the DSE documentation for further information.

Using Docker compose for automated provisioningUse Docker Compose to automate bootstrapping a multi-node cluster with DataStaxEnterprise (DSE), DSE OpsCenter, and DataStax Studio. Use the following links to getsample compose.yml files for different tools and services.

• DSE

• DSE OpsCenter

• DataStax Studio

Three node configuration

When creating multiple nodes, use the node parameter to bootstrap one node at a time. Forexample, the first node is node=0, the second node is node=1, and the third node is node=2.

Wait for each node to finish bootstrapping before running docker-compose for the next node.

$ docker-compose -f docker-compose.yml up -d --scale node=0

$ docker-compose -f docker-compose.yml up -d --scale node=1

$ docker-compose -f docker-compose.yml up -d --scale node=2

Page 46 DataStax Docker Docs

Page 47: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

Three node configuration with OpsCenter

$ docker-compose -f docker-compose.yml -f docker-compose.opscenter.yml \up -d --scale node=0

$ docker-compose -f docker-compose.yml up -d --scale node=1

$ docker-compose -f docker-compose.yml up -d --scale node=2

Three node configuration with OpsCenter and Studio

$ docker-compose -f docker-compose.yml -f docker-compose.opscenter.yml \-f docker-compose.studio.yml up -d --scale node=0

$ docker-compose -f docker-compose.yml up -d --scale node=1

$ docker-compose -f docker-compose.yml up -d --scale node=2

Single node configuration with Studio

$ docker-compose -f docker-compose.yml -f docker-compose.studio.yml \up -d --scale node=0

Single node configuration

To bootstrap a single-node cluster, use the docker run command and specify the version ofDSE to install, plus any additional options.

$ docker run -e DS_LICENSE=accept -d datastax/dse-server:version \options

Building custom Docker imagesDataStax provides a code repository on Github for building custom Docker images.

By default, Gradle downloads the DataStax tarballs from the DataStax Downloadspage. Enter DataStax Academy credentials either from the command line, or in thegradle.properties file, which is located in the project root.

To build all images, run the following command, entering DataStax Academy credentials forusername and password.

$ ./gradlew buildImages -PdownloadUsername=username \-PdownloadPassword=password

DataStax Docker Docs Page 47

Page 48: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax 5.1 Docker Guide

Run ./gradlew tasks to get the list of all available tasks.

Getting help with DockerUse the following links to get help with DataStax Docker images.

• Ask questions in the DataStax Slack channel.• Report issues on Github.• Send an email to [email protected] (page ).

Docker known issuesThe following issues are recognized.

• CFS is not supported.• Changing any file not included in the list of approved configuration files will require

an additional host volume or customization of the image. An example is SSL keymanagement.

• The JVM heap size must be set for DataStax Enterprise (DSE) running inside thecontainer using the JVM_EXTRA_OPTS variable or custom cassandra-env.sh. If notset, Java does not honor resource limits set for the container, and will peer through thecontainer to use resources (memory and CPU) of the host. See the JVM_EXTRA_OPTSvariable in Using environment variables (page 42) for more information.

Licensing termsReview the licensing terms for each of the following products and services:

• DataStax License Terms• DSE OpsCenter License Terms• DataStax Studio License Terms

Page 48 DataStax Docker Docs

Page 49: DataStax Docker Docs · DSE cluster per Docker host. If running multiple DataStax containers on a single Docker host, ensure that the containers are in different DSE clusters. Software

DataStax Docker Images

DataStax Docker ImagesUse DataStax Docker images to create containers in production and non-productionenvironments.

Before downloading DataStax Docker images, download and install Docker from the Dockerwebsite.

DataStax Docker Docs Page 49