1)创建网络
source ~/admin-openrc #执行环境1. 获得project id
#openstack project list
PROID=`openstack project list |grep service | awk '{print $2}'`
#openstack network create --project $PROID --share --provider-network-type flat --provider-physical-network physnet1 share-net1
[root@controller1 ~]# openstack network create --project $PROID --share --provider-network-type flat --provider-physical-network physnet1 share-net1
[root@controller1 ~]# openstack network list
参数
--share 允许所有项目使用虚拟网络
$PROID 是执行PROID=`openstack project list |grep service | awk '{print $2}'` 得到的project id
#openstack subnet create share-subnet1 \
--network share-net1 \
--project $PROID \
--subnet-range 10.16.100.0/24 \
--allocation-pool start=10.16.100.100,end=10.16.100.254 \
--dns-nameserver 202.96.128.166 --gateway 10.16.100.1
openstack keypair create --public-key ~/.ssh/id_rsa.pub nstkey
[root@controller1 .ssh]#openstack security group rule create --proto icmp default
查看安全组规则:#openstack security group rule list
openstack network list
NETID=`openstack network list |grep share-net1 |awk '{print $2}'`
创建虚拟机:
[root@controller1 ~]# openstack server create --flavor test.flavor \
--image cirros001 --security-group default \
--nic net-id=$NETID \
--key-name nstkey test-server006
如果创建失败,需要查看各个控制节点和计算节点:
grep 'ERROR' /var/log/nova/*
grep 'ERROR' /var/log/glance/*
grep 'ERROR' /var/log/neutron/*
grep 'ERROR' /var/log/keystone/*
cat /var/log/nova/nova-compute.log | grep "WARNING"
2)查看虚拟机实例
[root@controller1 ~]# openstack server list
3)登录
[root@controller1 .ssh]# nova get-vnc-console ad386616-d141-4920-b092-c57bc7612b59 novnc
http://172.16.70.206:6080/vnc_auto.html?token=97aa7e9b-4aef-4c06-a941-f68951e76679
3)排错
[root@compute1 nova]# egrep -c '(vmx|svm)' /proc/cpuinfo
0 #0 表示不支持kvm,1 表示支持kvm。
首先,在物理机BIOS中开启虚拟化功能,然后设置VWARE虚拟机
设置完后,再查看
[root@compute3 ~]# systemctl restart libvirtd
[root@compute3 ~]# systemctl restart openstack-nova-compute.service
------------------
注:创建虚拟机之前,由于一个网络下不能存在多个dhcp,所以一定关闭其他的dhcp选项 ,虚拟机关闭dhcp
这个问题产生的很大原因有:(4)所使用的Flavor云主机类型配置的根磁盘要满足image镜像的空间。
(3)配置dashboard
1)查看状态:openstack-status
2)安装配置dashboard
yum -y install openstack-dashboard
修改配置文件 /etc/openstack-dashboard/local_settings
ALLOWED_HOSTS = ['*', 'localhost']
OPENSTACK_API_VERSIONS = {
# "data-processing": 1.1,
"identity": 3,
"volume": 2,
"compute": 2,
}
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT =True
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN ='Default'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '172.16.100.70:11211',
},
}
OPENSTACK_HOST = "172.16.100.70"
OPENSTACK_KEYSTONE_URL ="http://%s:5000/v3" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_DEFAULT_ROLE ="user"
3)重启服务
systemctl restart httpd memcached
4)登录web:https://管理网IP/dashboard
5)出错:打不开500 internal server error
找查看日志cat /var/log/httpd/error_log ,如下:
[Thu Jun 21 14:24:40.156104 2018] [:error][pid 7494] No handlers could be found for logger"openstack_dashboard.settings"
[Thu Jun 21 14:24:40.263251 2018] [:error][pid 7494] [remote 172.16.100.111:0] mod_wsgi (pid=7494): Target WSGI script'/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi' cannot beloaded as Python module.
[Thu Jun 21 14:24:40.263301 2018] [:error][pid 7494] [remote 172.16.100.111:0] mod_wsgi (pid=7494): Exception occurredprocessing WSGI script'/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi'.
[Thu Jun 21 14:26:57.375927 2018] [:error][pid 7494] [remote 172.16.100.70:0] IOError: [Errno 13] Permission denied:'/usr/share/openstack-dashboard/openstack_dashboard/local/_usr_share_openstack-dashboard_openstack_dashboard_local_.secret_key_store.lock'
将权限更改:chown -Rapache:apache openstack_dashboard
6)根据日志报错信息,可能与django.wsgi有关。百度搜索到解决方法
修改/etc/httpd/conf.d/openstack-dashboard.conf文件
在WSGISocketPrefix run/wsgi下面加一行代码: WSGIApplicationGroup %{GLOBAL}
保存退出,然后重启httpd服务。