龙空技术网

OpenStack裸金属使用总结

新钛云服 661

前言:

现时姐妹们对“centos updateinitramfs”都比较注意,我们都想要知道一些“centos updateinitramfs”的相关文章。那么小编在网络上网罗了一些有关“centos updateinitramfs””的相关知识,希望同学们能喜欢,大家一起来学习一下吧!

作者:张宇

1. 介绍

在openstack 中提供裸金属服务的项目是ironic, 它可以作为一个单独的服务使用,也可以与openstack 其他服务(例如:keystone, nova, neutron, glance, swift)集成在一起使用。在为裸机正确配置了计算和网络服务后,可以通过计算服务的API配置裸机和虚拟机,但是,由于物理服务器和交换机硬件的不同特性,实例操作集受到限制,例如,不能在裸机实例上执行实时迁移。

2. 为什么需要裸机

以下是在云环境进行裸机(物理服务器)配置的一些用例:

高性能计算集群需要访问无法虚拟化的硬件设备的计算任务数据库主机(一些数据库在hypervisor中运行不佳)单租户,专用硬件以提高性能,安全性,可靠性和其他需求快速部署云基础架构3. 裸金属服务的关键技术PXE, 它是由Intel和Microsoft开发的Wired for Management(WfM)规范的一部分。PXE使系统的BIOS和网络接口卡(NIC)可以代替磁盘从网络引导计算机。引导程序是系统将OS加载到本地内存中以便由处理器执行的过程。这种允许系统通过网络引导的功能简化了管理员的服务器部署和服务器管理。DHCP, 它是在Internet协议(IP)网络上使用的标准化网络协议,用于动态分配网络配置参数,例如接口和服务的IP地址。BIOS使用PXE,使用DHCP为网络接口获取IP地址,并找到存储网络引导程序(NBP)的服务器。NBP, 它等效于GRUB(GRand Unified Bootloader) 或LILO (LInux LOader) -传统上用于本地引导的加载器。像硬盘驱动器环境中的引导程序一样,NBP负责将操作系统内核加载到内存中,以便可以通过网络引导操作系统。TFTP, 它是一种简单的文件传输协议,通常用于在本地环境中的计算机之间自动传输配置文件或启动文件。在PXE环境中,TFTP用于使用来自DHCP服务器的信息通过网络下载NBP。IPMI,它是系统管理员使用的标准化计算机系统接口,用于计算机系统的带外管理和对其操作的监视。它是一种仅通过与硬件而非操作系统的网络连接来管理可能无响应或断电的系统的方法。4. 安装支持裸金属的openstack 环境

以CentOS 7为例,使用packstack 安装S版openstack:

yum install centos-release-openstack-stein -y

安装 openstack-packstack:

yum install openstack-packstack -y

使用packstack生成answer文件, 并制定neutron使用openvswitch, os-ironic-install=y选项表示安装ironic相关服务:

packstack --gen-answer-file=answer.txt --os-neutron-ml2-mechanism-drivers=openvswitch --os-neutron-l2-agent=openvswitch --os-ironic-install=y

安装openstack, 使用上面生成的answer文件

packstack --answer-file answer.txt

一般等待半个小时左右即可安装完成,具体视网络情况而定,待安装好之后检查 /etc/nova/nova.conf 里面的 compute_driver, 指定os-ironic-install=y之后这里的值为ironic.IronicDriver. 登录安装好的openstack 管理员界面,在[管理员]-[系统]中会有[裸金属Ironic配置向导]。

5. 安装配置DHCP服务

在openstack裸金属环境中使用DHCP服务,有两种方式进行安装,一种是使用neutron创建网络并开启dhcp服务,另一种是独立安装dhcp服务,独立安装使用一下命令:

yum install dhcp -y

安装好之后修改配置文件:

vim /etc/dhcp/dhcpd.conf

修改 option domain-name-servers 8.8.8.8, 4.4.4.4;以及subnet 配置,然后重启dhcp服务。

# option definitions common to all supported networks...option domain-name "example.org";option domain-name-servers 8.8.8.8, 4.4.4.4;default-lease-time 600;max-lease-time 7200;# Use this to enble / disable dynamic dns updates globally.#ddns-update-style none;# If this DHCP server is the official DHCP server for the local# network, the authoritative directive should be uncommented.#authoritative;# Use this to send dhcp log messages to a different log file (you also# have to hack syslog.conf to complete the redirection).log-facility local7;# No service will be given on this subnet, but declaring it helps the# DHCP server to understand the network topology.# This is a very basic subnet declaration.subnet 192.168.102.0 netmask 255.255.255.0 {  range 192.168.102.110 192.168.102.130;  option domain-name-servers 8.8.8.8;  option routers 192.168.102.100;  option broadcast-address 192.168.102.101;  next-server 192.168.102.100;  filename "pxelinux.0";}
6. 安装TFTP 服务
yum install tftp-server xinetd -y

修改配置文件:

vim /etc/xinetd.d/tftp

将wait 项修改为yes, disable项修改为no, 修改server_args 指定启动文件目录/tftpboot, 指定map-file 文件位置。然后重启tftp服务。

service tftp{  protocol        = udp  port            = 69  socket_type     = dgram  wait            = yes  user            = root  server          = /usr/sbin/in.tftpd  server_args     = -v -v -v -v -v --map-file /tftpboot/map-file /tftpboot  disable         = no  # This is a workaround for Fedora, where TFTP will listen only on  # IPv6 endpoint, if IPv4 flag is not used.  flags           = IPv4}

进入/tftpboot 目录,创建map-file, 并输入一下内容:

re ^(/tftpboot/) /tftpboot/\2re ^/tftpboot/ /tftpboot/re ^(^/) /tftpboot/\1re ^([^/]) /tftpboot/\1

在/tftpboot 目录下创建 pxelinux.cfg 目录:

mkdir pxelinux.cfg

将/usr/share/syslinux 目录下的chain.c32, mboot.c32, memdisk, menu.c32, vesamenu.c32 文件拷贝到/tftpboot 目录下,拷贝pxelinux.0 到/tftpboot目录下。修改 /tftpboot 目录的用户和组权限为ironic:

chown -R ironic:ironic /tftpboot

下载Ironic Python Agent (IPA), U版本对应下载ipa-centos8-* , U版以前的版本下载ipa-centos7-*, 选择对应的initramfs 和kernel 文件下载,在下载完成之后使用openstack image create 命令将镜像上传到glance 服务中:

下载IPA:

上传镜像:

openstack image create --container-format aki --disk-format aki --visibility public ./ipa-centos7-master.kernel deploy-vmlinuzopenstack image create --container-format aki --disk-format aki --visibility public ./ipa-centos7-master.initramfs deploy-initramfs
7. 网络配置

在neutron中配置tenant网络:

# /etc/neutron/plugins/ml2/ml2_conf.ini[ml2]type_drivers=geneve,flat,vlan,vxlantenant_network_types=vlan,flatmechanism_drivers=openvswitch,baremetal[ml2_type_flat]flat_networks=extnet

安装ironic-neutron-agent:

yum install python3-ironic-neutron-agent -y

在neutron中创建flat 类型的网络, 注意物理网络和实际存在的网络名称要对应。

8.配置裸金属节点

可在nova.conf 文件中修改以下选项:

# vim /etc/nova/nova.confcompute_driver=ironic.IronicDriver           # 驱动修改为ironic类型update_resources_interval=10                 # 调整更新资源时间为10秒running_deleted_instance_action=reap         # 删除裸金属实例后更新相应资源running_deleted_instance_poll_interval=10[ironic]auth_url=

添加裸金属节点,如果在ironic-ui页面操作,点击注册节点按钮,填写节点名称,资源类,选择驱动类型ipmi, 添加属性,驱动详情,驱动接口信息后,点击注册按钮,对应名称操作及参数详情如下:

openstack baremetal node create --driver ipmi \--name BM100 \--deploy-interface iscsi  \--raid-interface agent  \--driver-info ipmi_username=root  \--driver-info ipmi_password=calvin  \--driver-info ipmi_address=192.168.102.8 \--driver-info ipmi_port=623 \--driver-info deploy_kernel=bd6fa6c5-03f6-4f8f-a0b5-22f7590f52b5 \--driver-info deploy_ramdisk=89b8fd13-70a6-4590-ae99-52b440dccc65 \--driver-info cleaning_network=f9c73aba-9b65-453a-a408-7224f1834f08 \--driver-info provisioning_network=f9c73aba-9b65-453a-a408-7224f1834f08 \--resource-class BAREMETAL_TEST \--property cpus=24 \--property memory_mb=32768  \--property local_gb=1117 \--property cpu_arch=x86_64

参数解释:

--driver 驱动类型--name 裸金属节点名称--deploy-interface 部署接口--raid-interface RAID接口--driver-info 对应驱动信息,包含IPMI驱动认证信息,  例如:ipmi_address,ipmi_username, ipmi_password,ipmi_port,  部署内核deploy_kernel, 虚拟镜像deploy_ramdisk,  清理网络 cleaning_network, 配置网络provisioning_network。--resource-class 资源类,需要和flavor 元数据对应,  例如:对应flavor元数据需要有 resources:CUSTOM_BAREMETAL_TEST--property 指定裸金属节点的配置信息,包含cpu, 内存,磁盘,cpu体系结构

添加完节点之后此时节点状态处于注册状态,需要手动将节点配置状态修改为management 状态,然后再修改为available状态,此时节点才是可被调度的状态,同时在虚拟机管理器页面中会生成一条记录,这条记录与裸金属节点对应。

9.创建裸金属flavor

openstack flavor create --ram 8192 --vcpus 2 --disk 100 baremetal-flavoropenstack flavor set --property resources:CUSTOM_BAREMETAL_TEST=1 baremetal-flavoropenstack flavor set --property resources:VCPU=0 baremetal-flavoropenstack flavor set --property resources:MEMORY_MB=0 baremetal-flavoropenstack flavor set --property resources:DISK_GB=0 baremetal-flavor
10.创建裸金属实例
openstack server create --flavor baremetal-flavor --nic net-id=$net_id --image $image bm-test# 其中net_id 为flat网络的id,image 为用户需要的目标镜像

创建裸金属实例过程中会在裸机上引导安装操作系统,最终裸机节点状态会修改为active, 裸金属Ironic配置向导页面,云主机ID对应刚创建的实例ID。

标签: #centos updateinitramfs