The reason why I have chosen VirtualBox over VMware is that the former is free of cost and is available for Microsoft Windows, Linux, and MacOS, while a full version of the latter costs money.
Other than that, you will also need to ensure that your virtual machine has two network interface cards. The first one is created by default while the second one has to be created manually.
To display the current network configuration for a VM, click on it in Virtualbox's main interface and then on the Settings button. A popup window will appear with the list of the different hardware categories. Choose Network and configure Adapter 1 to Bridged Adapter, as shown in the following screenshot:
Setting up the network infrastructure
Since our nodes will communicate between each other over the network, we will first define our network addresses and configuration. Our rather basic network infrastructure will consist of two CentOS 7 boxes with static IP addresses and host names node01 [192.168.0.2]
and node02 [192.168.0.3]
, and a gateway router called simply gateway [192.168.0.1].
In CentOS, all network interfaces are configured using scripts in the /etc/sysconfig/network-scripts
directory. If you followed the steps outlined earlier to create a second network interface, you should have a ifcfg-enp0s3
and ifcfg-enp0s8
file inside that directory. The first one is the configuration file for the network card that we will use to access the Internet and to connect via SSH using an outside client, whereas the second will be used in a later chapter to be a part of a cluster resource. Note that the exact naming of the network interfaces may differ a little, but it is safe to assume that they will follow the ifcfg-enp0sX
format, where X
is an integer number.
This is the minimum content that is needed in the /etc/sysconfig/network-scripts/ifcfg-enp0s3
directory for our purposes in our first node (when you set up the second node later, just change the IP address (IPADDR)
to 192.168.0.3
):
Note that the UUID
and HWADDR
values will be different in your case as they are assigned as part of the underlying hardware. For this reason, it is safe to leave the default values for those settings. In addition to this, beware that cluster machines need to be assigned a static IP address—never leave that up to DHCP! In the configuration file used previously, we are using Google's DNS but if you wish to, feel free to use another DNS.
When you are done making changes, save the file and restart the network service in order to apply them. Since CentOS, beginning with version 7, uses systemd instead of SysVinit for service management, we will use the systemctl
command instead of the /etc/init.d
scripts to restart the services throughout this book, as follows:
You can verify that the previous changes have taken effect using the following command:
You can verify that the expected changes have been correctly applied with the following command:
You can disregard all error messages related to the loopback interface as shown in the preceding screenshot. However, you will need to examine carefully any error messages related to enp0s3
, if any, and get them resolved in order to proceed further.
The second interface will be called enp0sX
, where X
is typically 8
, as it is in our case. You can verify this with the following command, as shown in the following screenshot:
As for the configuration file of enp0s8
, you can safely create it copying the contents of ifcfg-enp0s3
. Do not forget, however, to change the hardware (MAC) address as returned by the information on the NIC by the ip link show enp0s8
command and leave the IP address field blank now, using the following command:
Next, restart the network service as explained earlier.
Note that you will also need to set up at least a basic DNS resolution method. Considering that we will set up a cluster with two nodes only, we will use /etc/hosts
in both hosts for this purpose.
Edit /etc/hosts
with the following content:
Once you have set up both nodes as explained in the following sections, at this point and before proceeding further, you can perform a ping as a basic test for connectivity between the two hosts to ensure that they are reachable from each other.
To begin, execute in node01
:
Next, do the same in node02
: