source keystonerc_admin
查看环境变量
创建租户(项目)
openstack project create hds
创建用户
openstack user create hds --password 1 --project hds
追加角色
openstack role add_member --user hds --project hds
创建规格
openstack flavor create hds.hds --ram 1024 --disk 2 --vcpu 1
注册镜像
1.先把镜像上传到本机
2.注册镜像
[root@controller mnt(keystone_admin)]# openstack image create cirros123 --container-format bare --disk-format qcow2 --file /mnt/cirros-0.6.2-x86_64-disk.img --min-disk 1 --min-ram 1024 --public
将镜像从共享的改为公有的:
[root@controller ~(keystone_admin)]# openstack image set cirros123 --public
创建公网
创建网络
openstack network create public --share --project hds --external --provider-network-type flat --provider-physical-network extnet
openstack network list
创建子网
[root@controller mnt(keystone_admin)]# openstack subnet create public-sub --subnet-range 192.168.126.0/24 --dhcp --gateway 192.168.126.2 --network public --allocation-pool start=192.168.126.200,end=192.168.126.230
添加主机
openstack aggregate add host con controller
openstack aggregate add host com compute
追加az的名称
openstack aggregate set con --zone con
openstack aggregate set com --zone com
至此admin上面的操作结束了。
配置普通用户环境变量
切换到普通用户
[root@controller ~(keystone_admin)]# source keystonerc_hds
创建私网
创建网络
创建子网
[root@controller ~(keystone_hds)]# openstack subnet create private-sub --subnet-range 192.168.125.0/24 --dhcp --gateway 192.168.125.254 --network private --allocation-pool start=192.168.125.200,end=192.168.125.230
创建路由器
添加外部网关、内部接口
添加外部网关:
[root@controller ~(keystone_hds)]# openstack router set vrouter01 --external-gateway public
添加内部接口:
创建安全组
配置ICMP协议
[root@controller ~(keystone_hds)]# openstack security group rule create --protocol icmp --ingress SG01
配置SSH协议
[root@controller ~(keystone_hds)]# openstack security group rule create --protocol tcp --dst-port 22:22 --ingress SG01
创建密钥文件
[root@controller ~(keystone_hds)]# openstack keypair create key0422 >> key0422.pem
发放云主机
[root@controller ~(keystone_hds)]# openstack server create ECS0422 --image cirros123 --flavor hds.hds --security-group SG01 --key-name key0422 --availability-zone com --nic net-id=11615658-f5a5-43e6-be34-479015e4a32e
创建浮动IP
[root@controller ~(keystone_hds)]# openstack floating ip create public
绑定浮动IP
[root@controller ~(keystone_hds)]# openstack server add floating ip ECS0422 192.168.126.201