OpenStack之使用nova计算服务启动虚拟机实例

[root@xiandian ~]#source /etc/keystone/admin-openrc.sh

[root@xiandian ~]#openstack service list

openstack role list        openstack user list

生效环境变量获取令牌

[root@xiandian ~]# #nova常用检测和配置命令

[root@xiandian ~]#openstack-service list | grep nova

[root@xiandian ~]#openstack-service status | grep nova

 [root@xiandian ~]# #使用计算服务nova启动虚拟机实例(需要确定的信息包括:主机类型flavor、镜像文件image、网络IP、安全组secgroup、密钥对keypair)

[root@xiandian ~]# #第一步:确定主机类型flavor

[root@xiandian ~]# #查看当前可用主机类型

[root@xiandian ~]#nova flavor-list 

[root@xiandian ~]# #如未有合适主机类型,则需自主创建

[root@xiandian ~]#nova flavor-create ht.small 7 1024 20 2

[root@xiandian ~]# #第二步:获取并制作相应的镜像

[root@xiandian ~]# #获取源文件img(网络http://    本地file://     ftp)

[root@xiandian ~]# #ftp站点ftp://

[root@xiandian ~]#wget ftp://172.16.102.20/cirros-0.3.4-x86_64-disk.img

[root@xiandian ~]#glance image-create --name Linux-7 --disk-format qcow2 --container-format bare --progress<cirros-0.3.4-x86_64-disk.img\

[root@xiandian ~]#glance image-list

[root@xiandian ~]# #nova服务也可以对镜像进行相关操作

[root@xiandian ~]#nova image-show 相应id号

 [root@xiandian ~]# #镜像删除(glance image-delete)

[root@xiandian ~]# #第三步:使用网络服务neutron来获取网络IP

[root@xiandian ~]# #首先查看当前可用的网络和地址池

[root@xiandian ~]#neutron net-list

[root@xiandian ~]# #在sharednet1下创建一个子网shared-subnet学号,地址池是172.16.3.2-127,网关是172.16.3.1

[root@xiandian ~]#neutron subnet-create sharednet1 --name shared-subnet7 --allocation-pool start=172.16.3.2,end=172.16.3.127 --gateway 172.16.3.1 172.16.3.0/24

[root@xiandian ~]# #第四步:设置安全组secgroup

[root@xiandian ~]# #查看当前可用安全组

[root@xiandian ~]#nova secgroup-list 

[root@xiandian ~]# #查看default安全组里的规则

[root@xiandian ~]#nova secgroup-list-rules default

[root@xiandian ~]# #为default这个安全组添加规则

[root@xiandian ~]#nova secgroup-add-rule default tcp 80 80 172.16.3.0/24

[root@xiandian ~]# #自定义安全组

[root@xiandian ~]#nova secgroup-create webserver7 "test secgroup"

[root@xiandian ~]#nova secgroup-list

[root@xiandian ~]#nova secgroup-add-rule webserver7 tcp 80 80 0.0.0.0/0

[root@xiandian ~]# #第五步:创建密钥对keypair

[root@xiandian ~]#nova keypair-add demokey > demokey

[root@xiandian ~]#nova ketpair-add demo > demo

[root@xiandian ~]# #查看当前所有可用密钥对

[root@xiandian ~]#nova keypair-list

[root@xiandian ~]# #为了保护私钥,对其进行加密,保证只有登录用户才能使用

[root@xiandian ~]# chomd 0600 demokey

[root@xiandian ~]#nova root myInstance7 --flavor 7 --image <id> --nic net-id=<id> --security-groups default,webserver7 --key-name demokey

 

[root@xiandian ~]#nova list

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值