1、早上
當自己啓動ovs的時候,會創建一個數據庫(https://mp.csdn.net/mdeditor/97929098#)
sudo ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
數據庫的配置放在/usr/local/etc/openvswitch/conf.db,創建的數據庫的模式是由keke/openvswitch/vswitch/vswitch.ovsschema文件指定的(keke是個人目錄,keke下的openvswtich是下載下來的ovs2.3的源碼)。
keke/openvswitch/vswitch/vswitch.ovsschema這個文件指定了數據庫的表(14張表),這14張表的介紹參考ovs手冊:http://www.openvswitch.org/support/dist-docs/ovs-vswitchd.conf.db.5.html
現在在想,創建數據庫的時候,能不能修改schema格式,比如說給Open_vSwitch這個表中只有一條記錄,能不能修改schema(keke/openvswitch/vswitchd/vswitch.ovsschema),給Open_vSwitch這個表插入4列,這4列分別存儲四個特徵值。
但是如果這樣做的話,後續還要了解一下,ovs如何讀取數據庫中表的某一列的數據,以及floodlight如何修改ovsdb中表的某一列數據。
ovs手冊http://www.openvswitch.org/support/dist-docs/中的:ovs-vswitchd.conf.db(5)介紹了ovsdb中的14個table。
今天下午的目標,看完ovs手冊和ovsdb相關的
ovsdb-tool手冊:中的這段話,告訴我說,shcema中是可以增加、刪除、修改一列的。關於shcema的版本號,(keke/openvswitch/vswitchd/vswitch.ovsshema文件中確實有關於版本的一行信息)
An OVSDB schema has a schema version number, and an OVSDB database em‐
beds a particular version of an OVSDB schema. These version numbers
take the form x.y.z, e.g. 1.2.3. The OVSDB implementation does not en‐
force a particular version numbering scheme, but schemas managed within
the Open vSwitch project use the following approach. Whenever the
database schema is changed in a non-backward compatible way (e.g.
deleting a column or a table), x is incremented (and y and z are reset
to 0). When the database schema is changed in a backward compatible
way (e.g. adding a new column), y is incremented (and z is reset to 0).
When the database schema is changed cosmetically (e.g. reindenting its
syntax), z is incremented.
重點注意一下:
ovsdb-tool指令有以下的參數,這兩個指令可能是用來修改數據庫中的表的
[--rbac-role=role] query [db] transaction
[--rbac-role=role] transact [db] transaction
還有ovsdb-client的:
ovsdb-client's transact command to send the query to ovsdb-server
下一個要看的文檔:ovs手冊:ovsdb-client
ovsdb-client [options] transact [server] transaction
ovsdb-client [options] query [server] transaction
再次理解一下ovs的那14個表,
創建數據庫的時候,能不能修改schema格式,比如說給Open_vSwitch這個表中只有一條記錄,能不能修改schema(keke/openvswitch/vswitchd/vswitch.ovsschema),給Open_vSwitch這個表插入4列,這4列分別存儲四個特徵值。
===
現在想想是不對的,因爲Mininet會創建3個ovs,但是數據庫文件只會啓動一次,所以,shcema只會有一次,所以不能往Open_vSwitch表中存儲。
現在需要確認,mininet中的一個ovs是否對應一個bridge,也就是說是否對應Bridge中的一條記錄,如果有這個對應關係的話,接下來是可以往Bridge表中增加4個列用來存儲特徵數的。
所以接下來,就是要去確認一下,bridge表中的一條記錄是否對應着網絡中的一個ovs???
具體做實驗的方法:在Mininet中創建拓撲,然後使用sudo ovsdb-tool dump查看錶的信息,這個等健身回來再看
2、晚上
確認Bridge表中的一列是否對應一個交換機?
具體的實驗方法是:
sudo mn -c
##啓動floodlight
cd keke/floodlight
java -jar target/floodlight.jar
##使用腳本創建mininet
cd keke/topology
sudo python 2host_3switch.py
##使用floodlight的web ui查看網絡拓撲圖,確認網絡現在有幾個主機和交換機
現在網絡中有3個交換機,2個主機
##現在在mininet的命令提示符下ping是ping不通的,需要通過python腳本下發流表
cd keke/rules
sudo python StaticEntryPusher.py
##這時候再測試一下,是否能ping通
發現0%dropped,確實ping通了
##通過floodlight web ui確認有三個交換機,每個交換機各有兩個端口
##這時候,通過ovsdb-tool命令查看,ovsdb中表的情況
sudo ovsdb-tool dump
##下面的圖片顯示了dump的結果
Bridge table中確實有三行數據,剛好對應三個交換機,因爲它們的datapath_id和floodligth web中交換機剛好對應
Controller table也有三行數據:
Port table對應了9行數據
Open_vSwitch table還是對應了原來的一行數據,這是正確的,因爲這個表只能有一行record(在官方文檔中寫到)
Interface table也有很多數據:
除了上面這些表不爲空,其他的表中都沒有數據,沒有數據的表包括:(分號後面是官方文檔對錶的描述)
Flow_Table table:OpenFlow table configuration
QoS table:Quality of Service configuration
Queue table: QoS output queue.
Mirror table:Port mirroring.
SSL table:SSL configuration.
sFlow table:sFlow configuration.
NetFlow table:NetFlow configuration.
Manager table:OVSDB management connection.
IPFIX table:IPFIX configuration.
Flow_Sample_Collector_Set table:Flow_Sample_Collector_Set configuration.
有數據的表包括:(分號後面是官方文檔對錶的描述)
Open_vSwitch table :Open vSwitch configuration.
Bridge table:Bridge configuration.
Port table:Port configuration.
Interface table:One physical network device in a Port.
Controller table:OpenFlow controller configuration.
看來之前的猜想是正確的,Bridge table中的一行確實對應一個交換機,這時候我們其實可以修改schema,在Bridge table中增加4列,對應着不同交換機的特徵值。
3、明天要做的事情
1、修改schema,往bridge table中加4列
2、瞭解如何在ovs內部如何獲取到ovsdb中某一個表的某一個列的值,並且使用
3、瞭解如何設置ovsdb中某一個表的某一個值
4、待看
下一個需要看的文檔:OVSDB sepecification 中的JSON-RPC transact
待讀列表:
https://tools.ietf.org/html/rfc7047#section-4.1.3
http://docs.openvswitch.org/en/latest/ref/ovsdb.7/
http://blog.chinaunix.net/uid-26133817-id-4912718.html: ovsdb/SPEC文件定義了ovsdb的表規範,創建一個db時,需要預先準備好一個schema文件,該文件是一個JSON格式的字符串,定義了db名字,包含的所有表;每張表都包含一個columns的JSON dict,通過這個schema文件(e.g. vswitchd/vswitch.ovsschema)來創建一個db file。因此ovsdb實際是個文件數據庫(爲啥不直接用sqlite,還要自己寫個)。
http://www.h3c.com/cn/d_201811/1131081_30005_0.htm :介紹ovsdb協議,非常重要
https://tools.ietf.org/html/rfc7047#section-4.1.3 RFC官方文檔,介紹ovsdb
q