openstack queens版本 环境搭建:制作镜像(centos)

在镜像中,最好不要使用LVM,且无需创建分区指定swap。
# qemu-img create -f qcow2 centos7.qcow2 10G

然后使用virt-manger创建虚拟机,进行操作系统安装和环境配置;
(一般到这里,我们关闭虚拟机,其image我就可以使用了,但是为了配合云化,远没有完成)

Install the ACPI service

To enable the hypervisor to reboot or shutdown an instance, you must install and run the acpid service on the guest system.

yum install acpid -y
systemctl enable acpid

Configure to fetch metadata

一个实例在启动时,必须和metadata服务进行交互,以便完成一些任务;比如:获取ssh public key和运行用户脚本(默认只能访问centos用户)。

yum install cloud-init -y

cloud-init会自动从metadata server获取public key并和一个帐号绑定。这个帐号因linux的发行版不同而不同,基于CentOS的镜像会使用centos帐号。
当然,我们可以自定义帐号:
修改/etc/cloud/cloud.cfg文件,将
users:
 - default
替换为:
users:
 - name: 你的用户名

这么做完的效果:ssh Password认证失效,GSSAPIAuthentication yes,通过证书认证登录,默认情况下,只有控制节点可以登录,sudo su -进入到root视图,然后修改配置。如果要远程访问,将创建实例绑定的密钥对的私钥.ssh/id_rsa拷贝到客户端,然后启动horizon上实例的控制台日志有公钥,拷贝信息到新文件保存成和私钥同名的.pub文件,通过CRT绑定即可访问实例。

通过下面的命令,我们也可以设置其他帐号通过证书访问(在Instance里面操作):

mkdir /home/xiao/.ssh/
chmod 700 /home/xiao/.ssh/
cp /home/centos/.ssh/authorized_keys /home/xiao/.ssh/
chown xiao:xiao -R /home/xiao/.ssh/

Install cloud-utils-growpart to allow partitions to resize

为了根分区自动调整,安装cloud-utils-growpart程序,它包含一些工具可以通过cloud-init调整磁盘。

注意:这个玩意貌似对lvm分区没有啥用?后面再研究研究。。。

yum install cloud-utils-growpart -y

Disable the zeroconf route

For the instance to access the metadata service, you must disable the default zeroconf route:

echo "NOZEROCONF=yes" >> /etc/sysconfig/network

Configure console

为了使nova console-log命令对centos7正常执行,我们需要进行一些配置:
Edit the /etc/default/grub file and configure the GRUB_CMDLINE_LINUX option. Delete the rhgb quiet and add console=tty0 console=ttyS0,115200n8 to the option.
如:直接注释原来的GRUB_CMDLINE_LINUX,替换成下面的即可。
...
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap console=tty0 console=ttyS0,115200n8"
修改保存后,执行:# grub2-mkconfig -o /boot/grub2/grub.cfg

Shut down the instance

poweroff

然后将上面创建的image上传到“控制节点”,通过命令的方式创建openstack的镜像:

openstack image create "centos7" \
 --file /root/centos7.qcow2 \
 --disk-format qcow2 --container-format bare \
 --public

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值