HCIP-OpenStack

1、OpenStack概述

OpenStack是一种云操作系统,OpenStack是虚拟机、裸金属和容器的云基础架构。可控制整个数据中心的大型计算、存储和网络资源池,所有资源都通过API或Web界面进行管理。
OpenStack项目是一个适用于所有类型云的开源云计算管理平台,OpenStack由几个主要的组件组合起来完成具体工作,OpenStack通过一组相互关联的服务提供基础设施即服务 (IaaS)解决方案,每个服务都提供了一个应用程序编程接口 (API)来促进这种集成。

1、linux模板制作

使用minimal最小化安装Stream-8,最小化安装用# ip a查看ip
HCIP-OpenStack_第1张图片
制作Linux 虚拟机模板,后面克隆(完整克隆)出计算节点compute和控制节点controller,https://blog.51cto.com/cloudcs/5258769
HCIP-OpenStack_第2张图片
HCIP-OpenStack_第3张图片
HCIP-OpenStack_第4张图片
HCIP-OpenStack_第5张图片
HCIP-OpenStack_第6张图片
HCIP-OpenStack_第7张图片
HCIP-OpenStack_第8张图片
HCIP-OpenStack_第9张图片
HCIP-OpenStack_第10张图片

1、修改网卡信息 # cd /etc/sysconfig/network-scripts/  # cat ifcfg-ens160
TYPE=Ethernet
BOOTPROTO=dhcp
NAME=ens160
DEVICE=ens160
ONBOOT=yes
2、清除密钥信息 # cd /etc/ssh
# rm -rf ssh_host_*
3、清除 Machine ID # cat /etc/machine-id 
000fca8b6e184c94adbae8a120ce776a
# cat /dev/null > /etc/machine-id 
# cat /etc/machine-id 
4、最后关闭虚拟机,# init 0 关机(开机上述文件又会自动生成)
关机状态下进行克隆虚拟机,通过模板完整克隆出两台完整复制的虚拟机。

HCIP-OpenStack_第11张图片
开启两台虚拟机(controller和compute),分别修改主机名和配置静态IP
HCIP-OpenStack_第12张图片
HCIP-OpenStack_第13张图片

# hostnamectl set-hostname controller
# cd /etc/sysconfig/network-scripts/
# vi ifcfg-ens160 
TYPE=Ethernet
BOOTPROTO=none
NAME=ens160
DEVICE=ens160
ONBOOT=yes
IPADDR=10.1.1.50      10.1.1.60
NETMASK=255.255.255.0
GATEWAY=10.1.1.2
DNS1=10.1.1.2
重启控制节点和计算节点(controller和compute)再拍摄快照

HCIP-OpenStack_第14张图片

2、OpenStack环境搭建(在线yum源)

Openstack环境搭建有很多种方法:
1.手工搭建,一个组件一个组件去安装。
2.通过工具 packstack 生成一个应答文件,编写应答文件,packstack调用应答文件去安装openstack环境。
3.HCS huaweicloud stack deploy 工具,私有云部署工具,通过安装一个精简版的openstack(heat编排服务),通过该服务去一键式安装整个云环境。
https://blog.51cto.com/cloudcs/6267456 搭建 openstack 最麻烦的是 yum 源问题
8版本用NetworkManager替代了network,仍想用ntwork需安装network服务,# yum install network-scripts -y

以下内容控制节点和计算节点都要操作
关闭防火墙和selinux和NetworkManager
# systemctl stop firewalld
# systemctl disable firewalld
# setenforce 0
# vi /etc/selinux/config  修改SELINUX=disabled
# systemctl stop NetworkManager
# systemctl disable NetworkManager
配置ip和主机名的映射,
# vi /etc/hosts
# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.1.1.50 controller
10.1.1.60 compute
安装基础软件包(用自带的在线yum源)
yum install -y vim net-tools bash-completion chrony.x86_64 centos-release-openstack-victoria.noarch
安装network服务,# yum install network-scripts -y
配置ntp时间同步
# vim  /etc/chrony.conf
pool ntp.aliyun.com iburst
# systemctl start chronyd
# systemctl enable chronyd
配置yum源(先把原有的备份后清空)
# cd /etc/yum.repos.d/      # rm -rf *
# cat cloud.repo 

[highavailability]
name=CentOS Stream 8 - HighAvailability
baseurl=https://mirrors.aliyun.com/centos/8-stream/HighAvailability/x86_64/os/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1

[nfv]
name=CentOS Stream 8 - NFV
baseurl=https://mirrors.aliyun.com/centos/8-stream/NFV/x86_64/os/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1

[rt]
name=CentOS Stream 8 - RT
baseurl=https://mirrors.aliyun.com/centos/8-stream/RT/x86_64/os/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1

[resilientstorage]
name=CentOS Stream 8 - ResilientStorage
baseurl=https://mirrors.aliyun.com/centos/8-stream/ResilientStorage/x86_64/os/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1

[extras-common]
name=CentOS Stream 8 - Extras packages
baseurl=https://mirrors.aliyun.com/centos/8-stream/extras/x86_64/extras-common/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1

[extras]
name=CentOS Stream  - Extras
mirrorlist=http://mirrorlist.centos.org/?release=&arch=&repo=extras&infra=
#baseurl=http://mirror.centos.org///extras//os/
baseurl=https://mirrors.aliyun.com/centos/8-stream/extras/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[centos-ceph-pacific]
name=CentOS - Ceph Pacific
baseurl=https://mirrors.aliyun.com/centos/8-stream/storage/x86_64/ceph-pacific/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage

[centos-rabbitmq-38]
name=CentOS-8 - RabbitMQ 38
baseurl=https://mirrors.aliyun.com/centos/8-stream/messaging/x86_64/rabbitmq-38/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Messaging

[centos-nfv-openvswitch]
name=CentOS Stream 8 - NFV OpenvSwitch
baseurl=https://mirrors.aliyun.com/centos/8-stream/nfv/x86_64/openvswitch-2/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-NFV
module_hotfixes=1

[baseos]
name=CentOS Stream 8 - BaseOS
baseurl=https://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1

[appstream]
name=CentOS Stream 8 - AppStream
baseurl=https://mirrors.aliyun.com/centos/8-stream/AppStream/x86_64/os/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1

[centos-openstack-victoria]
name=CentOS 8 - OpenStack victoria
baseurl=https://mirrors.aliyun.com/centos/8-stream/cloud/x86_64/openstack-victoria/
#baseurl=https://repo.huaweicloud.com/centos/8-stream/cloud/x86_64/openstack-yoga/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud
module_hotfixes=1

[powertools]
name=CentOS Stream 8 - PowerTools
#mirrorlist=http://mirrorlist.centos.org/?release=&arch=&repo=PowerTools&infra=
baseurl=https://mirrors.aliyun.com/centos/8-stream/PowerTools/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

# yum clean all  清理缓存
# yum makecache  重新建立缓存
# yum repolist all  列出yum仓库

只在控制节点上安装并配置packstack
安装packstack工具,# yum install -y openstack-packstack
[root@controller ~]# packstack --help |grep ans 找到生成应答文件的参数,–gen-answer-file
[root@controller ~]# packstack --gen-answer-file=yingda.txt 生成应答文件
编辑应答文件,# vim yingda.txt
修改以下参数内容
CONFIG_COMPUTE_HOSTS=10.1.1.50,10.1.1.60
CONFIG_KEYSTONE_ADMIN_PW=redhat
CONFIG_PROVISION_DEMO=n
CONFIG_HEAT_INSTALL=y
CONFIG_NEUTRON_OVN_BRIDGE_IFACES=br-ex:ens160
需要注意的是 br-ex 后面对应的网卡名称,有的网卡是ens33,我这里是ens160
根据应答文件安装openstack,# packstack --answer-file=yingda.txt
HCIP-OpenStack_第15张图片
控制节点和计算节点都开启network服务,# systemctl start network # systemctl enable network
控制节点和计算节点分别拍摄快照
HCIP-OpenStack_第16张图片
HCIP-OpenStack_第17张图片

3、OpenStack环境搭建(本地yum源)

所有流程和在线yum源是一样的,唯独配置yum源不一样。
HCIP-OpenStack_第18张图片
在计算节点上开启httpd服务[root@compute ~]# yum install -y httpd # systemctl start httpd # systemctl enable httpd
[root@compute ~]# mkdir /iso 后将镜像放置该目录下[root@compute ~]# ls /iso
CentOS-Stream-8-OPS-Victoria.iso CentOS-Stream-8-x86_64-20221222-dvd1.iso
[root@compute ~]# cd /var/www/html/ [root@compute html]# mkdir os vic
[root@compute html]# vim /etc/fstab 镜像文件系统类型为iso9660
/iso/CentOS-Stream-8-x86_64-20221222-dvd1.iso /var/www/html/os iso9660 defaults 0 0
/iso/CentOS-Stream-8-OPS-Victoria.iso /var/www/html/vic iso9660 defaults 0 0
[root@compute html]# mount -a 刷新
[root@compute html]# df -Th
HCIP-OpenStack_第19张图片
控制节点和计算节点都要配置本地yum源

cat <<EOF > /etc/yum.repos.d/cloudcs.repo
[highavailability]
name=CentOS Stream 8 - HighAvailability
baseurl=http://192.168.100.152/vic/highavailability/
gpgcheck=0

[nfv]
name=CentOS Stream 8 - NFV
baseurl=http://192.168.100.152/vic/nfv/
gpgcheck=0

[rt]
name=CentOS Stream 8 - RT
baseurl=http://192.168.100.152/vic/rt/
gpgcheck=0

[resilientstorage]
name=CentOS Stream 8 - ResilientStorage
baseurl=http://192.168.100.152/vic/resilientstorage/
gpgcheck=0

[extras-common]
name=CentOS Stream 8 - Extras packages
baseurl=http://192.168.100.152/vic/extras-common/
gpgcheck=0

[extras]
name=CentOS Stream $releasever - Extras
baseurl=http://192.168.100.152/vic/extras/
gpgcheck=0

[centos-ceph-pacific]
name=CentOS - Ceph Pacific
baseurl=http://192.168.100.152/vic/centos-ceph-pacific/
gpgcheck=0

[centos-rabbitmq-38]
name=CentOS-8 - RabbitMQ 38
baseurl=http://192.168.100.152/vic/centos-rabbitmq-38/
gpgcheck=0

[centos-nfv-openvswitch]
name=CentOS Stream 8 - NFV OpenvSwitch
baseurl=http://192.168.100.152/vic/centos-nfv-openvswitch/
gpgcheck=0

[baseos]
name=CentOS Stream 8 - BaseOS
baseurl=http://192.168.100.152/os/BaseOS/
gpgcheck=0

[appstream]
name=CentOS Stream 8 - AppStream
baseurl=http://192.168.100.152/os/AppStream/
gpgcheck=0

[centos-openstack-victoria]
name=CentOS 8 - OpenStack victoria
baseurl=http://192.168.100.152/vic/centos-openstack-victoria/
gpgcheck=0

[powertools]
name=CentOS Stream 8 - PowerTools
baseurl=http://192.168.100.152/vic/powertools/
gpgcheck=0
EOF

你可能感兴趣的:(openstack)