学习了这么久的网络,有些词很熟悉,但是就从来没有搞明白它的作用是什么。
例如我们经常在设备上配置的logging buffer。
logging buffer:直译过来就是“日志缓存”的意思。
如下是模拟器设备输出内容:
1、如果我们配置了一台设备,开始并没有相关配置,也就是说我们在设备上配置没有日志缓存。例如如下情况:
R3#sho logging
Syslog logging: enabled (11 messages dropped, 0 messages rate-limited,
0 flushes, 0 overruns, xml disabled, filtering disabled)
Console logging: level debugging, 16 messages logged, xml disabled,
filtering disabled
Monitor logging: level debugging, 0 messages logged, xml disabled,
filtering disabled
Buffer logging: disabled, xml disabled,
filtering disabled
Logging Exception size (4096 bytes)
Count and timestamp logging messages: disabled
Trap logging: level informational, 20 message lines logged
R3#
show logging 显示不出任何的日志信息。这个时候,如果我们想要记录对应的发生在设备上的日志信息,例如配置变动了,接口up或down了,协议收敛或断开了等等情况,那么我们需要在设备上给logging分配一个缓存大小,这个大小就是logging buffer。logging buffer的大小范围如下:
R3(config)#logging buffered <4096-2147483647> //Logging buffer size,但是是byte
我们也可以针对特定的日志级别去记录日志。
R3(config)#logging buffered ?
<0-7> Logging severity level
<4096-2147483647> Logging buffer size
alerts Immediate action needed (severity=1)
critical Critical conditions (severity=2)
debugging Debugging messages (severity=7)
emergencies System is unusable (severity=0)
errors Error conditions (severity=3)
informational Informational messages (severity=6)
notifications Normal but significant conditions (severity=5)
warnings Warning conditions (severity=4)
xml Enable logging in XML to XML logging buffer
<cr>
这里我们只简单测试一下为logging配置一个缓存大小,最小是4096 bytes = 4K bytes(实际一般配置40960 bytes应该足够了),这里就配置最小参数值测试。
R3(config)#logging buffered 4096
1、首先尝试接口up/down
R3(config)#int e0/0
R3(config-if)#shu
R3(config-if)#no shu
*Mar 1 00:33:23.335: %LINK-5-CHANGED: Interface Ethernet0/0, changed state to administratively down
*Mar 1 00:33:24.335: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to down
R3(config-if)#no shu
R3(config-if)#
*Mar 1 00:33:27.031: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
*Mar 1 00:33:28.031: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
在没有配置logging buffer的时候,如上的四条日志不会被记录在show logging的log文件中,那么此时我们查看show logging
R3(config-if)#do sho logg
Syslog logging: enabled (11 messages dropped, 0 messages rate-limited,
0 flushes, 0 overruns, xml disabled, filtering disabled)
Console logging: level debugging, 20 messages logged, xml disabled,
filtering disabled
Monitor logging: level debugging, 0 messages logged, xml disabled,
filtering disabled
Buffer logging: level debugging, 4 messages logged, xml disabled,
filtering disabled
Logging Exception size (4096 bytes)
Count and timestamp logging messages: disabled
Trap logging: level informational, 24 message lines logged
Log Buffer (4096 bytes): //可以看到我们的log buffer大小,而且如下是刚才发生的四条日志。
*Mar 1 00:33:23.335: %LINK-5-CHANGED: Interface Ethernet0/0, changed state to administratively down
*Mar 1 00:33:24.335: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to down
*Mar 1 00:33:27.031: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
*Mar 1 00:33:28.031: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
2、例如我们再尝试和别的设备建立路由邻居,这里以EIGRP为例。
R3(config-if)#router eigrp 1
R3(config-router)#no au
R3(config-router)#net 13.1.1.3 0.0.0.0
R3(config-router)#
*Mar 1 00:36:35.591: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 1: Neighbor 13.1.1.1 (Ethernet0/0) is up: new adjacency
R3(config-router)#end
R3#
*Mar 1 00:36:41.751: %SYS-5-CONFIG_I: Configured from console by console
如上的EIGRP邻居up的日志和配置修改完成的日志也应该被记录在log里面。
R3#sho logging
Syslog logging: enabled (11 messages dropped, 0 messages rate-limited,
0 flushes, 0 overruns, xml disabled, filtering disabled)
Console logging: level debugging, 22 messages logged, xml disabled,
filtering disabled
Monitor logging: level debugging, 0 messages logged, xml disabled,
filtering disabled
Buffer logging: level debugging, 6 messages logged, xml disabled,
filtering disabled
Logging Exception size (4096 bytes)
Count and timestamp logging messages: disabled
Trap logging: level informational, 26 message lines logged
Log Buffer (4096 bytes):
*Mar 1 00:33:23.335: %LINK-5-CHANGED: Interface Ethernet0/0, changed state to administratively down
*Mar 1 00:33:24.335: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to down
*Mar 1 00:33:27.031: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
*Mar 1 00:33:28.031: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
*Mar 1 00:36:35.591: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 1: Neighbor 13.1.1.1 (Ethernet0/0) is up: new adjacency
*Mar 1 00:36:41.751: %SYS-5-CONFIG_I: Configured from console by console
转载于:https://blog.51cto.com/momentsli/2133932