因爲項目中須要使用OpenDaylight(Oxygen)替換OpenStack(Otaca)中的neutron-openvswitch-agent,能找到的一些資料都是比較舊的版本,官網上的文檔也一直沒有更新,致使中間踩了不少坑,特此記錄一下二者對接的過程python
首先是環境,這次對接使用的opendaylight版本是0.8.3的版本,OpenStack使用的阿里鏡像中的Ocata版本mysql
對接必須確認opendaylight中feature:git
odl-netvirt-openstackgithub
已安裝sql
因爲在部署Openstack時沒有分離出網絡節點,故控制節點與網絡節點爲同一主機數據庫
在控制節點上進行以下操做:網絡
1.在部署openstak的機器上確認實例:curl
nova listtcp
2.清空實例測試
nova delete
3.查看子網
neutron subnet-list
4.查看路由
neutron router-list
5.查看路由接口
neutron router-port-list
6.刪除路由接口
neutron router-interface-delete
7.刪除子網
neutron subnet-delete
neutron net-list
8.刪除網絡
neutron net-delete
9.刪除路由
neutron router-delete
10.確認接口是否清空
neutron port-list
11.中止neutron相關服務
systemctl stop neutron-server
systemctl stop neutron-openvswitch-agent
systemctl disable neutron-openvswitch-agent
12.中止OVS並清空OVS的數據庫,再啓動OVS
systemctl stop openvswitch
rm -rf /var/log/openvswitch/*
rm -rf /etc/openvswitch/conf.db
systemctl start openvswitch
13.此時使用
ovs-vsctl show
查看ovs狀態時應該沒有任何的網橋
14.設置控制器全權控制OVS
ovs-vsctl set-manager tcp:${CONTROL_HOST}:6640
使用
ovs-vsctl show
命令後能看到opendaylight已經管理了OVS,而且生成了br-int的網橋。而且br-int也屬於odl管理
15.安裝ml2驅動:
yum install python-pip
pip install --upgrade distribute
git clone https://github.com/openstack/networking-odl -b stable/ocata
cd networking-odl
python setup.py install
16.修改/etc/neutron/plugins/ml2/ml2_conf.ini:
[ml2]
mechanism_drivers = opendaylight
#在文件最末加上
[ml2_odl]
password = admin
username = admin
#${CONTROL_HOST}這個值修改成odl的ip地址
url = http://${CONTROL_HOST}:8181/controller/nb/v2/neutron
17.將配置寫入neutron的數據庫中:
mysql -u root -p -e "drop database if exists neutron_ml2;"
mysql -u root -p -e "create database neutron_ml2 character set utf8;"
mysql -u root -p -e "grant all on neutron_ml2.* to 'neutron'@'%';"
neutron-db-manage --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf \
--config-file /etc/neutron/plugin.ini upgrade head
18.啓動neutron服務:
systemctl start neutron-server
19.能夠經過odl查看是否有網絡(有結果返回即配置成功,若返回錯誤信息則須要檢查odl是否安裝了相應的組件)
curl -u admin:admin http://${CONTROL_HOST}:8181/controller/nb/v2/neutron/networks
20. openstack啓用odl控制
neutron-odl-ovs-hostconfig --datapath_type=system
在計算節點進行以下操做:
1.關閉計算節點的openvswitch agent
systemctl stop neutron-openvswitch-agent
systemctl disable neutron-openvswitch-agent
2.將計算節點的ovs中全部網橋以及管理地址清空
systemctl stop openvswitch
rm -rf /var/log/openvswitch/*
rm -rf /etc/openvswitch/conf.db
systemctl start openvswitch
3.設置控制器全權控制OVS
ovs-vsctl set-manager tcp:${CONTROL_HOST}:6640
驗證:
ovs-vsctl show
4.安裝openstack-odl驅動
yum install python-pip
pip install --upgrade distribute
git clone https://github.com/openstack/networking-odl -b stable/ocata
cd networking-odl
python setup.py install
5.openstack啓用odl控制(官方文檔未添加這一命令,可是必須運行,不然neutron仍然會使用openvswitch進行網絡組建,致使虛擬機沒法啓動)
neutron-odl-ovs-hostconfig --datapath_type=system
此時opendaylight與open stack已經對接完成,能夠正常創建虛擬機了
不過對接完成後在創建虛擬機時會出現Openstack已經分配好ip,但虛擬機實例內部網卡沒有ip的狀況,此問題暫未解決(使用cirros鏡像測試)