Computer Process
When we start one program (e.g., Excel), we'll start one process.
Process occupies part of a CPU, part of memory and can only see files that are opened by that process. In that way, process is like a small virtual machine. Excel process is working inside of such small virtual machine and can only access workbooks that we have opened inside of that Excel (e.g., Book1.xlsx and Book2.xlsx). The purpose of a process is to isolate one program from everything else.
Processes, Daemons and Services
We can divide processes into 4 groups:
- User process is a process with a friendly interface toward human users ( like Notepad.exe ).
- Daemon process is a process with a friendly interface toward other programs ( "Windows Time" (w32time) service ).
- Service is a daemon which provides interface to some essential functionality. For example, Apache server is a service because through it we get our web pages. In the background, Apache server will pull needed data from the MySQL database which is another daemon. In this setup, Apache server is a service daemon, and MySQL database is a normal daemon.
- Some processes are in between. Microsoft Outlook is a user process dominantly, but it also has an VBA api, so it is partially a daemon.
We can see that the major difference between these processes is stemming from their indented usage. Usually, daemons will start when the OS starts and they will work in the background without users' interaction. On the other side, daemons can also be started manually and users can interact with them. We have already saw an example of such, manually started, daemon:
monetdbd start /home/fffovde/DBfarm1
monetdbd
get all /home/fffovde/DBfarm1
Official Processes
In the "real world" other definitions are used. Something is a daemon or service only if it is officially registered with the operating system. Only processes registered in "Systemd" on Linux systems are called Daemons. In Windows, only processes registered in SCM (Service Control Manager) are called Services.
Systemd and SCM are operating system components used to automatically start official daemons and services in the correct order, control resource usage, access rights, log, and restart failed services. From an OS perspective, this is the only way to distinguish between processes. Since Windows and Linux use such definitions, most people will also use those definitions.
Two Ways to Manually Start Monetdbd Daemon
We will first check that Monetdbd daemon is not working. "pgrep " command is "process grep ". We are searching the process by its name. Pgrep should return ID of a monetdbd process, but our process is not active. | pgrep monetdb |
We will then start our server using systemctl. "Systemctl " is a console program used to control "Systemd ". We already saw that systemd is OS component used to control daemons.sydo systemctl start monetdb " Pgrep " command will confirm that our MonetDB server is now working.pgrep monetdbd |
We can also start monetdbd daemon with the "start " command. This will fail because our daemon is already working.monetdbd start /home/fffovde/DBfarm1 |
The explanation is that when we open monetdbd with systemctl, two things will happen:
- Systemctl will start the daemon, but not "
/home/fffovde/Dbfarm1
", this server will not start. This is because systemctl will start the default server. The default server is on the location "/var/monetdb5/dbfarm
". - The server "
/etc/monetdb5/dbfarm
" will occupy the port 50.000. That is why we are getting an error "cannot remove socket files".
We will now just stop the monetdbd daemon using systemctl to release the port 50.000.sudo systemctl stop monetdb Only after that we will be able to start our other server manually. monetdb |
Mserver5
When our database is opened, then the process Mserver5 is working. Currently our database is not opened. We can check that with: pgrep mserver5 . |
There are two ways how to start database. One is to use monetdb console program. Just like systemctl console program is used to control system daemon systemd, in the same way monetdb console program is used to control monetdb daemon monetdbd. monetdb start voc pgrep mserver5 |
The other way is to just call database from mclient. I will first stop the database with "monetdb stop voc ", and mserver5 will close.pgrep mserver5 #we can see that mserver5 is stoppedI'm closing the database just to show you that we can also open the database with the mclient. mclient -u voc -d voc |
We can exit mclient applicaton with "quit". We will only close client application, but the database will remain open. We can check that with pgrep command and we will see that our database is still opened:pgrep mserver5 |
When we login to the voc database with mclient, at that moment the database will be opened if it is not already open. When our database is opened, process Mserver5 is also working. This is because Mserver5 process is OUR DATABASE. This process will perform all processing on request of clients for a database voc. Mclient console application is used to send our queries to this Mserver5 process.
Starting the Monetdbd Daemon When the Computer Starts up
We can not start "/home/fffovde/Dbfarm1
" server automatically when the computer boot up. We can only do that with the default server "/var/monetdb5/dbfarm
". First we will stop "/home/fffovde/Dbfarm1
" server to release the port 50.000:
monetdb |
Then we will start "/var/monetdb5/dbfarm " server.systemctl start monetdbd |
Next, we will create a new database, and we will open mclient application to test it:monetdb create newDB (password is monetdb for the admin group monetdb) |
Now that we have confirmed that our database is working, we will make our "/var/monetdb5/dbfarm " to a full fledged systemctl controled daemon. This will make our server to open automatically after each system boot. |
systemctl enable monetdb |
Now we can exit everything and we can reboot our computer.
After restarting, our server will open automagically:pgrep monetdbd |
Avoid Entering Credentials Every Time
Inside of our home folder "/home/fffovde ", we can create textual file ".monetdb ". Inside of this file we can type our password and username:user=monetdb password=monetdb After that we don' have to type our credentials any more. We just have to type this, and we are in. mclient -d newDB |
Running Two Servers at the Same Time
Server "/var/monetdb5/dbfarm " is blocking the port 50.000. While this server is opened, we will not be able to use server "/home/fffovde/Dbfarm1 " because that other server is also using the port 50.000. |
First, we will change the port of the "DBfarm1" server: monetdb |
Now, we are able to start manually our DBfarm1 server:monetdb For mclient application we have to provide our new port number: mclient -p50001 -u voc -d voc |
Cleaning up
First, I will exit the mclient application with the quit command. I will close and disable " /var/monetdb5/dbfarm " server. Disabling means that the server will no longer open automatically. systemctl stop monetdb I will change port number of " /home/fffovde/DBfarm1 " server back to 50.000. monetdb Then, I will close " /home/fffovde/DBfarm1 " server. monetdb | After this I will continue to use " /home/fffovde/DBfarm1 " and "voc " database. I will allway use commands:monetdb |
Summary
We can open the server manually or automatically. To open it manually, we use "monetdbd start
". For automatic startup we use "systemctl
". We can only automatically open the server "/var/monetdb5/dbfarm
". If we use two servers at the same time, they must have different port numbers.
In MonetDB, the databases are quite independent. In Microsoft SQL server things are different. SQL server can have many databases that are sharing many resources. They are sharing logins, tempdb, resource pools, memory settings, collation. Backups, replication, and monitoring tools (like SQL Agent jobs) are often configured at the server level.
Because of that it is correct to say that Mserver5 process is not just a database, it is a whole server. Monetdbd is not really a server. That daemon is only a managing tool for Mserver5 processes. Almost the only thing databases within the same dbfarm folder share is their port number. So, "voc
" and "newDB
" are monetdb servers. "/home/fffovde/DBfarm1
" and "/var/monetdb5/dbfarm
" are just folders for those servers.
Monetdb is console application used by a user to interact with montdbd daemon.