openstack user case.

最近在部署openstack,遇到一些问题,做下总结


  使用rdo安装好openstak后,连不上openstack dashboard

   1) dashboard 使用httpd服务,所以要正确配置httpd服务的配置文件

   修改 /etc/openstack-dashboard/local_settings

   注意修改

   ALLOWED_HOSTS

   OPENSTACK_HOST

以及 

CACHES = {
    'default': {


#        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',


    }
}


然后重启 httpd 和 memcached  



2 配置openstack 网络

1) 删除了 public network

2) 重新创建了一个 192.168.1.0/24的外网

3) 创建一个内网 10.0.0.0/24(用于给虚拟机分配ip)

4) 然后创建一个router 把 内网和外网连上

5)当vm需要访问外网的时候,直接分配一个ip即可

openstack 有两个比较重要的 bridge

br-ex, 对应外网

br-in,对应内网


    Bridge br-int
        Port "tap0f466986-42"
            tag: 4095
            Interface "tap0f466986-42"
                type: internal
        Port br-int
            Interface br-int
                type: internal
        Port "qvof96ab0b4-50"
            tag: 4095
            Interface "qvof96ab0b4-50"
        Port "snooper0"
            Interface "snooper0"
        Port int-br-ex
            Interface int-br-ex
        Port "tap3670fc27-f3"
            tag: 4095
            Interface "tap3670fc27-f3"
                type: internal
        Port "int-br-eth1"
            Interface "int-br-eth1"
    Bridge br-ex
        Port "p4p2"
            Interface "p4p2"
        Port br-ex
            Interface br-ex
                type: internal
        Port phy-br-ex
            Interface phy-br-ex
    Bridge "br-eth1"
        Port "enp11s0f0"
            Interface "enp11s0f0"
        Port "br-eth1"
            Interface "br-eth1"
                type: internal
        Port "phy-br-eth1"
            Interface "phy-br-eth1"
    ovs_version: "2.0.1"



p4p2 是一个192.168.1.x的ip,在lab里的一个交换机上,网关是192.168.1.1,他作为代理服务器连接外网。

所以给vm分配一个192.168.1.x的ip就可以了。

这里把p4p2加入到br-ex网桥上。

然后把p4p2的ip配置给br-ex

ovs-vsctl add-port br-ex p4p2

ip addr remove $ip dev p4p2

ip addr add $ip dev br-ex

最后要把默认路由改成从br-ex出去

route remove default -dev p4p2

route add default gw 192.168.1.1 -dev p4p2


3 novnc 返回1006错误:

主机有两个ip,一个外网9.x,一个内网192.x

nova.conf 中


novncproxy_base_url=http://9.181.129.110:6080/vnc_auto.html
vncserver_listen=9.181.129.110

#把这个代理地址改成 内网的ip,就可以连上vnc了
vncserver_proxyclient_address=192.168.1.110


4 ping不通vm的floating ip,却能ssh

原来vm设置了安全组,把ssh的22端口开放了,所以能ssh。

没有加icmp规则,所以ping不了

如果要访问http服务,或者要开放tcp端口,要手动加入规则


5创建镜像

之前一直没有搞通网络,所以没法使用fedora 和ubuntu的官方 img,自己做了个img


6 打开dashboard的时候报错

port=8774): Max retries exceeded with url: /v2
看了下httpd的log,  发现有大量端口都处于cloae_wait 的状态的进程,重启httpd可以解决,但需要调查一下root cause。

tcp        1      0 192.168.1.110:41555     192.168.1.110:8774      CLOSE_WAIT  19852/httpd         
tcp        1      0 192.168.1.110:47621     192.168.1.110:8774      CLOSE_WAIT  19852/httpd    

7 vnc的配置

controller :

vnc_enabled = True vncserver_host = 0.0.0.0 vncserver_listen = < controller ip > vncproxy_url = http://<controller ip>:6080 vncserver_proxyclient_address = <controller ip> novncproxy_base_url=http://<controller ip>:6080/vnc_auto.html

compute node:

vnc_enabled = True vncserver_listen = <compute ip> vncserver_proxyclient_address = <compute ip> vncproxy_url = http://<controller ip>:6080 novncproxy_base_url=http://<controller ip>:6080/vnc_auto.html

I also have faced the same problem. The above cofiguration solved my issue.


8 设置vlan

openstack bridge:

3346933c-68f1-4312-98c9-c0883ffdd03a
    Bridge br-int
        Port "tap0f466986-42"
            tag: 4095
            Interface "tap0f466986-42"
                type: internal
        Port br-int
            Interface br-int
                type: internal
        Port "qvof96ab0b4-50"
            tag: 4095
            Interface "qvof96ab0b4-50"
        Port "snooper0"
            Interface "snooper0"
        Port int-br-ex
            Interface int-br-ex
        Port "tap3670fc27-f3"
            tag: 4095
            Interface "tap3670fc27-f3"
                type: internal
        Port "int-br-eth1"
            Interface "int-br-eth1"
    Bridge br-ex
        Port "p4p2"
            Interface "p4p2"
        Port br-ex
            Interface br-ex
                type: internal
        Port phy-br-ex
            Interface phy-br-ex
    Bridge "br-eth1"
        Port "enp11s0f0"
            Interface "enp11s0f0"
        Port "br-eth1"
            Interface "br-eth1"
                type: internal
        Port "phy-br-eth1"
            Interface "phy-br-eth1"
    ovs_version: "2.0.1"

修改配置文件

网络节点的 openvswitch 配置

[root@stack-kvm110 ~(keystone_admin)]# grep phy /etc/neutron/plugin.ini 
network_vlan_ranges = physnet2:100:110
bridge_mappings = physnet1:br-eth1,physnet2:br-ex

计算节点,去掉br-ex即可

创建public 网络


$ tenant=$(keystone tenant-list | awk '/service/ {print $2}')
$ neutron router-create router01
$ neutron net-create --tenant-id $tenant public01 \
--provider:network_type flat \
--provider:physical_network physnet1 \
--router:external=True
$ neutron subnet-create --tenant-id $tenant --name public01_subnet01 \
--gateway 10.64.201.254 public01 10.64.201.0/24 --disable-dhcp
$ neutron router-gateway-set router01 public01

根据  http://docs.openstack.org/admin-guide-cloud/content/under_the_hood_openvswitch.html#under_the_hood_openvswitch_scenario1_network

文档的host 配置,一直报错

Unknown provider:physical_network physnet1

于是修改配置文件 /etc/neutron/plug.ini:

network_vlan_ranges = physnet2:100:110,physnet1

就ok了,难道是官方的那个文档有问题么?有待验证。


接着创建内网和内网的子网

$ tenant=$(keystone tenant-list|awk '/demo/ {print $2}'
$ neutron net-create --tenant-id $tenant net01 \
--provider:network_type vlan \
--provider:physical_network physnet2 \
--provider:segmentation_id 101
$ neutron subnet-create --tenant-id $tenant --name net01_subnet01 net01 192.
168.101.0/24
$ neutron router-interface-add router01 net01_subnet01


neutron net-create --tenant-id $tenant net02 \
--provider:network_type vlan \
--provider:physical_network physnet2 \
--provider:segmentation_id 102

$ neutron subnet-create --tenant-id $tenant --name net02_subnet01 net02 192.
168.102.0/24
$ neutron router-interface-add router01 net02_subnet01



9 Debug networking floating ip

给其中的某一个虚拟机实例绑定一个floating ip,发现无法ping通

看了这篇文章,觉得很实用[1]

在vm中添加了一条可以到floating ip所在网络的路由就可以了。


(ip route add 192.168.1.0/24 via 192.168.101.1)

192.168.101.1 是虚拟机的网关

[1]http://openstack.redhat.com/Networking


# List namespaces
$ ip netns
qdhcp-4a04382f-03bf-49a9-9d4a-35ab9ffc22ad
qrouter-1fabd5f0-f80b-468d-b733-1b80d0c3e80f

# Show all interfaces inside the namespace
$ ip netns exec qrouter-1fabd5f0-f80b-468d-b733-1b80d0c3e80f \
  ip a

# Check routing table inside the router namespace     
$ ip netns exec qrouter-1fabd5f0-f80b-468d-b733-1b80d0c3e80f \
  ip r

# IP config inside the router namesapce 
$ ip netns exec qrouter-1fabd5f0-f80b-468d-b733-1b80d0c3e80f \
  ifconfig

# IP configu inside the dhcp namesace
$ ip netns exec qrouter-1fabd5f0-f80b-468d-b733-1b80d0c3e80f \
  ifconfig

# Ping the private IP (of the cirros guest)
$ ip netns exec qrouter-1fabd5f0-f80b-468d-b733-1b80d0c3e80f \
  ping -c2 30.0.0.7
$ ip netns exec qrouter-1fabd5f0-f80b-468d-b733-1b80d0c3e80f \
  ping -c2 192.168.122.14

# ssh into cirros guest
$ ip netns exec qdhcp-4a04382f-03bf-49a9-9d4a-35ab9ffc22ad ssh   [email protected]


10 说到floating ip 就要提iptable 转发

snat: 源地址僞裝, 虛擬機如果想訪問外網,需要作snat

dnat: 目的地址伪装,作为floating ip 使用,也就是说外部要访问虚拟机


11 访问openstack虚拟机

openstack 是用image创建虚拟机,用户不知道这个image的密码

但是openstack 在创建虚拟机之前,使用libguestfs这个工具注入了ssh-key pair,这样就可以无密码访问了。

查看 /va/log/nova/compute.log 来确认libguestfs 有没有成功把key pair注入进去。

使用 yum install libguestfs 安装 

两种方式用来生成sshkey,

一种是opesntack 生成,会自动下载一个 .pem 文件

ssh -l root -i pem floating_ip

第二种是导入主机的公钥

这样可以直接ssh -l root floating_ip



12 创建与本地网络在同一网段的网络(不是外网,也不是floating ip)


创建网络时,指定 physical_network,并且添加一个跟 physical_network 在同一网段的子网。
如下段命令

neutron net-create public02 --provider:network_type flat --provider:physical_network physnet2
</pre><div>创建一个网络,provider指定为physnet2,pyhsent2 在plugin.ini 中要事先定义好 mapping bridge_mappings = physnet1:br-ex,physnet2:br-eth1</div><pre code_snippet_id="342909" snippet_file_name="blog_20140520_7_8768276" name="code" class="plain">
neutron subnet-create --name public02_subnet01 --no-gateway --host-route destination=9.0.0.0/8,nexthop=9.110.190.1 --allocation-pool start=9.110.190.168,end=9.110.190.169 public02 9.0.0.0/8
在 public02 上创建一个子网,指定host-route 和ip pool openstack user case._第1张图片



13 gre 配置,然后重启 openvswitch agent

[ovs]
tenant_network_type = gre
tunnel_id_ranges = 1:1000
enable_tunneling = True
integration_bridge = br-int
tunnel_bridge = br-tun
local_ip = DATA_INTERFACE_IP

br-tun 不用手动创建,agent会帮你创建好,只要在配置文件里指定就好了。

参考连接:

[1] http://developer.rackspace.com/blog/neutron-networking-vlan-provider-networks.html  【12】关于网络的创建


你可能感兴趣的:(openstack user case.)