OpenStack命令行发放
创建租户(项目)
一个租户下面有很多个用户
[root@controller ~]# source keystonerc_admin # admin环境变量
[root@controller ~(keystone_admin)]# nova list # 查看主机
[root@controller ~(keystone_admin)]# keystone -h |grep ten |查看命令
[root@controller ~(keystone_admin)]# keystone help tenant-create # 查看参数
[root@controller ~(keystone_admin)]# keystone tenant-create --name natasha # 创建租户
创建用户(keystone)
[root@controller ~(keystone_admin)]# keystone -h |grep user |查看命令
[root@controller ~(keystone_admin)]# keystone help user-create # 查看参数
[root@controller ~(keystone_admin)]# keystone user-create --name natasha --tenant natasha --pass redhat # 创建用户
上传镜像(glance)
[root@controller ~(keystone_admin)]# mkdir /soft (上传镜像到OpenStack)
[root@controller ~(keystone_admin)]# ls /soft
cirros-0.5.2-x86_64-disk.img
[root@controller ~(keystone_admin)]# cp keystonerc_admin keystonerc_natasha
[root@controller ~(keystone_admin)]# vim keystonerc_natasha
#修改下面参数
export OS_USERNAME=natasha
export OS_TENANT=natasha
export PS='[\U@\h \W(keystone_natasha)]\$'
[root@controller ~(keystone_admin)]# source keystonerc_natasha
[root@controller ~(keystone_natasha)]# glance -h |grep create #查看命令
[root@controller ~(keystone_natasha)]# glance help image-create #查看参数
[root@controller ~(keystone_natasha)]# glance image-create --name loveu --disk-format qcow2 --container-format bare --min-disk 5 --min-ram 2048 --file=/soft/cirros-0.5.2-x86_64-disk.img --is-protected True --progress
#container:存储镜像格式 bare裸磁盘 progress:显示进度条 protected:受保护的
创建规格(nova)
#切换到管理员admin用户
[root@controller ~(keystone_natasha)]# source keystonerc_admin
[root@controller ~(keystone_admin)]# nova -h |grep flav
[root@controller ~(keystone_admin)]# nova help flavor-create
[root@controller ~(keystone_admin)]# nova flavor-create m2.love auto 2048 5 1
创建私网和子网(neutron)
[root@controller ~(keystone_admin)]# source keystonerc_natasha
[root@controller ~(keystone_natasha)]# neutron -h |grep create
[root@controller ~(keystone_natasha)]# neutron help net-create
[root@controller ~(keystone_natasha)]# neutron net-create private
#创建子网
[root@controller ~(keystone_natasha)]# neutron -h |grep subnet
[root@controller ~(keystone_natasha)]# neutron help subnet-create
[root@controller ~(keystone_natasha)]# neutron subnet-create --name sub_private --gateway 192.168.88.254 --enable-dhcp --allocation-pool start=192.168.88.10,end=192.168.88.200 private 192.168.88.0/24
#allocation-pool:限制分配dhcp网段
创建公网和子网
#创建公网DHCP必须关闭
[root@controller ~(keystone_natasha)]# neutron net-create public
[root@controller ~(keystone_natasha)]# neutron subnet-create --name sub_public --gateway 192.168.10.254 --disable-dhcp --allocation-pool start=192.168.10.100,end=192.168.10.200 public 192.168.10.0/24
设置网络为 共享和外部网络
#必须管理员用户才能设置
[root@controller ~(keystone_natasha)]# source keystonerc_admin
[root@controller ~(keystone_admin)]# neutron help net-update # 查看参数
[root@controller ~(keystone_admin)]# neutron net-show public # 查看public公网信息
[root@controller ~(keystone_admin)]# neutron net-update --shared=true --router:external=true public
创建路由(neutron)
[root@controller ~(keystone_admin)]# source keystonerc_natasha
#创建路由器
[root@controller ~(keystone_natasha)]# neutron -h |grep router
[root@controller ~(keystone_natasha)]# neutron router-create abc
#设置网关
[root@controller ~(keystone_natasha)]# neutron -h |grep gateway
[root@controller ~(keystone_natasha)]# neutron router-gateway-set abc public
#设置路由接口
[root@controller ~(keystone_natasha)]# neutron -h |grep interface
[root@controller ~(keystone_natasha)]# neutron router-interface-add abc sub_private
创建安全组(neutron)
[root@controller ~(keystone_natasha)]# neutron -h |grep security
[root@controller ~(keystone_natasha)]# neutron security-group-create sec01
#创建规则
[root@controller ~(keystone_natasha)]# neutron help security-group-rule-create #查看参数
[root@controller ~(keystone_natasha)]# neutron security-group-rule-create --direction ingress --protocol icmp sec01
#direction:出入规则,ingress是入口 protocol:放通的协议
[root@controller ~(keystone_natasha)]# neutron security-group-rule-create --direction ingress --protocol tcp --port-range-min 22 --port-range-max 22 sec01 #放通22端口
创建密钥对 (nova)
[root@controller ~(keystone_natasha)]# nova -h |grep key
[root@controller ~(keystone_natasha)]# nova keypair-add key110 > key110.pem
发放云主机
[root@controller ~(keystone_natasha)]# nova boot --flavor m2.love \
--image loveu \
--min-count 1 \
--key-name key110 \
--security-group sec01 \
--nic net-id=ad34348d-6979-4f96-a2de-3a2a56e92215 ecs01
可以用以下查询
# nova flavor-list #查规格
# glance image-list #查镜像
# min-count #创建几台
# nova keypair-list #查密钥
# neutron security-group-list #查安全组
# neutron net-list #查net的ID
创建浮动IP(neutron)
[root@controller ~(keystone_natasha)]# neutron -h |grep float
[root@controller ~(keystone_natasha)]# neutron floatingip-create public
分配浮动IP(nova)
[root@controller ~(keystone_natasha)]# nova -h |grep float
[root@controller ~(keystone_natasha)]# nova floating-ip-associate
[root@controller ~(keystone_natasha)]# nova help floating-ip-associate
[root@controller ~(keystone_natasha)]# nova floating-ip-associate ecs01 192.168.10.102
标签:--,controller,keystone,命令行,OpenStack,root,neutron,natasha
From: https://www.cnblogs.com/wengfy/p/17055398.html