CloudStack+KVM virtual machine deployment test detailed process

catalogue

Basic introduction

Deployment preparation

Start deployment

1. View and modify virtual machine network

2. Create a manager node

2. Configure the manage node

2. Clone as agent node

3. Configure NFS service

4. Install MySQL service

5. Set up network bridging

6. Install CloudStack

(1) Network source

(2) Local source

7. Configure CloudStack

8. Create a resource domain

9. Register ISO, add instances, and create templates

Possible problems

Basic introduction

This paper aims to introduce how to deploy a set of CloudStack environment test process in the native virtual machine, including a manager and a computing node. Among them, the manager node will build the NFS service as secondary storage, and the agent will build the nginx server for image download.

This article uses KVM to create virtual machines and manages them through libvirtd.

Deployment preparation

Software installation:

VMWare Workstation,XShell

Resource download:

CentOS-7-x86_64-Minimal-1810.iso / / system image

cloudstack-common-4.13.1.0-1.el7.x86_64.rpm

cloudstack-management-4.13.1.0-1.el7.x86_64

cloudstack-agent-4.13.1.0-1.el7.x86_64.rpm

systemvmtemplate-4.11.3-kvm.qcow2.bz2

Baidu cloud sharing links of all resources used in this article: https://pan.baidu.com/s/1AiuZUF5JvudgIgFjc_8j4Q Extraction code: oy3h

Start deployment

1. View and modify virtual machine network

First, open Wmware Workstation, select "Edit - > virtual network editor" in the menu bar, and view the subnet address of VMnet8.

Each machine VMne8t is assigned different subnet addresses. This paper takes the local "191.168.100.0" network segment as an example.

In this network segment, the default IP address of the machine is "192.168.100.1", and the default IP address of the gateway is "192.168.100.2".

If you want to change the network segment, you can click "change settings" in the lower right corner to open the virtual network editor with administrator privileges and modify the subnet IP in the lower left corner.

The default DHCP assigned IP range is 128-254, which can be adjusted by clicking "DHCP settings". The adjustment in this paper is as follows.

The information to remember is as follows:

Address range: 192.168.100.100-192.168.100.254
 Gateway: 192.168.100.2
 Subnet mask: 255.255.255.0

2. Create a manager node

This paper first creates the virtual machine of the manager node. After installing the necessary software, it will clone the virtual machine as the agent node, and then deploy their own nodes respectively.

The manager node IP is set to 192.168.100.100

The agent node IP is set to 192.168.100.101

Create a new virtual machine in the VmWare Station. In the new wizard, select typical, install the operating system later, Linux, CentOS 7 64 bit.

Name the virtual machine Manager to avoid confusion.

The disk capacity is 20G by default. In the last step, click "customize hardware" and configure it according to the following figure.

The recommended memory of the Manager node is 2G, with two processor cores. Turn on Intel VT-x/EPT, load the iso image of CentOS in the CD drive, and make sure that the connection at startup is checked. Then delete the redundant sound card and printer hardware, click "close" and click "finish".

Edit the virtual machine settings again and click add in the lower left corner to add a hard disk.

Add new hard disk

Click "next" all the way, and finally complete the addition of new hard disk.

Start the virtual machine and start the image installation. Click the virtual screen, press the up and down keys to select "Install CentOs 7" to enter the visual installation interface.

The first step is to choose Chinese.

Select "Chinese"

Click "continue", wait for the dependency retrieval to complete, and configure "installation location", "network and host name" in turn.

Configure installation location
Configure network and host names

Set the IP address "192.168.100.100" of the manager node and configure the Alibaba DNS server. Click save and finish.

Configure "ens33"

   

Click "start installation".

Installation in progress

 

During installation, set the ROOT password, which is set to 12345 in this article. If the password is too simple, click twice to complete the setting.

After installation, restart.

2. Configure the manage node

Open XShell and create a new session.

Click "user authentication" and enter the root and root passwords.

Save and connect, verify the host key, and select accept and save.

Complete the following configuration in XShell.

(1) Set IP mapping

After setting, you can directly access the corresponding node through Hostname.

Copy the instruction into the XShell session box and press enter to execute.

vi /etc/hosts

Insert the following in a new line of the file:

192.168.100.100 manager
192.168.100.101 agent

Tips

Press the I key to enter the INSERT mode.

Press ESC, enter ": wq!" to save and exit, and enter ": q!" to exit without saving.

Press ESC and double-click D to delete the line where the cursor is located.

(2) Turn off the firewall

systemctl disable firewalld
systemctl stop firewalld

Then set selinux to permissive mode

Modify config file

vi /etc/selinux/config 

Find selinx and change to

SELINUX=permissive

Restart effective

reboot

View selinux

getenforce 

(3) Time zone setting (not necessary)

timedatectl set-timezone  Asia/Shanghai

View time zone

timedatectl

(4) installation of EPEL

yum -y install epel*

Rebuild local warehouse cache

yum clean all && yum makecache

Install VIM for editing files.

yum -y install vim

Install lrzsz to send files to the virtual machine.

yum -y install lrzsz

(5) Install time synchronization module

yum -y install chrony

Modify profile

vim /etc/chrony.conf

Change the server to Alibaba cloud time synchronization server

Find the following four lines

server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

Change to

server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst

Restart the chronyd service

systemctl restart chronyd

(5) Installing services for NFS

yum -y install nfs-utils

Edit profile

vim /etc/sysconfig/nfs

Uncomment the following items. Among them, rquote_ Port needs to be added manually.

LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
RQUOTAD_PORT=875
STATD_PORT=662
STATD_OUTGOING_PORT=2020

Start the service and set the startup.

systemctl enable rpcbind
systemctl start rpcbind
systemctl enable nfs
systemctl start nfs

View new hard disk

fdisk -l

Format hard disk and establish ext4 file system

mkfs.ext4 /dev/sdb

So far, the general configuration of the two nodes has been completed.

2. Clone as agent node

Close the manager node, right-click the manager node in the library, and select Manage - > clone to enter the clone virtual machine wizard.

Select "clone current status", "create full clone", name it "agent", and then click finish.

Because the IP address of the cloned agent node conflicts with that of the manager, it is recommended to modify the static IP address inside the virtual machine first, and then configure it through XShell.

Open the agent virtual machine, enter the account root and password 12345.

Modify host name

vim /etc/hostname

Change manager to agent

Modify IP address

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

Modify IPADDR to 192.168.100.101 as follows.

Restart the virtual machine

reboot

In XShell, create a new session with the name of "agent", the host of 192.168.100.101, the account of root and the password of 12345.

Complete the subsequent configuration in the session of XShell.

3. Configure NFS service

The file has been configured previously. In this step, you only need to set the shared directory. Please pay attention to each operation and its operation node to avoid confusion.

manager node

Create mount point

mkdir -p /export/secondary

Hard disk mount

 echo "/dev/sdb  /export/secondary  ext4 defaults 0 0"  >> /etc/fstab

Quick mount

mount -a

View mount

df -h

give the result as follows

Set shared directory

vim /etc/exports

add to

/export/secondary *(rw,async,no_root_squash,no_subtree_check)

Re import shared directory configuration

exportfs -a

agent node

Create mount point

mkdir -p /export/primary

Hard disk mount

echo "/dev/sdb  /export/primary  ext4 defaults 0 0"  >> /etc/fstab

Quick mount

mount -a

Set shared directory

vim /etc/exports

add to

/export/primary *(rw,async,no_root_squash,no_subtree_check)

Re import shared directory configuration

exportfs -a

Verify sharing

The manager node views the shared directory of the agent

showmount -e agent

The agent node views the shared directory of the manager

showmount -e manager

4. Install MySQL service

manager node

yum -y install mariadb-server mariadb

Edit mariadb configuration file

vim /etc/my.cnf

Add under mysqld module

innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'

bind-address = 0.0.0.0

Start mariadb and set it to boot

systemctl enable mariadb
systemctl start mariadb

Perform database initialization security operations

mysql_secure_installation

If the password is not set initially, press enter to skip, select set password, set it to 12345, remove anonymous users, do not block remote login, etc., and press enter to select the default.

Give root remote login permission

mysql -uroot -p123456 -e "GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY '123456' WITH GRANT OPTION";

5. Set up network bridging

agent node

yum -y install net-tools bridge-utils

Edit the network card bridge file cloudbr

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

The revised content is as follows. Static IP can be modified according to your actual situation.

TYPE=Bridge
BOOTPROTO=none
DEVICE=cloudbr0
ONBOOT=yes
IPADDR=192.168.100.101
NETMASK=255.255.255.0
GATEWAY=192.168.100.2
DNS1=223.5.5.5
STP=yes

Set network card file

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

Revised as follows

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="ad4d6e67-ae59-4a3c-9270-7045700517cd"
DEVICE="ens33"
ONBOOT="yes"
BRIDGE=cloudbr0

Restart network service

systemctl restart network

View bridges and routes

brctl show route -n

So far, the basic environment installation has been completed. It is recommended to take a snapshot to avoid configuration errors in the later stage.

6. Install CloudStack

(1) Network source

manager and agent nodes

Configure the network source file. The configuration of the two nodes is the same

vi /etc/yum.repos.d/cloudstack.repo

Add

[cloudstack]
name=cloudstack
baseurl=http://cloudstack.apt-get.eu/centos7/4.13/
enabled=1
gpgcheck=0

manager node

yum -y install cloudstack-management

agent node

yum -y install cloudstack-agent

(2) Local source

Official download address:

http://cloudstack.apt-get.eu/centos7/4.13/cloudstack-management-4.13.1.0-1.el7.x86_64.rpm
http://cloudstack.apt-get.eu/centos7/4.13/cloudstack-agent-4.13.1.0-1.el7.x86_64.rpm
http://cloudstack.apt-get.eu/centos7/4.13/cloudstack-common-4.13.1.0-1.el7.x86_64.rpm

or

This article provides Baidu cloud download.

In this paper, lrzsz is used to send files. In case of problems, other software such as WinSCP can also be used to send files.

manager node

Drag the cloudstack common and cloudstack management rpm files into the XShell session box and send them to the virtual machine.

Perform the following instructions for local installation.

yum -y install cloudstack-common-4.13.1.0-1.el7.x86_64.rpm cloudstack-management-4.13.1.0-1.el7.x86_64.rpm

If you have any problems during installation or later use, you can view them through the log.

tail -f /var/log/cloudstack/management/management-server.log

Initialize the database and create a new user cloud.

Finally, root: 12345 is the root account and root password. Please modify the password if it is different.

cloudstack-setup-databases cloud:123456@localhost --deploy-as=root:12345

Start management

cloudstack-setup-management

agent node

Drag the cloudstack common and cloudstack agent rpm files into the XShell session box and send them to the virtual machine.

Perform the following instructions for local installation.

yum -y install cloudstack-common-4.13.1.0-1.el7.x86_64.rpm cloudstack-agent-4.13.1.0-1.el7.x86_64.rpm 

manager node

Install KVM template

Install the KVM template in secondary storage. Choose one of the following two methods.

a. Network source installation

/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
-m /export/secondary \
-u http://cloudstack.apt-get.eu/systemvm/4.11/systemvmtemplate-4.11.3-kvm.qcow2.bz2  \
-h kvm -F

b. Local source

Official address:

http://cloudstack.apt-get.eu/systemvm/4.11/systemvmtemplate-4.11.3-kvm.qcow2.bz2

or

This article provides Baidu cloud download.

In the same way as above, just drag in the session.

Note: whether the current folder is root or not, please "cd /root" first, or modify the path in the following code.

/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt  \
-m /export/secondary \
-f /root/systemvmtemplate-4.11.3-kvm.qcow2.bz2 \
-h kvm –F

agent node

Configure libvirt

Edit QEMU VNC configuration file / etc / libvirt / QEMU conf

vim /etc/libvirt/libvirtd.conf

Uncomment or add

listen_tls = 0
listen_tcp = 1
tcp_port = "16509"
auth_tcp = "none"
mdns_adv = 0

Tips

You can press ESC to search with "/ + search words, such as" / listen ".

Configure / etc/sysconfig/libvirtd file

LIBVIRTD_ARGS="--listen"

Restart libvirtd and set it to start automatically

systemctl restart libvirtd
systemctl enable libvirtd

7. Configure CloudStack

The default access port is port 8080 of the manager node IP.

Open a browser to access http://192.168.199.100:8080/client/.

The default account is admin, the default password is password, and the language selected is "simplified Chinese". Log in.

The lower left corner is selected for the first login. I have used it before.

Select "global settings" in the lower left corner to modify the settings.

cpu.overprovisioning.factor 2.0               //CPU over configuration
mem.overprovisioning.factor 2.0               //Memory over allocation, i.e. 2GB to 4GB
secstorage.allowed.internal.sites 0.0.0.0/0   //Download ISO or template from this network segment, and build ngix server later, which can be modified
management.network.cidr 192.168.100.0/24      //The management network segment can not be modified, but there will be alarm information

In the manager node, restart the cloudsatck management service

systemctl restart cloudstack-management

The restart time is long. Please wait patiently. You can observe the log file to understand the startup process.

tail -f /var/log/cloudstack/management/management-server.log

8. Create a resource domain

Log in again, select "infrastructure" in the lower left corner, select "resource domain", and click "+ add resource domain" on the toolbar.

The configuration is as follows.

 

 

Please note that the "add host" step is to add the computing node as the default host of the cluster, not the management node.

 

Click "start resource domain", wait until the creation is completed, and then start it.

9. Register ISO, add instances, and create templates

As follows, wait until the system VM is created successfully, and then start the next steps.

agent node

Create an NGINX server as an image download station.

Install nginx software

yum -y install nginx

Edit nginx configuration file

vim  /etc/nginx/nginx.conf 

In access_ log /var/log/nginx/access. Add log main after the line

autoindex on;# display contents
autoindex_exact_size on;# display files size
autoindex_localtime on;# Display file time

Empty / usr/share/nginx/html directory

circumspect

cd /usr/share/nginx/html
rm -rf *

Put the prepared ISO image in. This article uses the image of the virtual machine, directly drag it into the session box and transfer it to the / usr/share/nginx/html directory.

Restart nginx service and set it to startup

systemctl enable nginx
systemctl start nginx

You can directly access the IP address of the agent node through the browser.

Register ISO

Click "ISO view" - > select "ISO registration" on the left.

Fill in all the information in turn, and the URL can copy the link from the 192.168.100.101 web page.

Click "OK", click the ISO, and click "resource field" to view the status.

After the installation is completed, as shown below.

Add instance

Select "instance" on the left - > Toolbar "add instance".

Select ISO create.

Select the ISO you just registered.

The calculation scheme is Medium, and the allocated memory is 1GB, which can be modified in "service scheme".

The rest of the law can be defaulted, and finally fill in the information.

Start the VM and wait for the VM to be created and run.

Select the virtual machine quick view - > View console.

In the pop-up console web page, install ISO.

The installation process is roughly the same as that of the virtual machine, except that the network only needs to be turned on, and there is no need to set the static IP and host name.

After installation, restart.

So far, an instance that can be used for production has been deployed, and other production environments can be installed later. This paper only tests and installs the system.

Create template

Next, the sample creation template with the production environment will be installed to create more instances.

Close the instance. "Quick view" - > stop.

After waiting to stop, click "view volume".

Select quick view - > create template.

After filling in the information, you can create it.

 

When you add an instance in the future, select this template to create an identical instance.

Possible problems

Q: When installing the software, you always switch the image and don't download it at last. What's going on?

A: DNS server is not configured.

If the bridge is not configured, configure the network

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

Add DNS server

DNS1=223.5.5.5

If the bridge is configured, add DNS to the bridge file.

vi /etc/sysconfig/network-scripts/ifcfg-cloudbr0

 

Q: After the management node is restarted, CloudStack's WEB UI doesn't work. What's going on?

A: Generally, the Server is still starting. Just wait.

You can troubleshoot the problem by viewing the log.

tail -f /var/log/cloudstack/management/management-server.log

 

Q: The system VM creation fails, and the log shows "can't create development for vm". Why?

A: There are two possible reasons for this:

1. Insufficient hardware resources of agent node

The proposed 4GB memory plus 2 cores and 2 times over allocation can fully meet the requirements after many tests.

2. KVM template is not installed

If there is an error "Not such file or directory" in the log, and then point to the template folder in / export/secondary, this is the reason. Follow the steps of "installing KVM template" in part 6.

Q: How to deal with column errors in the log database?

A: Follow the steps in step 6 to initialize the database, re create the user and install management.

Tags: Big Data

Posted by cinos11 on Fri, 13 May 2022 10:10:52 +0300