Set up Docker, Virtual Box, Cassandra in Docker - sharans003/DatabaseSystems GitHub Wiki
We'll be using Cassandra 2.1 and Ubuntu 16.04
https://www.youtube.com/watch?v=lEvM-No4eQo
Also, to enable universal Copy Paste, Universal Drag n drop do the following:
- Devices -> Insert Guest Additions CD image (Keep saying YES or OK, let it do its thing)
- Devices -> Shared Clipboard -> Bidriectional
- Devices -> Drag and Drop -> Bidriectional
https://docs.docker.com/install/linux/docker-ce/ubuntu/
- Install Xernial 16.04
- Stop before "Install using the convenience script"
- Then do this : https://docs.docker.com/install/linux/linux-postinstall/
- Shutdown the VM and restart
https://hub.docker.com/_/cassandra/ (Replace tag by 2.1)
- sudo docker run --name sharan_cass --link some-cassandra:cassandra -d cassandra:2.1
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
apt-cache madison docker-ce
pt-cache madison docker-ce
docker-ce | 17.12.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
apt-cache madison docker-ce
sudo apt-get install docker-ce=<VERSION>
sudo apt-get install docker-ce
sudo docker run hello-world
sudo groupadd docker
sudo usermod -aG docker $USER
docker run hello-world
sudo docker run hello-world
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
docker
sudo docker ps
docker ps
docker run --name sharan-cass -d cassandra:2.1
docker exec -it sharan-cass bash
docker ps
docker ls
docker exec -it <container-name> bash
docker run --name cass1 -d cassandra:2.1
- cqlsh
- exit To exit docker, type exit again
https://github.com/abh1nav/docker-cassandra
- Skip everything till "Manual Mode"
docker pull abh1nav/cassandra:latest
Create a new container using opscenter
docker run -d --name opscenter -p 8888:8888 -p 61620:61620 abh1nav/opscenter:latest
Changing configuration of address.yaml in all the cassandra nodes that are part of a single cluster
Fields to be changed
--rpc_address- change from 0.0.0.0 to node ip address
--seed_ip- currently it will have ip of just the current node, add ip of all the other nodes in the cluster.
1. ssh into node: docker exec -it NODENAME bash
2. Go to cd /etc/cassandra
3. Modify cassandra.yaml file
Install datastax agent on every node:
https://docs.datastax.com/en/archived/opscenter/5.1/opsc/install/opsc-agentInstallManual_t.html
Steps to be followed:
1. GO to cd /home
2. Run following command
curl -L http://downloads.datastax.com/community/datastax-agent-5.1.0.tar.gz | tar xz
3. cd datastax-agent-version
4. echo "stomp_interface: <<OPS_CENTER_IP>>" >> ./conf/address.yaml
5.bin/datastax-agent
Go to a directory
Pre-requisite to install agents:
apt-get update && apt-get install sudo
sudo apt-get install curl
- Getting IP address:
OPS_IP=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' opscenter)
- Go here: https://github.com/docker/kitematic/releases
- Download the .deb
- Install it.
- If that does not work try
sudo apt-get install kitematic
- Sometimes it might not show up as a logo. So in that case go to terminal and type kitemetic.
- Start new cassandra node which will be used as NTP Server.
- Make sure there are few ntp servers in /etc/ntpd.conf file.
- Start few nodes in a cluster.
- Install ntp on all nodes ( If you are using docker cassandra iamge, ntp should be pre installed).
- Setup ip address of ntp server node in /etc/ntpd.conf file on all the nodes. -- $pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will $pick a different set every time it starts up. Please consider joining the $pool: http://www.pool.ntp.org/join.html. server 172.17.0.4 iburst
- Restart ntp server on all the nodes using : /etc/init.d/ntp restart
- Try pinging ntp server from all the nodes and check on ntp server node if we are able to receive the ping. To ping : ping 172.17.0.4 . To check if node is receiving ping: tcpdump ip proto \icmp
https://askubuntu.com/questions/429306/ntpdate-no-server-suitable-for-synchronization-found https://github.com/cturra/docker-ntp
- We are going to have 3 VMS.
- VM 1 is going to have the NTP server
- VM 2 is going to have the 1st Cassandra node
- VM 3 is going to have the 2nd Cassandra node
- In the first cassandra node, set the broadcast IP.
- Do IFCONFIG in the cassandra node and get the IP.
docker run --name <container_name> -d -e CASSANDRA_BROADCAST_ADDRESS=192.168.89.4 -p 9044:9044 cassandra:2.1 docker container start <same_container_name> docker exec -it <same_container_name> bash
- The broadcast IP is going to tell the other nodes in cassandra which IP to listen to.
- In a way it is the "central" link for the rest of the cluster
- The Seed IP is going to be set in the Cassandra node that is not the broadcast IP.
docker run --name <container_name> -d -e CASSANDRA_SEEDS=<broadcast_ip_that we set in node 1>
docker run --name <container_name> -d cassandra:2.1 -e CASSANDRA_SEEDS=<broadcast_ip_that we set in node 1>
docker run --name <name> -d -e CASSANDRA_BROADCAST_ADDRESS=<ip of this vm> -p 7000:7000 cassandra 2.1
docker run --name <name> -d -e CASSANDRA_BROADCAST_ADDRESS=<ip of this vm> -e CASSANDRA_SEEDS=<broadcast mentioned in the first vm i.e. the first vm's IP address>-p 7000:7000 cassandra:2.1
nodetool status
-
Setup NTP
-
Say server ip is 10.10.0.1.
-
1 Node is connected to server (0.debian.pool.ntp.org). Where ever we have pool, replace by server. Remove pool0,pool1 etc. Have just 1 line.
-
Also in fall back make it 127.0.0.1
-
Now in the clients, make the server IP point to 10.10.0.1, and remove the rest. Make the fall back 127.0.0.1
-
Now restart the server on all.
-
Then check if the nodes have synced.
-
If they have, move on with life.
-
Next Install Java. Make sure it is Java 1.8
-
java -version should do it
-
If its not 1.8 find out how to set it to that.
-
Now install cassandra from the documentation.
-
Check java version. It has to be 1.8, without that it wont work
-
Run cassandra.
Multi node cassandra: Server: 10.0.0.1 Client1: 10.0.0.2 Client2: 10.0.0.3
In the yaml file do not change the server file at all
Go to client1: broadcast IP: 10.0.0.2 RPC IP: 10.0.0.2 Listen IP: 10.0.0.2 SeedIP: 10.0.0.2
Go to client2: broadcast IP: 10.0.0.3 RPC IP: 10.0.0.3 Listen IP: 10.0.0.3 SeedIP: 10.0.0.2, 10.0.0.3
Try the cassandra stress:
cassandra-stress write n=50000 -rate threads=40 -node d0.cass.org