openstack 网络相关问题的解决

环境

使用的nova-network
使用的flatdhcp模式,具体配置见
openstack(kilo)安装部署文档(最小化安装,单机安装)
创建网络
nova network-create demo-net –bridge br100 –fixed-range-v4 10.1.80.0/22 –allowed-start 10.1.82.163 –allowed-end 10.1.82.165 –dns1 8.8.8.8
我这里发现如果加了–gateway,似乎会有问题,br100变成了gateway所以,并没有加这个参数

虚拟机IP未设置成功

用cirros-0.3.4-x86_64创建虚拟机,可以看到ip地址已经分配,但是进入虚拟机查看,并未看到IP配置,因此查看虚拟机日志,命令如下:

nova console-log XXX

结果:

Initializing random number generator... done.
Starting acpid: OK
cirros-ds 'local' up at 0.99
no results found for mode=local. up 1.02. searched: nocloud configdrive ec2
Starting network...
udhcpc (v1.20.1) started
Sending discover...
Sending discover...
Sending discover...
Usage: /sbin/cirros-dhcpc <up|down>
No lease, failing
WARN: /etc/rc3.d/S40-network failed
cirros-ds 'net' up at 181.23
checking http://169.254.169.254/2009-04-04/instance-id
discover failed

可以看到Sending discover…,但是发现失败了,因此怀疑是dnsmasq的问题,到网络主节点上查看

ps aux | grep dnsmasq

结果:

nobody   12925  0.0  0.0  15524   900 ?        S    8月31   0:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --dhcp-script=/usr/libexec/libvirt_leaseshelper
root     12926  0.0  0.0  15496   320 ?        S    8月31   0:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --dhcp-script=/usr/libexec/libvirt_leaseshelper
nobody   23090  0.0  0.0  15520   912 ?        S    10:16   0:00 /sbin/dnsmasq --strict-order --bind-interfaces --conf-file= --pid-file=/var/lib/nova/networks/nova-br100.pid --dhcp-optsfile=/var/lib/nova/networks/nova-br100.opts --listen-address=10.1.81.215 --except-interface=lo --dhcp-range=set:net1,10.1.81.216,static,255.255.252.0,86400s --dhcp-lease-max=1024 --dhcp-hostsfile=/var/lib/nova/networks/nova-br100.conf --dhcp-script=/usr/bin/nova-dhcpbridge --no-hosts --leasefile-ro --domain=novalocal
root     23091  0.0  0.0  15520   328 ?        S    10:16   0:00 /sbin/dnsmasq --strict-order --bind-interfaces --conf-file= --pid-file=/var/lib/nova/networks/nova-br100.pid --dhcp-optsfile=/var/lib/nova/networks/nova-br100.opts --listen-address=10.1.81.215 --except-interface=lo --dhcp-range=set:net1,10.1.81.216,static,255.255.252.0,86400s --dhcp-lease-max=1024 --dhcp-hostsfile=/var/lib/nova/networks/nova-br100.conf --dhcp-script=/usr/bin/nova-dhcpbridge --no-hosts --leasefile-ro --domain=novalocal
root     27881  0.0  0.0 112664   976 pts/1    S+   14:08   0:00 grep --color=auto dnsmasq

感觉进程问题不大,怀疑是防火墙问题
查看本机用的是firewalld
先找到dnsmasq的端口

[root@controller ~]# netstat -apnl|grep dnsmasq


tcp        0      0 10.1.81.215:53          0.0.0.0:*               LISTEN      23090/dnsmasq       
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      12925/dnsmasq       
udp        0      0 10.1.81.215:53          0.0.0.0:*                           23090/dnsmasq       
udp        0      0 192.168.122.1:53        0.0.0.0:*                           12925/dnsmasq       
udp        0      0 0.0.0.0:67              0.0.0.0:*                           23090/dnsmasq       
udp        0      0 0.0.0.0:67              0.0.0.0:*                           12925/dnsmasq       
unix  2      [ ]         DGRAM                    3445735  12925/dnsmasq        

可以看到53端口 TCP UDP
67端口 UDP
使用firewall-config,然后加入对应的端口,重启firewalld
重新建一个虚拟机,看日志

no results found for mode=local. up 0.93. searched: nocloud configdrive ec2
Starting network...
udhcpc (v1.20.1) started
Sending discover...
Sending select for 10.1.81.217...
Lease of 10.1.81.217 obtained, lease time 86400
cirros-ds 'net' up at 0.96
checking http://169.254.169.254/2009-04-04/instance-id

发现分配成功!

重用释放的IP不成功

之后又发现一个问题,删除掉某个虚拟机,理论上会释放IP,但是建立虚拟机后,从WEB上看分配了此IP,但虚拟机内部没有设置成功IP,查看dnsmasq日志

journalctl -a|grep dnsmasq

看到

not using configured address 10.1.81.216 because it is leased to fa:16:3e:b6:e3:26

感觉这个IP释放仍是没有成功,调整了nova.conf里的参数
设置

force_dhcp_release=True
fixed_ip_disassociate_timeout=60

重启相关服务,之后IP设置成功。
纠正,发现IP仍然有问题,我又修改了dhcp_lease_time=60,之后似乎是可行了,仍然不是很明白此处具体是怎么回事
参考:
http://openstackoperationsguide.readthedocs.org/en/latest/Operations/Network%20Troubleshooting.html

你可能感兴趣的:(openstack,NetWork,nova)