openstack搭建之-創建實例(21)
一、 創建flat網絡的實例
#運行admin環境變量,創建網絡類型為flat
. admin-openrc
openstack network create --share \
--provider-physical-network provider \
--provider-network-type flat provider
#創建subnet
openstack subnet create \
--network provider \
--subnet-range 172.16.0.0/16 provider \
--allocation-pool start=172.16.2.100,end=172.16.2.200 \
--gateway 172.16.0.1 \
--dns-nameserver 172.16.0.1 \
--dns-nameserver 8.8.8.8
#驗證IP網絡
. admin-openrc
ip netns
#創建模板(flvor)
openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
openstack flavor create --id 1 --vcpus 1 --ram 1024 --disk 10 chen.nano
#創建鑰匙對
. demo-openrc
ssh-keygen -q -N ""
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
openstack keypair list
#安全組策略設置
openstack security group rule create --proto icmp default
openstack security group rule create --proto tcp --dst-port 22 default
#查看相關信息
. demo-openrc
openstack flavor list
openstack image list
openstack network list
openstack security group list
#創建provider-instance實例(以cirros鏡像為例)
openstack server create \
--flavor m1.nano \
--image cirros \
--security-group default \
--key-name mykey \
provider-instance
openstack server list
openstack console url show provider-instance
ping -c 4 openstack.org
#創建存儲塊並加載到實例
. demo-openrc
openstack volume create --size 1 volume1
openstack volume list
openstack server add volume provider-instance volume1
openstack volume list
二、 創建route網絡
#運行環境變量,創建網絡類型為flat(外網)
. admin-openrc
openstack network create --share \
--provider-physical-network provider \
--provider-network-type flat provider
openstack subnet create \
--network provider \
--subnet-range 172.0.0/16 provider \
--allocation-pool start=172.16.2.100,end=172.16.2.200 \
--gateway 172.16.0.1 \
--dns-nameserver172.16.0.1 \
--dns-nameserver 8.8.8.8
#創建selfservice網絡(內網)
. demo-openrc
openstack network create selfservice
openstack subnet create \
--network selfservice \
--dns-nameserver 8.8.8.8 \
--gateway 192.168.11.1 \
--subnet-range 192.168.11.0/24 selfservice
#更新外部路由
. admin-openrc
neutron net-update provider --router:external
#創建路由
. demo-openrc
openstack router create router
neutron router-interface-add router selfservice
neutron router-gateway-set router provider
#驗證
. admin-openrc
ip netns
neutron router-port-list router
#創建模板flvor
openstack flavor create --id 0 --vcpus 1 --ram 1024 --disk 10 chen.nano
#創建鑰匙對
. demo-openrc
ssh-keygen -q -N ""
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
openstack keypair list
#安全組策略
openstack security group rule create --proto icmp default
openstack security group rule create --proto tcp --dst-port 22 default
#查看相關信息
. demo-openrc
openstack flavor list
openstack image list
openstack network list
openstack security group list
#創建selfservice-instance實例( openstack network list查看selfservice的id)
openstack server create \
--flavor chen1.nano \
--image chen-test \
--nic net-id=8ff69e7c-0762-4243-bfe3-1925752f0e96 \
--security-group default \
--key-name mykey \
selfservice-instance
openstack server list
openstack console url show selfservice-instance
ping -c 4 www.baidu.com
#創建浮點IP,用於通過外部網絡訪問虛擬機,相當於給虛擬機映射一個外網IP
openstack floating ip create provider
openstack server add floating ip selfservice-instance 172.16.2.150(上一步創建的ip)
openstack server list
ping -c 4 192.168.11.2
#創建存儲塊
. demo-openrc
openstack volume create --size 10 volume2
openstack volume list
openstack server add volume provider-instance volume2
openstack volume list
openstack搭建之-創建實例(21)