next up previous contents
Next: 設定用戶網路 Up: Quantum 網路服務 Previous: 安裝 Openstack-Quantum   Contents

設定 openvswitch

  1. 設定 openvswitch 主機 ip。
    [root@kvm4 ~(keystone_quantum)]# quantum-node-setup --plugin openvswitch --qhost 192.168.122.4
    Quantum plugin: openvswitch
    Would you like to update the nova configuration files? (y/n): 
    y
    Configuration updates complete!
    
  2. 啟動 openvswitch,並設定開機自動啟動。
    [root@kvm4 ~(keystone_quantum)]# /etc/init.d/openvswitch start
    /etc/openvswitch/conf.db does not exist ... (warning).
    Creating empty database /etc/openvswitch/conf.db   [  OK  ]
    Starting ovsdb-server                              [  OK  ]
    Configuring Open vSwitch system IDs                [  OK  ]
    Inserting openvswitch module                       [  OK  ]
    Starting ovs-vswitchd                              [  OK  ]
    [root@kvm4 ~(keystone_quantum)]# chkconfig openvswitch on
    
  3. 檢查啟動是否正常?沒有訊息表示正常。
    [root@kvm4 ~(keystone_quantum)]# egrep 'ERROR|CRITICAL' /var/log/openvswitch/*
    
  4. 產生名為 br-int 的 OpenvSwitch 橋接器,指定 instance (也就是虛擬機) 的 interface。
    [root@kvm4 ~(keystone_quantum)]# ovs-vsctl add-br br-int
    [root@kvm4 ~(keystone_quantum)]# ovs-vsctl show
    1ff32c6e-03e9-4544-86fe-e8a726830ff0
        Bridge br-int
            Port br-int
                Interface br-int
                    type: internal
        ovs_version: "1.9.0"
    
  5. 設定 br-int 為 integration bridge。
    [root@kvm4 ~(keystone_quantum)]# openstack-config --set \
    /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini OVS integration_bridge br-int
    
  6. 啟動 quantum-openvswitch-agent,並設定開機自動啟動。
    [root@kvm4 ~(keystone_quantum)]# /etc/init.d/quantum-openvswitch-agent start
    Starting quantum-openvswitch-agent:                        [  OK  ]
    [root@kvm4 ~(keystone_quantum)]# chkconfig quantum-openvswitch-agent on
    
  7. 檢查啟動是否正常?出現無法執行指令的訊息,此為用戶 quantum 無法使用 sudo。
    [root@kvm4 ~(keystone_quantum)]# egrep 'ERROR|CRITICAL' /var/log/quantum/openvswitch-agent.log 
    2014-01-25 12:10:58    ERROR [quantum.agent.linux.ovs_lib] \
    Unable to execute ['ovs-vsctl', '--timeout=2', '--', '--if-exists', \
    'del-port', 'br-int', 'patch-tun']. Exception: 
    2014-01-25 12:10:58    ERROR [quantum.agent.linux.ovs_lib] \
    Unable to execute ['ovs-ofctl', 'del-flows', 'br-int']. Exception: 
    2014-01-25 12:10:58    ERROR [quantum.agent.linux.ovs_lib] \
    Unable to execute ['ovs-ofctl', 'add-flow', 'br-int', \
    'hard_timeout=0,idle_timeout=0,priority=1,actions=normal']. Exception: 
    2014-01-25 12:10:58    ERROR [quantum.agent.linux.ovs_lib] \
    Unable to execute ['ovs-vsctl', '--timeout=2', 'list-ports', 'br-int']. Exception:
    
  8. visudo 加入用戶 quantum 使用指令權限。
    [root@kvm4 ~(keystone_quantum)]# cat >> /etc/sudoers << EOF
    > Defaults:quantum !requiretty
    > quantum ALL = (root) NOPASSWD: /usr/bin/quantum-rootwrap
    > EOF
    
  9. 刪除 /var/log/quantum/openvswitch-agent.log,重新啟動 quantum-openvswitch-agent,再檢查已正常。
    [root@kvm4 ~(keystone_quantum)]# rm -f /var/log/quantum/openvswitch-agent.log
    [root@kvm4 ~(keystone_quantum)]# /etc/init.d/quantum-openvswitch-agent restart
    Stopping quantum-openvswitch-agent:                [  OK  ]
    Starting quantum-openvswitch-agent:                [  OK  ]
    [root@kvm4 ~(keystone_quantum)]# egrep 'ERROR|CRITICAL' /var/log/quantum/openvswitch-agent.log
    
  10. 設定開機啟動 quantum-ovs-cleanup,以保證 Openstack Networking agents 可以完全控制網路設備。
    [root@kvm4 ~(keystone_quantum)]# chkconfig quantum-ovs-cleanup on
    
  11. 設定 Openstack Networking DHCP 主機 ip。
    [root@kvm4 ~(keystone_quantum)]# quantum-dhcp-setup --plugin openvswitch --qhost 192.168.122.4
    Quantum plugin: openvswitch
    Configuration updates complete!
    
  12. 啟動 quantum-dhcp-agent,並設定開機啟動。
    [root@kvm4 ~(keystone_quantum)]# /etc/init.d/quantum-dhcp-agent start
    Starting quantum-dhcp-agent:                       [  OK  ]
    [root@kvm4 ~(keystone_quantum)]# chkconfig quantum-dhcp-agent on
    
  13. 檢查啟動是否正常?quantum-dhcp 啟動失敗。
    [root@kvm4 ~(keystone_quantum)]# /etc/init.d/quantum-dhcp-agent restart
    Stopping quantum-dhcp-agent:                               [  OK  ]
    Starting quantum-dhcp-agent:                               [  OK  ]
    [root@kvm4 ~(keystone_quantum)]# egrep 'ERROR|CRITICAL' /var/log/quantum/dhcp-agent.log 
    2015-04-12 15:35:07    ERROR [quantum.agent.dhcp_agent] Unable to enable dhcp.
    2015-04-12 15:35:15    ERROR [quantum.agent.dhcp_agent] Unable to enable dhcp.
    
  14. 解決方式:安裝 kernel-2.6.32-358.114.1.openstack,並重新開機。
    [root@kvm4 ~(keystone_quantum)]# yum install -y kernel iproute \
    --enablerepo=openstack && reboot
    
  15. 再啟動 quantum-dhcp-agent,並檢查啟動是否正常?沒有訊息表示正常。
    [root@kvm4 ~]# source keystonerc_quantum
    [root@kvm4 ~(keystone_quantum)]# rm /var/log/quantum/dhcp-agent.log 
    rm: remove regular file `/var/log/quantum/dhcp-agent.log'? y
    [root@kvm4 ~(keystone_quantum)]# /etc/init.d/quantum-dhcp-agent restart
    Stopping quantum-dhcp-agent:                               [  OK  ]
    Starting quantum-dhcp-agent:                               [  OK  ]
    [root@kvm4 ~(keystone_quantum)]# egrep 'ERROR|CRITICAL' /var/log/quantum/dhcp-agent.log 
    [root@kvm4 ~(keystone_quantum)]#
    
  16. 產生橋接器 br-ex,作為連結外部網路用。
    [root@kvm4 ~(keystone_quantum)]# ovs-vsctl add-br br-ex
    
  17. 備份並複製網卡 eth0 為 br-ex。
    [root@kvm4 ~(keystone_quantum)]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /root/
    [root@kvm4 ~(keystone_quantum)]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 \
    /etc/sysconfig/network-scripts/ifcfg-br-ex
    
  18. 刪除網卡 eth0 中的設定,保留以下三行:
    [root@kvm4 ~(keystone_quantum)]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE="eth0"
    HWADDR="52:54:00:0F:C9:09"
    ONBOOT="yes"
    
  19. 橋接器 br-ex 為對外網路設定,必須保留原有對外網卡的設定,只需要修改 DEVICE 為 br-ex 即可。
    [root@kvm4 ~(keystone_quantum)]# vim /etc/sysconfig/network-scripts/ifcfg-br-ex 
    DEVICE="br-ex"
    BOOTPROTO="static"
    DNS1="192.168.122.1"
    GATEWAY="192.168.122.1"
    IPADDR="192.168.122.4"
    NETMASK="255.255.255.0"
    ONBOOT="yes"
    
  20. 增加網卡 eth0 到橋接器 br-ex,並重新啟動網路。
    [root@kvm4 ~(keystone_quantum)]# ovs-vsctl add-port br-ex eth0; /etc/init.d/network restart
    Shutting down interface eth0:                      [  OK  ]
    Shutting down loopback interface:                  [  OK  ]
    Bringing up loopback interface:                    [  OK  ]
    Bringing up interface br-ex:                       [  OK  ]
    Bringing up interface eth0:                        [  OK  ]
    
  21. 確認網路橋接器 br-ex 的 port 是否為 eth0?
    [root@kvm4 ~(keystone_quantum)]# ovs-vsctl show
    1ff32c6e-03e9-4544-86fe-e8a726830ff0
        Bridge br-int
            Port br-int
                Interface br-int
                    type: internal
        Bridge br-ex
            Port br-ex
                Interface br-ex
                    type: internal
            Port "eth0"
                Interface "eth0"
        ovs_version: "1.9.0"
    
  22. 設定 Openstack Networking L3 Agent 主機 ip。
    [root@kvm4 ~(keystone_quantum)]# quantum-l3-setup --plugin openvswitch --qhost 192.168.122.4
    Quantum plugin: openvswitch
    Configuration updates complete!
    
  23. 啟動 quantum-l3-agent,並設定開機啟動。
    [root@kvm4 ~(keystone_quantum)]# /etc/init.d/quantum-l3-agent start
    Starting quantum-l3-agent:                         [  OK  ]
    [root@kvm4 ~(keystone_quantum)]# chkconfig quantum-l3-agent on
    
  24. 檢查啟動是否正常?出現 CRITICAL 訊息,查看紀錄檔 /var/log/quantum/l3-agnet.log,發現 ip 指定沒有物件 netns,也就是網路 namespace,由於 openstack 虛擬網路各裝置皆使用的 UUID,目前 ifconfig 及 ip 指令不認得這些裝置,必須使用支援 openstack 的 kernel,且套件 iproute 也必須更新。
    [root@kvm4 ~(keystone_quantum)]# egrep 'ERROR|CRITICAL' /var/log/quantum/l3-agent.log 
    2014-01-25 12:51:31 CRITICAL [quantum] 
    
    [root@kvm4 ~(keystone_quantum)]# tail /var/log/quantum/l3-agent.log 
        output = cls._execute('', 'netns', ('list',), root_helper=root_helper)
      File "/usr/lib/python2.6/site-packages/quantum/agent/linux/ip_lib.py", line 58, in _execute
        root_helper=root_helper)
      File "/usr/lib/python2.6/site-packages/quantum/agent/linux/utils.py", line 61, in execute
        raise RuntimeError(m)
    RuntimeError: 
    Command: ['sudo', 'quantum-rootwrap', '/etc/quantum/rootwrap.conf', 'ip', 'netns', 'list']
    Exit code: 255
    Stdout: ''
    Stderr: 'Object "netns" is unknown, try "ip help".\n'
    
    [root@kvm4 ~(keystone_quantum)]# ip netns
    Object "netns" is unknown, try "ip help".
    
  25. 安裝支援 openstack 網路的 kernel 及 iproute,並重新啟動。
    [root@kvm4 ~(keystone_quantum)]# yum install -y kernel-2.6.32-358.114.1.openstack.el6.x86_64 iproute
    [root@kvm4 ~(keystone_quantum)]# rpm -qa | grep iproute
    iproute-2.6.32-23.el6ost.netns.2.x86_64
    [root@kvm4 ~(keystone_quantum)]# reboot
    
  26. 重新啟動後,再導入用戶 quantum 環境變數,檢查 quantum-l3-agent 啟動是否正常?沒有訊息表示正常。
    [root@kvm4 ~]# source keystonerc_quantum 
    [root@kvm4 ~(keystone_quantum)]# rm -f /var/log/quantum/l3-agent.log 
    [root@kvm4 ~(keystone_quantum)]# /etc/init.d/quantum-l3-agent restart
    Stopping quantum-l3-agent:                         [  OK  ]
    Starting quantum-l3-agent:                         [  OK  ]
    [root@kvm4 ~(keystone_quantum)]# egrep 'ERROR|CRITICAL' /var/log/quantum/l3-agent.log
    
  27. 確認 Openstack Networking 狀態,先前設定的 quantum 相關服務已正常啟動。
    [root@kvm4 ~(keystone_quantum)]# openstack-status 
    .......
    == Quantum services ==
    quantum-server:               active
    quantum-dhcp-agent:           active
    quantum-l3-agent:             active
    quantum-linuxbridge-agent:    dead (disabled on boot)
    quantum-openvswitch-agent:    active
    openvswitch:                  active
    ......
    



2015-12-29