In this post, we will learn how to install a NuoDB Community Edition in kubernetes infrastructure using OpenEBS for storage
Introduction to NuoDB
Elastic Scalability is the capability of the database to provide amazing scale-out performance and scale-in cost savings on-demand.
Every organization wants to make the most of any growth opportunity presented to them. A successful business often anticipates when it will need more resources for its database. However, there are times in the lives of organizations when they grow so fast that they need to scale up fairly quickly. This is the time when you need elastic scalability more than any other day. You don’t want your application to crash or start performing poorly when the business opportunities are more numerous.
Scaling a traditional relational database usually requires a lot of planning and is a very nervous road even for experienced DBAs. Whereas NoSQL often requires development work for the application.
Now you don’t have to worry about rewriting your applications when you need to scale your database. NuoDB preserves ACID guarantees and a standard SQL interface while offering simple and elastic scaling. In other words, you can add and remove database capabilities as you need them, which lowers the total cost of ownership and your application team won’t have to worry about programming or database architecture. There are three unique advantages :
- Reduce total cost by matching resources to demand
- Improve your product by focusing on the application code
- Grow your business without technical constraints
NuoDB is a relational database designed for the cloud. It’s a true SQL service that has all the properties of ACID transactions, supports the standard SQL language and relational logic that you love. It’s also designed from the ground up to provide the scalability you’d expect from a service designed for the cloud.
The architecture of the NuoDB database is based on three main components. The first one is a broker that interprets JDBC, ODBC and SQL requests from different clients. This broker acts as an interpreter but also as a load balancer for the requests. The second component is a transactional engine that ensures the ACID (Atomicity, Consistency, Isolation and Durability) of the transactions, which guarantees that NuoDB behaves like a real relational database in terms of transaction consistency. Finally, the last component is a storage engine that relies on a Key Value Store system. This engine can rely on local storage but also on storage services such as Amazon’s S3 or HDFS (Hadoop File System), provided that these storages meet the required performance constraints. NuoDB’s architecture is fully distributed and allows to design a geodistributed database in active-active mode
Each of these components can be duplicated at will according to the database’s scalability needs (and there is no notion of master or slave). It is thus possible to multiply the storage engines in order to guarantee optimal data integrity (data is replicated between Key Value Stores) or to deploy a large number of transactional engines to handle a large number of transactions.
The NuoDB Community Edition is available for Kubernetes, Docker, and physical / virtual machine host environments. Community Edition of NuoDB limits your deployment to:
- 3 Transaction Engines and 1 Storage Manager
- Deployment in a single location
NuoDB processes:
-
Admin Services (AP) are responsible for managing the domain and database state. The Admin service is also responsible for the load balancing function that connects client applications to NuoDB TE processes.
-
Transaction Engines (TEs) are responsible for connecting client applications to the database and processing SQL transactions. They also perform in-memory data caching of data tables to optimize SQL performance. Each TE is managed by a single Admin service.
-
Storage Managers (SMs) are responsible for ensuring on-disk data durability and replicating changes to new started SMs. Each SM is managed by a single Admin service.
We have one Admin Service per domain, several databases per domain, one Transaction Engines (or more) and one Storage Managers (or more) per database. It is recommended to have more than one Admin Service (AP) per domain.
Handling Fault Tolerance & High Availability Requirements
NuoDB is a highly consistent database, using replication between a user-defined set of replicas. NuoDB offers a highly available, scale-out database without the added complexities of adopting NoSQL for transactional applications or the need for sharding.
Prerequisites
Before you get started, you’ll need to have these things:
- A kubernetes cluster (1 master and 3 workers nodes) on linux instance
- Configuration of each node : 16 vCPUs - 32GB RAM - 120 GB of storage
- HELM > 3.0.x
- OpenEBS 1.4.0
- package tuned installed
Architecture
I will use the following architecture :
Advantages of using OpenEBS for NuoDB database:
- No need to manage the local disks, they are managed by OpenEBS
- Large size PVs can be provisioned by OpenEBS and NuoDB
- Start with small storage and add disks as needed on the fly. Sometimes NuoDB instances are scaled up because of capacity on the nodes. With OpenEBS persistent volumes, capacity can be thin provisioned and disks can be added to OpenEBS on the fly without disruption of service
- If required, take backup of the NuoDB data periodically and back them up to S3 or any object storage so that restoration of the same data is possible to the same or any other Kubernetes cluster
In this post I will not detail the installation of OpenEBS see the previous posts : Using HELM Chart to Deploying OpenEBS to an Kubernetes Cluster using Terraform and OpenEBS CStor CSI Driver
The storage class we are going to use is called: sc-cstor-csi-student1 it uses the CSI OpenEBS driver
Deployment Steps
To deploy NuoDB in Kubernetes, we will use Helm Charts. NuoDB Helm Charts are production ready and fully support day two operational tasks such as backup and restore, continuous upgrade, and can be deployed in multi-cloud and multi-cloud environments.
Disable Linux Transparent Huge Pages on all cluster nodes that will host NuoDB pods.
Run the following commands on each node of the cluster (or deploy a Terraform script for example …) :
Add NuoDB Helm Charts repository
Create the nuodb namespace to install the NuoDB components
Install the NuoDB Admin domain administrative tier with monitoring and specified storage class
NuoDB Admin (nuoadmin) is NuoDB’s domain and database management tier as of release 4.0. NuoDB Admin provides the following benefits:
- Simplification of operational tasks when running NuoDB Command (nuocmd) which supports command line completion and provides online help for commands and options.
- Improved database availability and reliability in the event of common network delay and failure scenarios.
- Improved domain and database health and root cause information to help diagnose error conditions and restore operations quickly.
- In containerized management environments, such as Kubernetes, process error detection and self-healing is automatic resulting in zero downtime.
When using NuoDB Admin, use the NuoDB Command nuocmd command line interface to control, monitor, and analyze a NuoDB domain. For information on using NuoDB Command and other NuoDB utilities, see Command Line Tools.
Verify the pods are running :
Verify the connected states of the database domain
Install the NuoDB database Storage Manager (SM) and Transaction Engine (TE) components
Verify the pods are running:
Verify the connected states of the database domain:
To scale the TEs, run the following command:
we will have two TE processes :
Create A New Database
We have a database that has been created at installation that is called demo we will create another database: hockeydb01. We will use the helm charts (used previously to deploy our demo database)
Run the following command :
Verify the pods are running:
We have our SM and TE processes started for the chart database02.
Let’s check the connection of the database hockeydb01 to the domain demo
Populate your Database
NuoDB comes with a sample database, which contains North American ice hockey data. It is located in /opt/nuodb/samples/quickstart/sql in our pod sm-database02-nuodb… and we will use these SQL files to populate our new database with field hockey data.
Copy the SQL directory from the sm-database02-nuodb… pod to the admin-nuodb-cluster0-0 pod or download this file : https://github.com/colussim/ansible-aws-k8s/raw/main/NuoDB/nuodbdatabase.tar and copy and decompress the file in the /home/nuodb/ directory of the admin-nuodb-cluster0-0 pod.
You can execute the following commands (for example from the master node) :
We will use the command line utility delivered with NuoDB : nuosql We will use the sql script : create-db.sql
Load DATA
Explore your Database using SQL Commands
NuoDB supports a rich and comprehensive set of SQL features, which includes the full ANSI SQL standard as well as additional procedural extensions. It also provides a typical SQL database permission model, allowing you to control who or what roles are allowed to perform actions on a schema, table, view or procedure.
Enter the NuoDB SQL tool by specifying the database you are accessing, your username, and password:
Use the show schemas command to take a look at what schemas our database includes:
Show the tables in that schema :
Show number of entries in HOCKEY table :
We can also have information about our configuration: number of connections, number of nodes (TE and SM process) :
You can also connect with your favorite graphic tool like DBeaver or DbVisualizer
We are going to open an ssh tunnel on the listening port of our TE process linked to our hockeydb01 database.
Our TE process binds to the address : 10.44.0.4:48006
Our ssh tunnel command will be as follows :
we connect with the public ip address of our master node.
In my test I use DBeaver, and I use as connection string:
- host : localhost
- port : 48006
- database : hockeydb01
- user : dba
- password : default_password : secret
Conclusion
As an elastic SQL database, NuoDB was conceived fundamentally as a peer-to-peer distributed architecture that provides database services. So, it appears as a single logical ANSI SQL database to the application, and that makes it very straightforward and easy for developers to work with. In future posts we will see the Scale-Out, Continuous Availability and monitoring part
Next Step
Scale-Out, Continuous Availability