Sign inSign up

nuodbsaleseng/testdrive

By nuodbsaleseng

Updated over 8 years ago

Test Docker for NuoDB in 3 containers - docker pull nuodbsaleseng/testdrive:1

Image
0

125

nuodbsaleseng/testdrive repository overview

Build NuoDB multi container environment on Docker

Table of Contents Preparation in AWS 2 Install Docker 2 Build NuoDB docker 3 Base image and automate start of Nuodb 4 Setup docker network 4 Start NuoDB containers 6 Tidy up 8

Preparation in AWS

Create a single SPOT instance m4.xlarge is recommended. This type of machine has 4 CPUs and 16GB of RAM, should be enough to run 3 docker containers comfortably.

In addition to this, I ordered 2 EBS Root file system 16GB – ( ensure this is big enough for your docker builds as /var/lib/docker is the default location to store these) Add an additional volume, sized 100GB, and the idea is if you need anything more permanent, put it in this volume. Mount as /data. Ensure that this EBS does not get deleted if the spot instance is terminated

Launch and connect the instance with Amazon Linux AMI Install Docker

Update all packages first

sudo yum update -y sudo yum install -y docker sudo service docker start

Then make sure ec2-user is added to docker group

sudo usermod -a -G docker ec2-user

Log out and log back in, to ensure that ec2-user can now run docker

Test it by running

docker --version

Docker version 17.12.0-ce, build 3dfb8343b139d6342acfd9975d7f1068b5b1c3d3

Test that docker is running ok by running “hello-world”

docker run hello-world

Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world ca4f61b1923c: Pull complete Digest: sha256:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1 Status: Downloaded newer image for hello-world:latest

Hello from Docker! This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64)
  3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
  4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/

For more examples and ideas, visit: https://docs.docker.com/engine/userguide/

Build NuoDB docker

Prepare environment

Sudo mkdir '-p' /data/docker_stuff/builds/NuoDBDocker sudo chmod 777 –R /data cd /data/docker_stuff/builds/NuoDBDocker

Base image and automate start of Nuodb

Edit a new file called nuohosts

vi nuohosts

paste the following into it and save

10.1.4.101 nuo1 10.1.4.102 nuo2 10.1.4.103 nuo3

Fetch the images

docker pull nuodbsaleseng/testdrive:1

Run the build

docker build -t testdrive:1 .

Setup docker network

Now in order to be able to use the assigned IP address, we need to create our own network in docker. We will be creating our own bridge called nuobridge1 with a range of IP address in block 10.1.4.0/24

docker network create --subnet 10.1.0.0/16 --gateway 10.1.0.1 --ip-range=10.1.4.0/24 --driver=bridge --label=nuonetwork nuobridge1

docker network ls NETWORK ID NAME DRIVER SCOPE c056a0091eff bridge bridge local 809a724d866f host host local 08626698e558 none null local bb94d59e0070 nuobridge1 bridge local

On the docker host, if we check ifconfig, docker will install docker0 network interface after docker install, and after our step above, it will create a new bridge network interface br-*

ifconfig

br-bb94d59e0070 Link encap:Ethernet HWaddr 02:42:F4:B0:66:89
inet addr:10.1.0.1 Bcast:10.1.255.255 Mask:255.255.0.0 inet6 addr: fe80::42:f4ff:feb0:6689/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6838996 errors:0 dropped:0 overruns:0 frame:0 TX packets:3580168 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:9514532879 (8.8 GiB) TX bytes:1602790785 (1.4 GiB)

docker0 Link encap:Ethernet HWaddr 02:42:F6:00:0C:4E
inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0 inet6 addr: fe80::42:f6ff:fe00:c4e/64 Scope:Link UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:130715 errors:0 dropped:0 overruns:0 frame:0 TX packets:142342 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:7369203 (7.0 MiB) TX bytes:1165720563 (1.0 GiB)

eth0 Link encap:Ethernet HWaddr 02:3E:E6:C0:CD:FE
inet addr:172.31.5.125 Bcast:172.31.15.255 Mask:255.255.240.0 inet6 addr: fe80::3e:e6ff:fec0:cdfe/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:9001 Metric:1 RX packets:6838996 errors:0 dropped:0 overruns:0 frame:0 TX packets:3580172 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:9514532879 (8.8 GiB) TX bytes:1602791841 (1.4 GiB)

Start NuoDB containers

Next we start 3 containers, and we call it nuo1, nuo2 and nuo3, and we expose different ports against it from the originating host

Start container 1 – called nuo1, hardcode to 10.1.4.101 as per our nuohosts, map host ports 48104-48120 to be used as 48004-48020 internally

docker run -itd --name nuo1 -h nuo1 --net nuobridge1 --ip 10.1.4.101 -v /data/docker_stuff/builds/NuoDBDocker/mount:/data -p 48104-48120:48004-48020 nuodbsaleseng/testdrive:1

Start container 2 – called nuo2, hardcode to 10.1.4.102 as per our nuohosts, map host ports 48204-48220 to be used as 48004-48020 internally

docker run -itd --name nuo2 -h nuo2 --net nuobridge1 --ip 10.1.4.102 -v /data/docker_stuff/builds/NuoDBDocker/mount:/data -p 48204-48220:48004-48020 nuodbsaleseng/testdrive:1

Start container 3 – called nuo3, hardcode to 10.1.4.103 as per our nuohosts, map host ports 48304-48320 to be used as 48004-48020 internally

docker run -itd --name nuo3 -h nuo3 --net nuobridge1 --ip 10.1.4.103 -v /data/docker_stuff/builds/NuoDBDocker/mount:/data -p 48304-48320:48004-48020 nuodbsaleseng/testdrive:1

Make sure they are all running

docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7752de6b96b4 stepbystep:v6 "/bin/sh -c 'cat /tm…" 3 seconds ago Up 2 seconds 0.0.0.0:48304->48004/tcp, 0.0.0.0:48305->48005/tcp, 0.0.0.0:48306->48006/tcp, 0.0.0.0:48307->48007/tcp, 0.0.0.0:48308->48008/tcp, 0.0.0.0:48309->48009/tcp, 0.0.0.0:48310->48010/tcp, 0.0.0.0:48311->48011/tcp, 0.0.0.0:48312->48012/tcp, 0.0.0.0:48313->48013/tcp, 0.0.0.0:48314->48014/tcp, 0.0.0.0:48315->48015/tcp, 0.0.0.0:48316->48016/tcp, 0.0.0.0:48317->48017/tcp, 0.0.0.0:48318->48018/tcp, 0.0.0.0:48319->48019/tcp, 0.0.0.0:48320->48020/tcp nuo3 524ca8667ae8 stepbystep:v6 "/bin/sh -c 'cat /tm…" 14 seconds ago Up 13 seconds 0.0.0.0:48204->48004/tcp, 0.0.0.0:48205->48005/tcp, 0.0.0.0:48206->48006/tcp, 0.0.0.0:48207->48007/tcp, 0.0.0.0:48208->48008/tcp, 0.0.0.0:48209->48009/tcp, 0.0.0.0:48210->48010/tcp, 0.0.0.0:48211->48011/tcp, 0.0.0.0:48212->48012/tcp, 0.0.0.0:48213->48013/tcp, 0.0.0.0:48214->48014/tcp, 0.0.0.0:48215->48015/tcp, 0.0.0.0:48216->48016/tcp, 0.0.0.0:48217->48017/tcp, 0.0.0.0:48218->48018/tcp, 0.0.0.0:48219->48019/tcp, 0.0.0.0:48220->48020/tcp nuo2 c647d8783acf stepbystep:v6 "/bin/sh -c 'cat /tm…" 28 seconds ago Up 28 seconds 0.0.0.0:48104->48004/tcp, 0.0.0.0:48105->48005/tcp, 0.0.0.0:48106->48006/tcp, 0.0.0.0:48107->48007/tcp, 0.0.0.0:48108->48008/tcp, 0.0.0.0:48109->48009/tcp, 0.0.0.0:48110->48010/tcp, 0.0.0.0:48111->48011/tcp, 0.0.0.0:48112->48012/tcp, 0.0.0.0:48113->48013/tcp, 0.0.0.0:48114->48014/tcp, 0.0.0.0:48115->48015/tcp, 0.0.0.0:48116->48016/tcp, 0.0.0.0:48117->48017/tcp, 0.0.0.0:48118->48018/tcp, 0.0.0.0:48119->48019/tcp, 0.0.0.0:48120->48020/tcp nuo1

To ensure that the containers can write to the mounted drive, run

sudo chmod 777 /data/docker_stuff/builds/NuoDBDocker/mount

Now let’s just login to one of them. All brokers can be seen as up and running on all 3 hosts

docker exec -it nuo3 /bin/bash

run the commands in the container you have just connected to below:

[root@nuo3 /]# more /etc/hosts 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 10.1.4.103 nuo3 10.1.4.101 nuo1 10.1.4.102 nuo2 10.1.4.103 nuo3 [root@nuo3 /]# ping nuo1 PING nuo1 (10.1.4.101) 56(84) bytes of data. 64 bytes from nuo1 (10.1.4.101): icmp_seq=1 ttl=255 time=0.061 ms 64 bytes from nuo1 (10.1.4.101): icmp_seq=2 ttl=255 time=0.047 ms 64 bytes from nuo1 (10.1.4.101): icmp_seq=3 ttl=255 time=0.047 ms ^C --- nuo1 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2053ms rtt min/avg/max/mdev = 0.047/0.051/0.061/0.010 ms [root@nuo3 /]# ping nuo2 PING nuo2 (10.1.4.102) 56(84) bytes of data. 64 bytes from nuo2 (10.1.4.102): icmp_seq=1 ttl=255 time=0.058 ms 64 bytes from nuo2 (10.1.4.102): icmp_seq=2 ttl=255 time=0.038 ms 64 bytes from nuo2 (10.1.4.102): icmp_seq=3 ttl=255 time=0.051 ms 64 bytes from nuo2 (10.1.4.102): icmp_seq=4 ttl=255 time=0.051 ms ^C --- nuo2 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3054ms rtt min/avg/max/mdev = 0.038/0.049/0.058/0.010 ms [root@nuo3 /]# nuodbmgr --broker localhost --password nuodb NuoDB host version: 3.0.2-6: Professional Edition nuodb [domain] > show domain summary

Hosts: [broker] nuo1/10.1.4.101:48004 (DEFAULT_REGION) CONNECTED [broker] nuo2/10.1.4.102:48004 (DEFAULT_REGION) CONNECTED [broker] * nuo3/127.0.0.1:48004 (DEFAULT_REGION) CONNECTED

nuodb [domain] > exit

Tidy up

Old images and containers take up space. Remove what you don’t need and remove the network

docker network remove nuobridge1

Tag summary

Content type

Image

Digest

Size

980.3 MB

Last updated

over 8 years ago

docker pull nuodbsaleseng/testdrive:1