Graphic tutorial of building centos8 virtual machine cluster with VMware Workstation Pro 16

Time:2022-5-27

In our daily study and work, we often need to use distributed cluster environment, such as Nacos cluster, MySQL Cluster, zookeeper cluster, redis cluster, big data cluster, etc., but usually there are not so many physical machines to use. Therefore, it is a good choice to build a set of distributed cluster environment through virtual machine for development and testing. Today, let’s try to build a cluster of CentOS 8 using VMware under Windows 10.

preparation

Hardware environment: since the virtual machine is installed, the hardware configuration of the physical machine itself should not be too low. The environment used by the author is a desktop computer with windows10 64 bit, i7 32g 256g SSD + 1t hard disk.

Software installation package: VMware Workstation 16, centos-8.2.2004-x86_ 64-dvd1. iso。

Installing VMware Workstation Pro 16

VMware Workstation is a very easy-to-use virtual simulator. Its powerful functions and convenient use methods make it the most used virtual machine brand in the world

1. Download VMware Workstation Pro 16 and centos8 installation packages from the official website;

在这里插入图片描述

2. Double click the mouse to run vmware-workstation-full-16.1.0-17198959 Exe starts installation;

3. Enter the installation interface and click [next]

在这里插入图片描述

4. First check “I accept the terms of the license agreement”, and then click [next]

在这里插入图片描述

5. Select the software installation path, which is installed on Disk C by default. Click [change] to modify the installation path. Note: the name of the installation path folder cannot contain Chinese characters!

在这里插入图片描述

Here, install the software in the folder of disk D, and then click [next]

在这里插入图片描述

6. Uncheck “check at startup…” and “join VMware…”, and then click [next]

在这里插入图片描述

7. Click [next]

在这里插入图片描述

8. Click [install]

在这里插入图片描述

9. The installation is in progress. This process will take about 1 minute. Please wait patiently

在这里插入图片描述

10. After installation, VMware Workstation Pro will be installed here

在这里插入图片描述

Creating a Linux virtual machine

1. Click create new virtual machine

在这里插入图片描述

2. Select custom (Advanced) configuration and click Next directly

在这里插入图片描述

3. Select the default workstation 16 when selecting virtual machine hardware compatibility 10. Click next

在这里插入图片描述

4. Choose to install the operating system later and click next

在这里插入图片描述

5. Select Linux as the operating system of the client, CentOS 8 64 bit as the version, and click next

在这里插入图片描述

6. Fill in the name of the virtual machine, specify the installation location of the virtual machine (it is not recommended to install to Disk C), and click next

在这里插入图片描述

7. Processor configuration: I choose 2 cores here, which can be modified as needed. Click next

在这里插入图片描述

8. Virtual machine memory. Because I have enough memory, I choose 4G, which can be modified as needed. Click next

在这里插入图片描述

9. Set the network type as the default NAT and click next

在这里插入图片描述

10. Select the I / O controller type, select the default LSI Logic here, and click next

在这里插入图片描述

11. Select the disk type, select the default SCSI here, and click next

在这里插入图片描述

12. Select create new virtual disk here and click next

在这里插入图片描述

13. I choose 40g disk capacity here. Others are default. Click next

在这里插入图片描述

14. Set the disk file location and click next

在这里插入图片描述

15. Ready to create virtual machine, click finish

在这里插入图片描述

16. Click Edit virtual machine settings in the main interface, select the downloaded centos8 image file, and click OK to create the virtual machine

在这里插入图片描述

Set network mode

VMware provides us with three network working modes: bridged mode, NAT mode and host only mode.

Open VMware virtual machine, we can see vmnet0 (bridge mode), VMnet1 (host mode only), VMnet8 (NAT mode) in the “virtual network editor” under “Edit” in the option bar. What are the functions of these? In fact, vmnet0 we see now represents the virtual switch used in the bridge mode; VMnet1 represents a virtual switch used in host only mode; VMnet8 represents a virtual switch used in NAT mode.

NAT (network address translation mode)

Here we use nat (network address translation mode), open VMware, click “virtual network editor” under “Edit”, and click change settings

在这里插入图片描述

Set the option of NAT mode in virtual machine, and set NAT parameters and DHCP parameters.

在这里插入图片描述

Nat settings

在这里插入图片描述

DHCP settings

在这里插入图片描述

Installing centos8

1. Click “start this virtual machine”

在这里插入图片描述

2. If an error is reported, this host supports Intel VT-x, but Intel VT-x is disabled

在这里插入图片描述

VMware prompts that this host supports Intel VT-x, but Intel VT-x is disabled. What’s the matter? The full name of Intel VT-x is Intel virtualization technology, which is Intel virtual technology. Enabling it allows the hardware platform to run multiple operating systems at the same time is one of the necessary technologies for the operation of virtual machine software. If disabled, the prompt “this host supports Intel VT-x, but Intel VT-x is disabled” will pop up. The solution is to enter the BIOS and start Intel virtualization technology. You can refer to this link for solutions http://www.xitongcheng.com/jiaocheng/xtazjc_article_38955.html , different brands of models have different solutions

3. Enter the system installation page – > select Install cientos8 Linux 8 and wait a moment

在这里插入图片描述

4. Language setting: set it according to your preferences. I choose Chinese here and click continue

在这里插入图片描述

5. Summary of installation information. Here, you need to set the installation destination, network and host name, time and date

在这里插入图片描述

Enter the installation target location interface and click finish

在这里插入图片描述

Network and host name (it’s better to turn on the network, otherwise it’s hard to configure later)

在这里插入图片描述

Set the host name and click apply

在这里插入图片描述

Time and date, set to Asia / Shanghai

在这里插入图片描述

The interface after setting is as follows. Click to start installation

在这里插入图片描述

During the installation process, the waiting time is a little longer, about 10 minutes. Users and passwords can be configured

在这里插入图片描述

It’s convenient to remember here. Set the root user password to root and click finish

在这里插入图片描述

After installation, click restart

在这里插入图片描述

Set license

在这里插入图片描述

Check I agree to the license agreement and click finish

在这里插入图片描述

Return to the initial setting interface and click to end the configuration

在这里插入图片描述

Log in to the user, enter the system configuration, and click forward

在这里插入图片描述

Turn off the location service and click forward

在这里插入图片描述

Click online, skip account

在这里插入图片描述

Set the full name and user name (for login later), and click forward

在这里插入图片描述

Set the password (for login later). To facilitate memory, set it as root here, and then click forward

在这里插入图片描述

Click Start

在这里插入图片描述

Check the network connection, enter the interface, open the terminal and check the IP address

在这里插入图片描述

Test network

在这里插入图片描述

Other configurations

Change the server to static IP

Modify to static IP, and modify the configuration corresponding to bootproto and onboot


vim /etc/sysconfig/network-scripts/ifcfg-ens33 

在这里插入图片描述

Restart the network after modification


nmcli c reload ifcfg-ens33

View firewall status


systemctl status firewalld

在这里插入图片描述

Turn off the firewall

Turn off the firewall


systemctl stop firewalld

在这里插入图片描述

Set startup not to start firewall


systemctl disable firewalld

在这里插入图片描述

View startup items

在这里插入图片描述

Replace with Alibaba cloud Yum source

Due to the domestic network, if your server is in China, the speed of installing some software on CentOS may be very slow, so we need to change the system software source

It is recommended to change the yum source to a domestic source, such as Alibaba cloud, as follows:


yum install wget -y
yum install curl -y

backups


mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
mv /etc/yum.repos.d/CentOS-PowerTools.repo /etc/yum.repos.d/CentOS-PowerTools.repo.backup
mv /etc/yum.repos.d/CentOS-Extras.repo /etc/yum.repos.d/CentOS-Extras.repo.backup
mv /etc/yum.repos.d/CentOS-centosplus.repo /etc/yum.repos.d/CentOS-centosplus.repo.backup
mv /etc/yum.repos.d/CentOS-AppStream.repo /etc/yum.repos.d/CentOS-AppStream.repo.backup

All the above documents need to be renamed because Ali YunyuanCentos-8.repoAll the above documents are included. If you follow the traditional method, only change themCentOS-Base.repoA prompt will appear in this file


Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration

Change to Alibaba cloud


wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

Run Yum makecache to generate a cache


yum clean all
yum makecache

Install JDK

Jdk-8u191-linux-x64 tar. Put the GZ installation package into the / usr / local directory and unzip the installation package


tar -zxvf jdk-8u191-linux-x64.tar.gz

Configure environment variables


vi /etc/profile

Add environment variables for configuring Java


JAVA_HOME=/usr/local/jdk1.8.0_191
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME PATH CLASSPATH

Reload environment variables


source /etc/profile

Check whether the installation is successful


java -version

Build cluster environment

Clone virtual machine

Create virtual machine snapshot for backup

Right click the virtual machine, click snapshot, and then click take snapshot

Fill in the name and click take snapshot to complete the snapshot creation

在这里插入图片描述

Turn off the virtual machine, right-click the virtual machine, click power, and click turn off client

在这里插入图片描述

Shut down the virtual machine, right-click the virtual machine, stand-alone “management” – “clone”

在这里插入图片描述

Click “next”

在这里插入图片描述

Set the Clone Source and click next

在这里插入图片描述

Set the clone type, select create complete clone here, and click next

在这里插入图片描述

Set the virtual machine name and location, and then click finish

在这里插入图片描述

After cloning, click close

在这里插入图片描述

Repeat the steps above to create a virtual machine slave2

This is how cloning is done

在这里插入图片描述

Adjustment test

So far, we have created a total of three virtual machines. The configurations of these three virtual machines are identical. Therefore, as the most basic available cluster, we need to make some minor adjustments.

We put centos-8_ 64-slave1、CentOS-8_ 64-slave12 the IP addresses of the two machines are modified to192.168.138.9192.168.138.10, refer to the previous for specific operationModify to static IP, and modify the configuration corresponding to bootproto and onboot

Modify the hostname of three virtual machines. Modify to master, slave1, slave2


hostnamectl set-hostname slave1

Restart the virtual machine


reboot

The result is this

Corresponding IP of Master: 192.168.138.8

在这里插入图片描述

Slave1 corresponding IP: 192.168.138.9

在这里插入图片描述

Slave2 corresponding IP: 192.168.138.10

在这里插入图片描述

There is no problem for the master to Ping the IP corresponding to slave1 and slave2

在这里插入图片描述

So far, the cluster of three virtual machines of master, slave1 and slave2 has been built

The author accesses the three virtual machines through mobaxterm. For the time being, there is no need for secret free login between clusters. If so, we can handle it by ourselves.