Click here to Skip to main content
15,886,110 members
Articles / Containers / Docker
Article

Cloudant Data Layer

2 Aug 2016CPOL6 min read 16.5K  
IBM Cloudant Data Layer Local Edition is a database management system (DBMS) platform designed to resemble IBM Cloudant Database as a service (DBaaS) in the privacy of your own data center.

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

Image 1

Introduction

Size and speed > Data and Calculations > Storage and computing power > Cloud and scalability

Every day new data centers are built all over the world, cloud data storage is expanding, and as result, prices go down. Companies are moving their precious data to the Cloud enriching their business with unlimited space, more processing power, service availability, scalability, mobility, redundancy and data durability.

Not all clients are willing to trust cloud securities or have the liability of staying online during all operational time. There is no need for them to suffer the lack of cloud services in their business. This is why cloud service providers often offer private cloud services or locally deployable solutions.

Background

IBM Cloudant Data Layer Local Edition

IBM Cloudant Data Layer Local Edition is a database management system (DBMS) platform designed to resemble IBM Cloudant Database as a service (DBaaS) in the privacy of your own data center.

Cloudant Local packages up the rich functionality, behavior and tooling of Cloudant Managed DBaaS for companies of all sizes. It offers elastic scalability as it runs on inexpensive servers and you can easily add or remove servers in the cluster to balance your traffic fluctuations. It also offers multi-datacenter and data mobility services replicating data across data centers or between mobile devices in order to have the data closer to the user for fast access. Finally, it offers adaptive deployment options, that allow you to match your application development roadmap needs to the data layer.

Additionally:

  • You can run Cloudant Local in a private cloud environment to achieve maximum privacy.
  • You can run Cloudant Local in a public cloud on public cloud platforms to achieve geo-location and traffic goals.
  • You can run Cloudant Local in hybrid cloud a combination of private and public clouds to achieve optimal cost, reach, service and compliance.

Requirements

Cloudant Local requires minimum of five servers to create a cluster:

  • 1 primary load balance
  • 1 failover load balancer
  • 3 database servers

It runs on 64-bit operating systems - Debian (6.0.10), Ubuntu Server (12.04.4), Red Hat Enterprise Linux Server (6.5) or CentOS (6.5)

Cloudant Developer edition

For the purpose of this post we will install Cloudant Developer edition. This is a fully-featured version of Cloudant Local licensed for development purposes only. The limitations are that you can't create clusters and you can have only one node. On other side there is less hardware and software requirements in comparison to the hardware and software requirements for Cloudant Local installation.

Using the code

Prerequisites

As Cloudant Developer Edition is designed to be used as a design and test tool for developers, it's packaged as Docker standardized unit for software development. It is easy to deploy it using Docker and allows us to choose the best environment to work on.

I will show how Cloudant Developer is installed on both Ubuntu and Windows 10, but first we need to install Docker.

Image 2

Installation of Docker on Ubuntu

Image 3

Installing Docker on Linux is related to validations and preparations (as is often the case with Linux software)

We need to know two thinks before we start:

  • Kernel version: as Docker can be installed on 64-bit Ubuntu versions with kernel above version 3.10
  • Release versions: as we need to name the package for download.

Image 4

Next steps are:

  1. Update package information and install https and CA certificates
    $ sudo apt-get update
    $ sudo apt-get install apt-transport-https ca-certificates
    
  2. Add new GPG key (skip this step until you find the certificate thumbprint)
    $ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

    Remark: the certificate thumbprint will be shown as error message when repository pull is requested.

  3. Edit or create docker.list in /etc/apt/sources.list.d - based on your Ubuntu release you need to set file content to one of the following:

    Ubuntu Precise 12.04 (LTS)

    deb https://apt.dockerproject.org/repo ubuntu-precise main

    Ubuntu Trusty 14.04 (LTS)

    deb https://apt.dockerproject.org/repo ubuntu-trusty main

    Ubuntu Wily 15.10

    deb https://apt.dockerproject.org/repo ubuntu-wily main

    Ubuntu Xenial 16.04 (LTS)

    deb https://apt.dockerproject.org/repo ubuntu-xenial main

    In order to edit the file, you will need root access.

  4. Run the APT package update
    $ sudo apt-get update
  5. We need to purge the old repository (if any exists)
    $ sudo apt-get purge lxc-docker
  6. Set new repository for APT to pull Docker
    $ apt-cache policy docker-engine

    Image 5

  7. Install additional packages to extend Docker functionality. Based on your Ubuntu version this step can have one or multiple commands to execute:

    Ubuntu Precise 12.04 (LTS)

    (check Docker documentation)

    Ubuntu Trusty 14.04 (LTS)

    $ sudo apt-get install linux-image-extra-$(uname -r)

    Ubuntu Wily 15.10

    Ubuntu Xenial 16.04 (LTS)

    Image 6

  8. Last update, Install and run Docker
    $ sudo apt-get update    
    $ sudo apt-get install docker-engine    
    $ sudo service docker start
  9. Check if Docker is operational
    $ sudo docker run hello-world

    Image 7

    This will be all about Docker installation on Ubuntu

Install Docker on Windows 10

Image 8

It's easy as any other Windows installation:

  1. Download from Docker site and start the installation
  2. Accept the license agreement

    Image 9

  3. Finish the installation and check Docker

    Image 10

    Image 11

Install Cloudant Developer

After installing Docker the Cloudant Developer installation is fast and easy for both Windows and Ubuntu environments. It's a four step installation process including the license agreement.

  1. Pull Cloudant Developer from Docker repository
    docker pull ibmcom/cloudant-developer

    Image 12

    Image 13

  2. Start Cloudant Local with default settings
    docker run --privileged --detach --volume cloudant:/srv --name cloudant-developer --publish 8080:80 --hostname cloudant.dev ibmcom/cloudant-developer

    Image 14

  3. Accept the license agreement
    docker exec -ti cloudant-developer cast license â€"console

    Image 15

  4. Clear databases
    docker exec cloudant-developer cast database init -v -y -p pass

    Image 16

    Image 17

Finally, you have now fully operational local version of Cloudant Database:

Under Ubuntu

Image 18

And in Windows 10

Image 19

Repeating all those steps you will be pleased to discover how fast and smooth Cloudant Local works.

You can also design and test indexes and search queries without the risk of downtime in production environment.

Local testing

In previous posts we created simple IoT examples for storing data on a Cloudant Database and we did some demo indexing and searching over the collected data. Now we can reuse all those examples addressing local installation on a developer machine. For example, the emulator code can now submit data locally into Cloudant Developer installed under Windows 10. This way we will have a development environment separated from the public network, and solutions suitable for source control and off line mode in order to avoid data collisions.

The change in code is that the address is no longer a Cloudant DBaaS URL, but localhost.

#region CreateHttpClient
private static HttpClient CreateHttpClient(HttpClientHandler handler, string user, string database)
{
    return new HttpClient(handler)
        {
            BaseAddress = new Uri(string.Format("https://localhost:8080/{1}/", user, database))
        };

}
#endregion CreateHttpClient

With only this change we have the expected results:

  • High speed of processing as it's not delivering any data through the network
  • Full access to all Cloudant DB features

Image 20

Point of interest

IBM Cloudant provides for us a full set of tools and services for efficient application and business development. We can planresults and growth relaying on quality solutions for each step of our roadmap. An IBM Cloudant Developer comforts developers into their preferred operating system and set of tools

IBM Cloudant Data Layer Local comforts businesses into their privacy, accessibility and price expectations.

IBM Cloudant Managed DBaaS gives us the freedom of the Cloud.

The new Universal No-SQL Database Platform allows us to develop once and re-use code on mobile and personal devices, in private clusters, or in the cloud delivering fast results to our users.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Strypes
Bulgaria Bulgaria
Mihail Mateev is a Technical Consultant, Community enthusiast, PASS RM for CEE and chapter lead, Microsoft Azure MVP
He works as Solutions Architect, Technical PM and Senior Technical Evangelist at Strypes
Mihail Mateev has experience as a Senior Technical Evangelist, Team Lead at Infragistics Inc. He worked as a Software developer and team lead on WPF and Silverlight Line of Business production lines of the company.
Mihail worked in various areas related to technology Microsoft: Silverlight, WPF, Windows Phone 7, Visual Studio LightSwitch, WCF RIA Services, ASP.Net MVC, Windows Metro Applications, MS SQL Server and Windows Azure. He also write many jQuery related blogs.
Over the past ten years, Mihail has written articles for Bulgarian Computer World magazine, blogs about .Net technologies. He is a contributor and a technical editor of publications PACKT Publishing and Wiley. Mihail did presentations for .Net and Silverlight user groups in Bulgaria. He has an Experience with GIS system over .Net framework. He worked more than five years in ESRI Bulgaria like a Software developer and a trainer. Several years Mihail did a lectures about Geographic Information Systems in the Sofia University “St. Kliment Ohridski” , Faculty of Mathematics and Informatics. Mihail is also a lecturer about Computer Systems in the University of the Architecture, Civil Engineering and Geodesy in Sofia at Computer Aided Engineering Department. Mihail holds master's degrees in Structural Engineering and Applied Mathematics and Informatics.

Comments and Discussions

 
-- There are no messages in this forum --