Cloud Native应用交付

  • 首页
  • 关于本站
  • 个人介绍
  • Downloads
  • Repo
    • Github
    • Container
  • F5
    • F5 Python SDK
    • F5-container
    • F5-LBaaS
  • 社交
    • 联系我
    • 微信/微博
    • 公众号
    • 打赏赞助
行至水穷处 坐看云起时
Cloud Native Application Services: cnadn.net
  1. 首页
  2. F5技术
  3. 正文

扫盲计划之:log&syslog

2010年08月17日 12950点热度 0人点赞 1条评论

GUI下的log显示有:

system---------->/var/log/messages

packer filter ------------->/var/log/pktfilter

Local traffic-------------->/var/log/ltm

audit----------------->/var/log/audit

打开GUI下的审计需要打开MCP审计功能并确保MCP的日志级别不高于notice

打开b 命令的审计则需打开bigpipe的审计

在/var/log 下其实还有很多其他日志文件

------------------------------------------------------

使用logtool可以快速的在所有日志中查找感兴趣的日志,使用方法如下

[root@v10-1:Active] log # logtool --help
Unknown option: help
Usage: /usr/bin/logtool [options] ["<SearchString>"]
Options:
--filename:    Append the log file name to the message
--level=LEVEL: Search for messages at a level
--system=NAME: Search for messages from a system
--slot=NUMBER: Search for messages from a slot
--zipped:      Search for messages in compressed log files

注意searchstring是区分大小写的。

----------------------------------------

在命令行下查看日志时候可以通过增加 bigcodes 管道来解析F5一些专用的抽象代码,例如

cat /var/log/ltm | bigcodes |less

----------------------------------------

resize-logFS 可以用来resize 给/var/log预分配的固定空间,默认是7G,可配区间是1-10G

--------------------

配置syslog-ng将log发送到远程syslog服务器

9.4.2之前手工编辑/etc/syslog-ng/syslog-ng.conf

9.4.2--9.4.6用 b命令配置syslog

9.4.2--9.4.6中用b syslog remote server 命令只能配置一个目标服务器,且不能指定协议,所以必须用b syslog include命令来配置(SOL8259),但这个版本区间用b syslog include配置多个目标服务器又可能会在log中提示错误(SOL8549),所有的问题都在V10中解决,v10中关于syslog的配置命令进行了增强。

9.4.2--9.4.6中b syslog include 配置方法:

bigpipe syslog include '"destination <dest_name> { <protocol>(\"<syslog_ip_address>\" port(<syslog_port>));};log { source(local); destination(<dest_name>);};"'

Replace <dest_name> with a unique name for the new log destination object, <protocol> with the desired transport protocol (UDP or TCP), <syslog_ip_address> with the IP address of the destination remote syslog server, and <syslog_port> with the port upon which the remote syslog service is listening. The tuple of <protocol>(\"<syslog_ip_address>\" port (<syslog_port>)) may be repeated as necessary, separated by semicolons, to configure multiple destinations.

For example, the following bigpipe syslog include command adds a remote UDP syslog server with the IP address of 10.0.0.1:

bigpipe syslog include '"destination d_udp { udp(\"10.0.0.1\" port(514));};log { source(local); destination(d_udp);};"'

The following bigpipe syslog include command adds two remote TCP syslog servers:

bigpipe syslog include '"destination d_tcp { tcp(\"10.0.0.1\" port(1468)); tcp(\"10.0.0.2\" port(1468));};log { source(local); destination(d_tcp);};"'

V10后使用 b syslog remote server配置方法:

  • Adding a single remote server:

bigpipe syslog remote server {<name> {host <addr_or_hostname>}}

  • Adding multiple remote servers:

bigpipe syslog remote server {<name1> {host <addr_or_hostname>} <name2> {host <addr_or_hostname>} ... }

  • Deleting a single remote server:bigpipe syslog remote server <name> delete
  • Deleting multiple remote servers:bigpipe syslog remote server {<name1> <name2> ... } delete
  • Deleting all remote servers:bigpipe syslog remote server none

配置举例V10:

b syslog remote server server1 host 192.168.192.90 server2 host 192.168.192.91

加完后,做一下b save,然后www.myf5.net在bigip_sys.conf下可以看到:

syslog {
remote server {
server1 {
host 192.168.192.90
}
server2 {
host 192.168.192.91
}
}
}

最终在syslog-ng.conf中表示如下:

# Log to a remote host
destination d_loghost {
udp("192.168.192.90" port(514));
udp("192.168.192.91" port(514));
};

log {
source(s_syslog_pipe);
destination(d_loghost);
};

指定syslog服务器端口:

b syslog remote server server1 remote port 5114

b save

在bigip_sys.conf效果如下:

syslog {
remote server {
server1 {
host 192.168.192.90
remote port 5114
}
server2 {
host 192.168.192.91
}
}
}

指定syslog服务器协议:

就得用include方法了。。。

------------------------

注意点:

v9中log 的source是 source(local),v10中改为 source(s_syslog_pipe)

如果遇到syslog服务器关于包大小处理问题,在V944版本之后,通过一个db值可以调整

bigpipe db Tmm.MaxRemoteLogLength <size>

------------------------

缺省情况下,F5根据路由情况来决定syslog发出的包的源地址,TMM缺省路由是优先于MGMT缺省路由的,这一点需特别注意。如果遇到包从不期望的接口发出去,那么需要考虑调整路由,一般来说定义关于syslog服务器的明细路由能比较有效的控制,例如可以定义明细路由从管理口的下一跳出去,这样包的源地址就是MGMT口的地址了。

如果需要绑定一个地址作为包的源地址,可以参考如下配置:

b syslog remote server server1 local ip 172.24.111.111

# Log to a remote host
destination d_loghost {
udp("192.168.192.90" port(514) localip(172.24.111.111));
};

log {
source(s_syslog_pipe);
destination(d_loghost);
};

如果绑定的IP有问题,会导致日志无法发出,可能重启syslog-ng都不会显示有问题,但此时在/var/log/boot.log里会看到相关错误:

Aug 16 23:44:25 local/v10-1 notice syslog-ng: Error binding socket; addr='AF_INET(172.24.111.111:0)', error='Cannot assign requested address (99)'
Aug 16 23:44:25 local/v10-1 notice syslog-ng: Initiating connection failed, reconnecting; time_reopen='60'
Aug 16 23:44:25 local/v10-1 notice syslog-ng: syslog-ng startup succeeded

b syslog remote server server1 local ip none 可以清除掉之前的绑定,要绑定的IP必须是F5上已经存在的IP

绑定IP 并不能因此影响包从TMM还是从MGMT发出,例如绑定TMM上的地址,但路由依然是从MGMT走,则此时的包是以TMM的地址作为SRC IP 并从MGMT口出去,这一点需要注意。

另外用local 参数指定的IP 实际存储在/etc/confpp.dat里,该文件并不会保存在ucs中,因为用ucs恢复系统后,该配置会丢失 (v10.2.2之后,include方式配置的内容将被存储在bigip_base.conf, 不再存储在bigip_sys.conf里, 我晕)

[root@v10-1:Active] log # b syslog remote server list
syslog {
remote server server1 {
host 192.168.192.90
local ip 10.17.0.254
remote port 514
}
}

不想让log存到F5本地 怎么办:

(能不要这么做就不要这么做),必须做的话,步骤如下

1. mount -o remount,rw /usr

2.pico /usr/share/defaults/config/templates/syslog.tmpl

3.例如将boot.log的日志不写到文件,只发送给syslog server

#destination d_boot {
#   file("/var/log/boot.log" create_dirs(yes));
#};
#edit for testing
destination d_boot {
udp("192.168.192.90" port(514));
};

4.mount -o rmoute,ro /usr

5.bigstart restart syslog-ng

------------------------------------

定义指定的log到syslog:

使用include定义filter,例如发送tamd产生的日志到指定的服务器:

bigpipe syslog include '"destination d_udp_tamd { udp(\"10.0.0.1\" port(514)); udp(\"10.0.0.2\" port(514));};filter f_tamd { program(tamd) ;};log { source(s_syslog_pipe);filter (f_tamd);destination(d_udp_tamd);};"'

此命令等同于直接在配置文件中增加include内容,所以可以参考syslog-ng的配置语法灵活定义

----------------

logsave :

NAME
logsave - save the output of a command in a logfile

SYNOPSIS
logsave [ -asv ] logfile cmd_prog [ ... ]

DESCRIPTION
The logsave program will execute cmd_prog with the specified argument(s), and save a copy of its output to log-
file.  If the containing directory for logfile does not exist, logsave will accumulate  the  output  in  memory
until it can be written out.  A copy of the output will also be written to standard output.

If  cmd_prog  is  a  single hyphen ('-'), then instead of executing a program, logsave will take its input from
standard input and save it in logfile

logsave is useful for saving the output of initial boot scripts until the /var partition  is  mounted,  so  the
output can be written to /var/log.

OPTIONS
-a     This  option will cause the output to be appended to logfile, instead of replacing its current contents.

-s     This option will cause logsave to skip writing to the log file text which is bracketed with a  control-A
(ASCII  001  or  Start  of Header) and control-B (ASCII 002 or Start of Text).  This allows progress bar
information to be visible to the user on the console, while not being written to the log file.

-v     This option will make logsave to be more verbose in its output to the user.

相关文章

  • F5常见log日志解释
  • 项目:k8s Gateway API 的BIG-IP实现
  • CIS增强版在线文档
  • F5-k8s解决方案(2)-基于Calico BGP网络的F5 k8s容器平台方案实践
  • openstack heat模板之配置基本LB到F5 BIGIP
本作品采用 知识共享署名-非商业性使用 4.0 国际许可协议 进行许可
标签: F5 linux log syslog
最后更新:2011年07月13日

纳米

linjing.io

打赏 点赞
< 上一篇
下一篇 >

文章评论

  • ipneter

    好东西,学习了。

    2010年09月8日
    回复
  • razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
    取消回复

    这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。

    页面AI聊天助手
    文章目录
    • 配置举例V10:

    纳米

    linjing.io

    ☁️迈向Cloud Native ADC ☁️

    认证获得:
    TOGAF: ID 152743
    Kubernetes: CKA #664
    Microsoft: MCSE MCDBA
    Cisco: CCNP
    Juniper: JNCIS
    F5:
    F5 Certified Solution Expert, Security
    F5 Certified Technology Specialist, LTM/GTM/APM/ASM
    F5 Certified BIG-IP Administrator
  • 点击查看本博技术要素列表
  • 归档
    分类
    • AI
    • Automation
    • Avi Networks
    • Cisco ACI
    • CISCO资源
    • F5 with ELK
    • F5-Tech tips
    • F5技术
    • Juniper
    • Linux
    • NGINX
    • SDN
    • ServiceMesh
    • WEB编程
    • WINDOWS相关
    • 业界文章
    • 交换机技术
    • 化云为雨/Openstack
    • 协议原理
    • 容器/k8s
    • 我的工作
    • 我的生活
    • 网站技术
    • 路由器技术
    • 项目案例
    标签聚合
    k8s DNS gtm network bigip neutron istio flannel F5 docker nginx api openstack envoy irule
    最近评论
    汤姆 发布于 9 个月前(09月10日) 嗨,楼主,里面的json怎么下载啊,怎么收费啊?
    汤姆 发布于 9 个月前(09月09日) 大佬,kib的页面可以分享下吗?谢谢
    zhangsha 发布于 1 年前(05月12日) 资料发给我下,谢谢纳米同志!!!!lyx895@qq.com
    李成才 发布于 1 年前(01月02日) 麻烦了,谢谢大佬
    纳米 发布于 1 年前(01月02日) 你好。是的,因为以前下载系统插件在一次升级后将所有的下载生成信息全弄丢了。所以不少文件无法下载。DN...
    浏览次数
    • Downloads - 184,538 views
    • 联系我 - 118,966 views
    • 迄今为止最全最深入的BIGIP-DNS/GTM原理及培训资料 - 117,889 views
    • Github - 104,511 views
    • F5常见log日志解释 - 80,069 views
    • 从传统ADC迈向CLOUD NATIVE ADC - 下载 - 75,944 views
    • Sniffer Pro 4 70 530抓包软件 中文版+视频教程 - 74,320 views
    • 迄今为止最全最深入的BIGIP-DNS/GTM原理及培训资料 - 67,770 views
    • 关于本站 - 61,409 views
    • 这篇文档您是否感兴趣 - 55,724 views
    链接表
    • F5SE创新
    • Jimmy Song‘s Blog
    • SDNlab
    • Service Mesh社区
    • 三斗室
    • 个人profile
    • 云原生社区

    COPYRIGHT © 2023 Cloud Native 应用交付. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang

    京ICP备14048088号-1

    京公网安备 11010502041506号