So you want to learn about coding, huh? Maybe you’re looking at becoming a software developer or software engineer. This is the blog for you! I’m hoping to give you the 10,000 foot view of coding.

Be sure to check out the sponsor of this post, Pramp, where you can get the best preparation for technical interviews.

Code is the basis for every software application. An application is anything that runs on a computer. This includes any websites you visit, games you play, apps you use, etc. Software is now embedded in almost everything, such as all modern day vehicles.

Coding is done with programming languages. There are a ton of computer programming languages: C, C++, C#, Java, Python, Go, Scala, F#, Ruby, etc. Each computer programming language is slightly different and each one has their own keywords.

Coding can be described as a black box. This means that the user does not have to worry about what is going on behind the scenes of an app. If a user opens an iPhone app, they do not care about the code. All they care about is that when they click a button (input), something happens (output).

When something is described as a black box, it is an example of an abstraction. An abstraction hides the inner detail and the user only has to worry about the interface, or how to interact with the program.

There are two primary types of interfaces: a CLI (command line interface) and a GUI (graphical user interface).

A CLI allows the user to interact with your application through commands. This is often done in either a unix terminal or a windows command prompt:Appleterminal2Your code will output different things depending on the input given through the CLI.

One of the primary benefits of a CLI is that you can write scripts to interact with your program.

The alternative to a CLI is a GUI, which graphically allows the user to interact with your application through buttons. A perfect example of this would be essentially any app you use on a mobile device, game, etc.

Coders tend to like programs that have a CLI because they can execute commands against the application themselves or create a script to do it for them. Non-coders prefer a GUI as it makes working with the application much easier.

The application that has an interface that can be programmed against is said to have an API. An API (application programming interface). An API will have various commands that can cause the application to do something (this is very similar if not the same thing to a CLI, but you may not interact with it through a terminal). A simple example of an API would be the Twitter API. The Twitter API opens up commands that can be executed programmatically (through another application).

Each command available through the API is known as an API endpoint. Applications will be written to take advantage of these API endpoints. A common example of this would be an application that monitors Twitter accounted through the Twitter API and ranks them socially. Another example would be an application to schedule tweets.

This is a good intro, but now I suggest you Jump into part 2.

In the previous blog we created a table in Db2. The table is created, but now we want to put data into that table. This is done through an INSERT statement. Before we issue an INSERT statement though, we must first know the columns of our table.

Table Structure

We can find the details on this table in DSM by going to administer -> Tables

Administer Tables

So far we've learned about the very basic concepts of Db2, but now I want to dive in a bit and work with tables. Some of the material in blog may take a few more blogs to fully understand, but that is okay. The goal is to get you started. Later we will come back and learn all the details.

SQL

We will be using SQL (Structured Query Language) to communicate to our database. DSM (Data Server Manager) is the UI (user interface) that we can use to work with our database, but we should do as much as we can with SQL. Why use code when there is a user interface? I'm glad you asked.

The user interface is a great way to work with our database, don't get me wrong. The problem with using the UI exclusevely is that you are limiting your usefulness. When writing an application that interfaces with the database, you are going to have to use code.

Additionally, SQL is a standard language that is used widely by other databases. As a developer, it is important to learn the information that is going to transfer between technologies. If we learn the SQL standard, we can easily work with Db2, Oracle, SQL Server, MySQL, etc, all of which are based on the SQL standard. 

How to Use SQL in DSM

There will be a panel on the left containing a button Run SQL that will open a window similar to this one:

SQL Button

Before building a database for yourself or a corporation, you need to understand a bit about database structure.

We are going to go in some depth on how to design a database, which deals with structuring your database the best way possible. However, I thought it would be appropriate to give an overview of the Db2 structure and start using the database right away.

Once we have the fundamentals down, we are going to then go back to database design to learn the details. This will allow us to more concretely discuss database design because we’ve already had some experience with the fundamentals.

The very first thing that you need to know is that data is organized into different tables. We first discussed tables in the Introduction to Db2. Each table describes one type of thing (for example, users). You should see the table as the blueprint describing how the data should be structured. Each row is an instance of whatever the table describes.

When we discuss database design, we will fully understand how to break up our data into different tables. For now, the important thing to understand is that a database consists of multiple tables related to one another.

First off, what is a database? A database stores data, which is any information that might be of use to a company.

Db2 is a database created by IBM that is best known as an enterprise database, so we are talking about a database used by huge companies who have more data than they know what to do with. The great part for us is that that there are multiple editions of Db2 going all of the way up to the enterprise editions, but actually starting with a completely free version. That’s what I’ll be using.

So back on the topic of data. A database will often be used behind the scenes when you are using some software. Anytime you put information in software that you can access at a later time, that information will be stored in a database.

database and website

After signing up, a welcome email will be sent to your inbox giving you access to all of the available study guides.

We are finally to the cool part of the series!

ClusterControl allows us to do custom monitoring and automation through scripts that can be run regularly. These scripts are run through a tool called Developer Studio.

To begin looking at this, open your cluster and when you are in the cluster overview, hover over Manage and click Developer Studio.

From here you will see a ton of scripts that were already built into ClusterControl.

For example, s9s -> mysql -> schema -> schema_check_nopk.js.

In schema_check_nopk.js, you will find a comment describing what it does.

db clustering dsl

In this article, I'm going to talk about load balancers and guide you through installing ProxySQL. Now, this is only a light introduction with just enough information to get you started.

The Purpose of a Load Balancer

A load balancer is like another addition to your database that adds a layer of magic.  The load balancer is a piece of software that will automatically balance how much each node is being hit to protect from overworking a particular node and slowing down the entire database cluster.

If you do not have a load balancer, and you were writing a software application, you would manually decide what nodes to read and write from.  This is not always good because you might not know ahead of time how well a particular node is going to keep up with your demands.

With a load balancer, you make every piece of code talk to the load balancer, and then the load balancer will distribute the demands across the nodes.

The load balancer of choice is ProxySQL.

We’ve got most of the theory figured out, we managed to get a bunch of virtual machines up and running, and we even installed ClusterControl, but now it’s time for the fun part. We are going to create our first cluster!

Getting Started

If not open already, travel to the webpage you made your admin email and user name on in the last previous blog. The website will be:

localip/clustercontrol/

For example, mine is: 10.71.34.101/clustercontrol/

Once you get there, the "Welcome" page should show up. If not, open it by either clicking the "Get Started" button or the "Deploy" icon.

In this blog, we're finally going to install ClusterControl! It's taken us a long time to get to this point, but now we have a good foundation on which to work from.

Before we begin, open up your three virtual machines, and use the one we named "ClusterControl" to install ClusterControl onto.

Installation

One way to install ClusterControl is to follow the guide on their website.  That way you get the most up-to-date information. Alternatively, follow my simplified guide by reading this blog!

The commands are pretty easy; just copy and paste.

First, go to the virtual machine that we will be installing ClusterControl on and open a terminal.

The first command to run is:

In this blog, we will be setting up passwordless SSH in our virtual machines.

In order for ClusterControl to work, it must be able to communicate seamlessly with all of the nodes in a cluster. Passwordless SSH will allow this to happen.  This blog will guide you through the process, but there is also a video that might be easier to follow for this complex process. Whichever floats your boat!

Before we begin, have all three of your virtual machines up and running, and, to make it things a little easier on you, change the backrounds of each so that you can easily distinguish between them.

Getting the IP Addresses

The first thing we need to do is get the IP addresses of all three virtual machines.

We will start with the machine that will be running ClusterControl. Our goal is to see if we can communicate with all of the other machines.

Open a terminal and run:

In our process of setting up a database cluster, we are going to need multiple machines each with a database instance installed. As a reminder, these instances are called nodes. To save time and resources, we are going to be using virtual machines for each one of our nodes.

To do this we are going to need to install VirtualBox.

Once we have VirtualBox installed, we need to download the operating system. Now, if you are learning this material to apply it to a production environment, you will want to make sure a particular clustering software is available on the right operating system. For example, the Oracle Galera cluster is currently not offered on odd versions of Ubuntu; it is only offered on even versions.