cloudstack测试环境搭建

环境:
操作系统:openEuler 22.03
CPU:x86-64
参考资料:
cloudstack官方文档:http://docs.cloudstack.apache.org/en/latest/installguide/index.html#general-installation
openEuler官方文档:https://docs.openeuler.org/zh/docs/22.03_LTS/docs/Releasenotes/%E6%B3%95%E5%BE%8B%E5%A3%B0%E6%98%8E.html

角色 IP
MySQL、nfs、cloudstack-management 192.168.157.141
cloudstack-agent 192.168.157.144

1、server端

1.1、系统环境准备

#配置固定IP(修改如下内容)
vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPADDR=192.168.157.141
NETMASK=255.255.255.0
GATEWAY=192.168.157.2
#更新软件
dnf update -y
#disable selinux
vim /etc/selinux/config
SELINUX=disabled
setenforce 0
#配置hostname
hostnamectl set-hostname cloudstack-server
hostnamectl set-hostname cloudstack-server --static
vim /etc/hosts
$IP cloudstack-server
#配置ntp
yum install ntpdate -y
crontab -e
* 1 * * * /usr/sbin/ntpdate -u $ntp_server 2>&1 > /dev/null
#关闭防火墙
systemctl stop firewalld
systemctl disable firewalld

#查看是否为java 11
java --version
#若不是,需要安装
yum install java-11-openjdk java-11-openjdk-headless -y
alternatives --config java

1.2、安装nfs(可单独安装)

dnf install nfs-utils -y
vim /etc/exports
/secondary *(rw,async,no_root_squash,no_subtree_check)
/primary *(rw,async,no_root_squash,no_subtree_check)
mkdir -p /primary
mkdir -p /secondary
#primary和secondary可分别挂载一块硬盘
vim /etc/sysconfig/nfs
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
RQUOTAD_PORT=875
STATD_PORT=662
STATD_OUTGOING_PORT=2020
#启动服务
systemctl enable rpcbind
systemctl enable nfs
systemctl start rpcbind
systemctl start nfs

1.2、

#安装mysql
dnf install mysql mysql-server -y
#修改配置
vim /etc/my.cnf
server-id=1
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'
#启动服务
systemctl start mysqld
systemctl enable mysqld

#定义超管密码(超管默认没有密码)
#mysql 5.7版本其超管密码随机生成,写在日志中
mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.29 Source distribution

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> alter user root@'localhost' identified by 'qycx@12345678';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
#安装依赖
dnf install python3-mysqlclient -y

1.3、cloudstack-management

yum install -y net-tools
yum localinstall cloudstack-common-4.18.0.0-1.ky10.x86_64.rpm -y
yum localinstall cloudstack-management-4.18.0.0-1.ky10.x86_64.rpm -y
#cloudstack没有对国产操作系统进行适配,需要修改一下代码,其路径参考如下(根据python版本不同,路径有所不同)
vim /usr/lib64/python3.6/site-packages/cloudutils/utilities.py(147行)
            elif "openEuler" in distributor:
                self.distro = "openEuler"
vim /usr/lib64/python3.6/site-packages/cloudutils/syscfg.py(50行)
        elif distribution == "openEuler":
            return sysConfigEL(glbEnv)

#初始化数据库
cloudstack-setup-databases cloud:qycx12345678@localhost --deploy-as=root:qycx@12345678
#准备系统虚拟机模板
mkdir -p /mnt/secondary
mount -t nfs 192.168.157.141:/secondary /mnt/secondary/
#下载模板文件,可以从官网下载,我上传的材料中也有
bzip2 -d systemvmtemplate-4.18.0-kvm.qcow2.bz2
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /mnt/secondary/  -f systemvmtemplate-4.18.0-kvm.qcow2  -h kvm
umount /mnt/secondary
#初始化
cloudstack-setup-management
#查看日志,不频繁输出后,系统可用
tail -f /var/log/cloudstack/management/management-server.log
#浏览器访问http://192.168.157.141:8080/client

2、cloudstack-agent(KVM)

虚拟化技术使用kvm
网络插件使用openvswitch

2.1、系统准备

#openEuler默认使用networkManager来管理网络,但是和openvswitch集成度不高,切换为network-scripts
yum install network-scripts -y
systemctl stop NetworkMamager
systemctl disable NetworkManager
systemctl start network
#配置hostname
hostnamectl set-hostname cloudstack-agent
hostnamectl set-hostname cloudstack-agent --static
vim /etc/hosts
$IP cloudstack-agent
#disable selinux
vim /etc/selinux/config
SELINUX=disabled
setenforce 0
#关闭防火墙
systemctl disable firewalld
systemctl stop firewalld
#配置java 11
yum install java-11-openjdk java-11-openjdk-headless -y
alternatives --config java
#配置ntp
yum install ntpdate -y
crontab -e
* 1 * * * /usr/sbin/ntpdate -u $ntp_server 2>&1 > /dev/null
#查看是否支持kvm
ls /dev/kvm

2.2、安装虚拟化组件

yum install libvirt qemu -y
#配置vnc
vim /etc/libvirt/qemu.conf
vnc_listen="0.0.0.0"
#cloudstack通过libvirt来管理虚拟机,因此需要先安装libvrit并配置正确
vim  /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
tcp_port = "16509"
auth_tcp = "none"
mdns_adv = 0
vim /etc/sysconfig/libvirtd #注释掉下面一行
#LIBVIRTD_ARGS="--listen"
systemctl restart libvirtd
#如果时arm环境,还需要进行如下修改
yum install edk2-aarch64 -y
mkdir -p /usr/share/AAVMF
chown nova:nova /usr/share/AAVMF 

ln -s /usr/share/edk2/aarch64/QEMU_EFI-pflash.raw /usr/share/AAVMF/AAVMF_CODE.fd
ln -s /usr/share/edk2/aarch64/vars-template-pflash.raw /usr/share/AAVMF/AAVMF_VARS.fd

vim /etc/libvirt/qemu.conf

nvram = ["/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd", \ 
         "/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw:/usr/share/edk2/aarch64/vars-template-pflash.raw"]

2.3、网络配置

采用openvswitch进行网络管理

dnf install openvswitch -y
systemctl start openvswitch
systemctl enable openvswitch

#编辑网卡文件
vim  /etc/sysconfig/network-scripts/ifcfg-ens33
DEVICE=ens33
NAME=ens33
ONBOOT=yes
DEVICETYPE=ovs
TYPE=OVSPort
OVS_BRIDGE=cloudbr
BOOTPROTO=none
HOTPLUG=no
vim /etc/sysconfig/network-scripts/ifcfg-cloudbr
DEVICE=cloudbr
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=static
DEVICETYPE=ovs
TYPE=OVSBridge
IPADDR=192.168.157.144
NETMASK=255.255.255.0
GATEWAY=192.168.157.2
vim /etc/sysconfig/network-scripts/ifcfg-cloudbr0
DEVICE=cloudbr0
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
DEVICETYPE=ovs
TYPE=OVSBridge

reboot

2.4、cloudstack-agent

yum localinstall cloudstack-common-4.18.0.0-1.ky10.x86_64.rpm -y
yum localinstall cloudstack-agent-4.16.1.1-1.el7.x86_64.rpm -y
vim /usr/lib64/python3.6/site-packages/cloudutils/utilities.py (147)
            elif "openEuler" in distributor:
                self.distro = "openEuler"
vim /usr/lib64/python3.6/site-packages/cloudutils/syscfg.py (50)
        elif distribution == "openEuler":
            return sysConfigRedhat8(glbEnv)
vim /etc/cloudstack/agent/agent.properties 
#arm架构下
guest.cpu.arch=aarch64
guest.cpu.mode=host-passthrough
#若使用ovs
network.bridge.type=openvswitch
libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.OvsVifDriver

环境准备完毕,下一步——添加资源。

你可能感兴趣的:(cloudstack,cloudstack)