(1)创建虚拟机所需服务
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
–provider-physical-network physnet1#物理网为physnet1是在创建neutron时定义的,在 /etc/neutron/plugin.ini配置中flat_networks = physnet1,
在/etc/neutron/plugins/ml2/openvswitch_agent.ini 配置中bridge_mappings = physnet1:br-eth1 ,其中br-eth1网桥中加入了eth1物理端口
–provider-network-type flat#指定网络类型为flat
share-net1 #创建该网络的名称
2)创建子网
#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
3)创建flavor
(intance的type)
[root@controller1 ~]#openstack flavor create –vcpus 1 –ram 512 –disk 3 test.flavor #1cpu,512M内存 ,3G磁盘
[root@controller1 ~]# openstack flavor list
4)控制节点生成秘钥对,在启动实例之前,需要将公钥添加到Compute服务
1.source ~/demo-openrc #转成demo用户环境,这步是必须的,以下的操作都是在这个demo用户环境下操作的
2.ssh-keygen -q -N "" #生成一个密钥
[root@controller1 ~]# ssh-keygen -q -N ""
Enter file in which to save the key (/root/.ssh/id_rsa): #密钥保存目录
3.在openstack 上创建该密钥,名称为nstkey
openstack keypair create –public-key ~/.ssh/id_rsa.pub nstkey
5)添加安全组,允许ICMP(ping)和安全shell(SSH)
[root@controller1 .ssh]#openstack security group rule create –proto icmp default
6)允许安全shell(SSH)访问
[root@controller1 .ssh]#openstack security group rule create –proto tcp –dst-port 22 d80b74d2-c89f-49d9-a2cf-4b1adc18af4d
查看安全组规则:#openstack security group rule list
(2)开始创建虚拟机
1)开始创建
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
这个问题产生的很大原因有:
1)计算节点的内存不足、CPU资源不够、硬盘空间资源不足造成的;将云主机类型规格调小点,发现就能创建成功。
2)网络配置不正确,造成创建虚拟机的时候获取ip失败;网络不通或防火墙引起。
3)openstack-nova-compute服务状态问题。可以尝试重启控制节点的nova相关服务和计算节点的openstack-nova-compute服务;详细检查控制节点和计算节点的nova.conf配置是否有不当配置。
4)这个报错问题的原因很多,具体要查看/var/log/nova下的日志详细分析。重点是nova-compute.log、nova-conductor.log日志
—————————————————————————————————-
在部署openstack虚拟机的时候,要注意以下几点:
(1)控制节点和计算节点在部署前,需要在/etc/hosts里面对主机映射,并且后面不能轻易更改,否则会出问题!
(2)mysql的连接数要调大!否则在操作过程中会由于mysql连接数过多而中断!比如设置mysql连接数为1000,mysql命令为set GLOBAL max_connections=1000;
(3)在创建vm的时候,要保证openstack节点的内存够用。
(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服务。
原文链接:https://blog.csdn.net/openbox2008/article/details/80448808
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/5912