个性化制作OpenStack镜像|环境准备

755 阅读4分钟

欢迎留言讨论,期待与你共同进步掘金人的第一篇博客 - 掘金 (juejin.cn)

本系列文章主要对如何制作OpenStack镜像的过程进行描述记录,涉及基本环境准备、常见类型操作系统的镜像制作。
让你可以从零开始安装一个操作系统,并支持个性化制作OpenStack镜像。

掘金社区:个性化制作OpenStack镜像|系列教程

个性化制作OpenStack镜像|环境准备
个性化制作OpenStack镜像|Windows7
个性化制作OpenStack镜像|Windows10
个性化制作OpenStack镜像|Linux
个性化制作OpenStack镜像|Windows Server2019


CSDN:OpenStack镜像制作教程指导(全)


一、系统环境准备

1.主机说明

  • 宿主机:Windows10
  • 虚拟机:CentOS7 in VMwareWorkstation Pro、Ubuntu16.04 in VMwareWorkstation Pro
  • 镜像下载

下载CentOS-7-x86_64-DVD-1908.iso
下载Ubuntu 16.04

virtio-win README
This location, and the isos that were hosted here, are now deprecated.

virtio-win builds are now distributed in a new location with a new iso file layout. A yum repo is also provided. More info here:

fedoraproject.org/wiki/Window…

Links to the new equivalent of the old stable/ and latest/ directories are listed here:

fedoraproject.org/wiki/Window…

If you need access to the old isos that were hosted here, there's a mirror at:

fedorapeople.org/groups/virt…

Only use them if you need to maintain backwards compatability. No new isos will be added here.

2.简单配置

系统安装完成后一些常用的配置需求,例如:vim、ssh、sudo 、源等

(1)CentOS例子

vim /etc/sudoers

chmod +w /etc/sudoers

vim /etc/sudoers

chmod -w /etc/sudoers

vim /etc/vimrc 

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

yum makecache  history

(2)ubuntu的例子此处不做描述,注意update软件源。

3.检查是否支持虚拟化.打开虚拟化

如果是物理机,首先进入BIOS设置确保已经打开CPU虚拟化。同时进入系统后可以使用egrep检查是否支持虚拟化:

grep "flags" /proc/cpuinfo

或者

egrep -s "(vmx|svm)" /proc/cpuinfo

注:

有输出则说明支持虚拟化,如果输出的信息中有vmx,说明intel处理器支持完全虚拟化。如果显示svm,说明是AMD的处理器支持虚拟化。vmware workstation安装kvm的时候,需要开启CPU支持虚拟化。在BIOS界面设置。

如果使用的是VMware虚拟机制作kvm虚拟机,首先同样需要确保VMware物理机是否打开cpu虚拟化,然后再VMware中设置VMware虚拟机虚拟化引擎设置:

 

二、对于ubuntu主机软件环境安装

1. 安装制作KVM虚拟机相关工具:

sudo apt-get update

sudo apt-get install --no-install-recommends qemu-kvm qemu-utils libvirt-bin virtinst cpu-checker virt-manager virt-viewer -y

2. 下载openstack需要使用的VirtIO驱动:

下载链接:archive-virtio

注:这个链接是官方现存的所有的virtio驱动下载地址,国外站点下载比较慢。建议多下载几个版本,以防某些版本驱动与虚拟机系统不兼容。

3.配置修改

(1)修改VNC服务端的配置文件

vim /etc/libvirt/qemu.conf  

第十二行,把vnc_listen前面的#号去掉。

# vnc_listen = "0.0.0.0"   

wq保存退出。

三、对于CentOS主机软件环境安装

1.安装KVM

(1) 新机器上安装KVM

安装操作系统时选择上虚拟包即可,勾选KVM包

(2)在现有机器上安装KVM

①安装kvm和其他虚拟化所需管理软件包

yum install -y kvm virt-* libvirt bridge-utils qemu-img \
libguestfs-tools 

yum install virt-manager virt-viewer virt-install.noarch

软件包名称介绍:

Kvm:软件包中含有KVM内核模块,它在默认linux内核中提供kvm管理程序

Libvirts:安装虚拟机管理工具,使用virsh等命令来管理和控制虚拟机。

Bridge-utils:设置网络网卡桥接。

Virt-*:创建、克隆虚拟机命令,以及图形化管理工具virt-manager

Qemu-img:安装qemu组件,使用qemu命令来创建磁盘等。

②加载kvm模块,查看kvm模块是否被加载

[root@centos centos]# modprobe kvm-intel

[root@centos centos]# lsmod | grep kvm kvm_intel             

188644  0  kvm        621480  1 kvm_intel irqbypass              13503  1 kvm

[root@centos centos]#

③重启确实KVM是否被加载

[root@centos centos]# reboot

[root@centos centos]# lsmod | grep kvm kvm_intel            

188644  0  kvm                   621480  1 kvm_intel irqbypass              13503  1 kvm

[root@centos centos]#

2. 下载openstack需要使用的VirtIO驱动:

下载链接:VirtIO驱动

注:这个链接是官方现存的所有的virtio驱动下载地址,国外站点下载比较慢。建议多下载几个版本,以防某些版本驱动与虚拟机系统不兼容。

3. 配置KVM

(1)关闭iptables防火墙和selinux

关闭iptables

[root@centos init.d]# systemctl stop firewalld.service [root@centos init.d]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@centos init.d]# systemctl disable iptables.service

[root@centos init.d]# service iptables stop Redirecting to /bin/systemctl stop iptables.service 
[root@centos init.d]#

关闭selinux

[root@centos init.d]# vim /etc/sysconfig/selinux

[root@centos init.d]# setenforce 0

4.修改VNC服务端的配置文件

第十二行,把vnc_listen前面的#号去掉。

[root@LINUX ~]# vim /etc/libvirt/qemu.conf 

------
vnc_listen = "0.0.0.0"  
------

至此,两种Linux平台的环境准备完成。本系列的后续文章皆在ubuntu的平台中进行操作。