默认的DPDK日志是输出到dmesg中,为了方便定位问题,以下介绍相关的配置文件,将日志输出到OVS日志中,并增加一些日志控制手段。可以根据实际需求配置以下内容。
- 创建DPDK日志目录。
- 配置DPDK的rsyslog配置文件。
- 在“/etc/rsyslog.d”目录中新增配置文件dpdk.conf。
| vim /etc/rsyslog.d/dpdk.conf
|
- 输入以下内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | #DPDK_LOG_TAG "LibLogTag_DPDK"
template(name="template-dpdk" type="string" string="%TIMESTAMP:::date-rfc3339%|%syslogseverity-text%|%programname%[%PROCID%]|%$!msg_pre%%$!msg_after%\n")
$outchannel dpdk,/var/log/dpdk/dpdk.log,2097152,/opt/esyslog/esyslog_log_rsyslog_dump.sh /var/log/dpdk/dpdk.log dpdk
if ($msg contains "LibLogTag_DPDK" and $syslogseverity <= 7 ) then {
set $!msg_pre = field($msg,"LibLogTag_DPDK|",1);
set $!msg_after = field($msg,"LibLogTag_DPDK|",2);
:omfile:$dpdk;template-dpdk
stop
}
if ($msg contains "LibLogTag_DPDK" and $syslogseverity > 7 ) then {
/dev/null
stop
}
|
- 配置DPDK日志打包回卷文件。
- 新增“/etc/logrotate.d/dpdk”文件。
vim /etc/logrotate.d/dpdk
- 输入以下内容:
| /var/log/dpdk/dpdk.log {
hourly
compress
missingok
notifempty
maxsize 2048k
rotate 50
copytruncate
}
|
- 配置OVS日志打包回卷文件。
- 新增“/etc/logrotate.d/openvswitch”文件。
| vim /etc/logrotate.d/openvswitch
|
- 输入以下内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | # Copyright (C) 2009, 2010, 2011, 2012 Nicira, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without warranty of any kind.
/var/log/openvswitch/*.log {
su root root
hourly
compress
missingok
maxsize 2048k
rotate 50
sharedscripts
postrotate
# Tell Open vSwitch daemons to reopen their log files
if [ -d /var/run/openvswitch ]; then
for ctl in /var/run/openvswitch/*.ctl; do
ovs-appctl -t "$ctl" vlog/reopen 2>/dev/null || :
done
fi36
endscript
}
|
- 配置日志定时处理文件。
- 在“/etc/cron.hourly”路径下新增ovslogrotat文件。
| vim /etc/cron.hourly/ovslogrotate
|
- 输入以下内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | #!/bin/sh
/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.d/dpdk
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.d/openvswitch
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
|
- 修改文件权限,增加执行权限和只读属性。
| chmod 0644 /etc/cron.hourly/ovslogrotate
chmod +x /etc/cron.hourly/ovslogrotate
|