2021-02-02 SONiC系统管理 18配置文件格式

SONiC系统管理 18

配置文件格式

前面说到了SONiC系统启动时通过读取初始配置文件的内容来配置系统,SONiC系统默认初始配置文件的位置在/etc/sonic.startup.config。文件内容再进一步指示各种不同类型配置文件的位置。SONiC系统采用过MiniGraph的初始配置文件,后来改为数据库导出的JSON文件作为初始配置文件,也就是config_db.json这个文件。
如果需要让一个SONiC系统在重启以后自动进行初始配置,只需要将配置内容按格式写入config_db.json这个文件,本文进行研究了一下这个初始配置文件怎么写才能符合SONiC系统要求,配置文件编写错误会引起SONiC系统启动错误。
在SONiC相关文档中说明了config_db.json和其他DB的导出文件都是基于ABNF(RFC5234)的规则来描述的,ABNF是Augmented Backus-Naur Form的缩写,中文翻译增强的巴科斯范式。对于计算机语言的学习者来说必须了解什么是BNF和ABNF。一种计算机语言,如C,C++,Java等有自己的语法规则和标记方法,BNF/ABNF就是描述这种规则的语言。
简单理解了ABNF,可以为理解具体表格描述中每个表项的规则要求提供很多方便。
| : 表示在其左右两边任选一项,相当于"OR"的意思。
/ :一般选择操作符 (A / B)
12HEXDIG,164VCHAR,14DIGIT 等等都是ABNF描述的这个表项的取值规则。

config_db.json文件包括下来表格的描述:

PORT_TABLE

;Configuration for layer 2 ports
key = PORT|ifname ; ifname must be unique across PORT,INTF,VLAN,LAG TABLES
admin_status = “down” / “up” ; admin status
lanes = list of lanes ; (need format spec???)
mac = 12HEXDIG ;
alias = 164VCHAR ; alias name of the port used by LLDP and SNMP, must be unique
description = 1
64VCHAR ; port description
speed = 16DIGIT ; port line speed in Mbps
mtu = 1
4DIGIT ; port MTU
fec = 1*64VCHAR ; port fec mode
autoneg = BIT ; auto-negotiation mode

MGMT_PORT_TABLE
;Configuration for management port, including at least one key
key                 = MGMT_PORT|ifname    ; ifname must be unique across PORT,INTF,VLAN,LAG TABLES
admin_status        = "down" / "up" ; admin status
mac                 = 12HEXDIG      ;
alias               = 1*64VCHAR     ; alias name of the port used by LLDP and SNMP, must be unique
description         = 1*64VCHAR     ; port description
speed               = 1*6DIGIT      ; port line speed in Mbps
mtu                 = 1*4DIGIT      ; port MTU
fec                 = 1*64VCHAR     ; port fec mode
autoneg             = BIT           ; auto-negotiation mode
WARM_RESTART
;Stores system warm start configuration
;Status: work in progress

key                 = WARM_RESTART:name ; name is the name of SONiC docker or "system" for global configuration.

neighsyncd_timer    = 1*4DIGIT          ; neighsyncd_timer is the timer used for neighsyncd during the warm restart.
                                        ; Timer is started after we restored the neighborTable to internal data structures.
                                        ; neighborsyncd then starts to read all linux kernel entries and mark the entries in
                                        ; the data structures accordingly. Once the timer is expired, we will do reconciliation
                                        ; and push the delta to appDB
                                        ; Valid value is 1-9999. 0 is invalid.

bgp_timer           = 1*4DIGIT          ; bgp_timer holds the time interval utilized by fpmsyncd during warm-restart episodes.
                                        ; During this interval fpmsyncd will recover all the routing state previously pushed to
                                        ; AppDB, as well as all the new state coming from zebra/bgpd. Upon expiration of this
                                        ; timer, fpmsyncd will execute the reconciliation logic to eliminate all the staled
                                        ; state from AppDB. This timer should match the BGP-GR restart-timer configured within
                                        ; the elected routing-stack.
                                        ; Supported range: 1-3600.

teamsyncd_timer     = 1*4DIGIT          ; teamsyncd_timer holds the time interval utilized by teamsyncd during warm-restart episodes.
                                        ; The timer is started when teamsyncd starts. During the timer interval teamsyncd
                                        ; will preserver all LAG interface changes, but it will not apply them. The changes
                                        ; will only be applied when the timer expired. During the changes application the stale
                                        ; LAG entries will be removed, the new LAG entries will be created.
                                        ; Supported range: 1-9999. 0 is invalid
VXLAN_TUNNEL

Stores vxlan tunnels configuration
Status: ready

key       = VXLAN_TUNNEL:name               ; name is an arbitrary name of vxlan tunnel
src_ip    = ipv4_address                    ; tunnel source IP address. Mandatory
dst_ip    = ipv4_address                    ; tunnel destination IP address. Optional. When this attribute is omitted or equal to "0.0.0.0"
                                            ; the created tunnel will be P2MP. Otherwise the created tunnel will be P2P

VXLAN_TUNNEL_MAP

Stores vxlan tunnel map configuration. Defines mapping between vxlan vni and vlan interface
Status: ready

key       = VXLAN_TUNNEL_MAP:tunnel_name:tunnel_map_name
                                            ; tunnel_name is a reference to created vxlan tunnel
                                            ; tunnel_map_name is an arbitrary name of the map
vni       = uint24                          ; vni id, defined for tunnel map
vlan      = "Vlan"vlan_id                   ; name of the existing vlan interface
NEIGH_TABLE
; Stores the neighbors. Defines static configuration of neighbor entries. If mac address is not specified, implementation shall resolve the mac-address for the neighbor IP.
key           = NEIGH|PORT_TABLE.name / VLAN_INTF_TABLE.name / LAG_INTF_TABLE.name|prefix
neigh         = 12HEXDIG         ; mac address of the neighbor (optional)
family        = "IPv4" / "IPv6"  ; address family
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值