900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > nxlog日志采集

nxlog日志采集

时间:2022-04-30 17:41:52

相关推荐

nxlog日志采集

一、nxlog 简介

nxlog 是一个模块化、多线程、高性能的日志管理解决方案,支持多平台,可实现各类操作系统及其中间件的日志采集和管理

二、nxlog官网下载地址

2.1 社区版官网下载地址:NXLog Community Edition - Downloads | nxlog.co

2.2下载相应的系统版本

1) Centos 6.x

wget --no-check-certificate https://nxlog.co/system/files/products/files/348/nxlog-ce-2.10.2150-1_rhel6.x86_64.rpm

2)Centos 7.x

wget --no-check-certificate https://nxlog.co/system/files/products/files/348/nxlog-ce-3.0.2272-1_rhel7.x86_64.rpm

3)Centos 8.x

wget --no-check-certificate https://nxlog.co/system/files/products/files/348/nxlog-ce-3.0.2272_rhel8.x86_64.rpm

4) Ubuntu 18.04

wget --no-check-certificate https://nxlog.co/system/files/products/files/348/nxlog-ce_3.0.2272_ubuntu_bionic_amd64.deb

三、安装nxlog及依赖环境

3.1 Centos 6.x

yum install apr libdbi* -y #安装依赖环境(yum源不可用转步骤四)rpm -ivh nxlog-ce-2.10.2150-1_rhel6.x86_64.rpm #安装rpm包

3.2Centos 7.x

yum install apr libdbi libpython3.6m.so.1.0 -y #安装依赖环境rpm -ivh nxlog-ce-3.0.2272-1_rhel7.x86_64.rpm #安装rpm包

3.3Centos 8.x

yum install apr libdbi* libperl.so.5.26 -y #安装依赖环境(yum源不可用转步骤四)rpm -ivh nxlog-ce-3.0.2272-1_rhel7.x86_64.rpm #安装rpm包

3.4Ubuntu 18.04

sudo dpkg -i nxlog-ce_3.0.2272_ubuntu_bionic_amd64.deb #安装deb包,提示需依赖环境sudo apt-get --fix-broken install #解决并安装依赖环境sudo dpkg -i nxlog-ce_3.0.2272_ubuntu_bionic_amd64.deb #再次安装deb包

* Centos6.x 8.x 官方yum源已下线。如系统本身yum源失效, 不能安装依赖环境,需更换第三方源或搭建本地yum源。

四、解决Centos6.x 8.x yum源失效问题

4.1 Centos6.x 更换阿里云yum源

curl -o /etc/yum.repos.d/CentOS-Base.repo /repo/Centos-vault-6.10.repo #更换阿里yum源yum clean all #清除缓存yum makecache #重新建立缓存

4.2Centos 8.x 更换阿里云yum源

mv /etc/yum.repos.d /etc/yum.repos.d.bak #备份原有yum源目录mkdir -p /etc/yum.repos.d#创建新的yum源目录curl -o /etc/yum.repos.d/CentOS-Base.repo /repo/Centos-vault-8.5.2111.repo #更换阿里yum源curl -o /etc/yum.repos.d/epel-archive-8.repo /repo/epel-archive-8.repo #添加阿里epel yum源yum clean all #清除缓存yum makecache #重新建立缓存

五、nxlog 服务管理及卸载

5.1Centos 6.x

service nxlog start #启动service nxlog stop #停止service nxlog restart #重启service nxlog status #查看运行状态

5.2Centos 7.x 8.x

systemctl start nxlog#启动systemctl stop nxlog#停止systemctl restart nxlog #重启systemctl status nxlog #查看运行状态

5.3Ubuntu

sudo systemctl start nxlog #启动sudo systemctl stop nxlog #启动sudo systemctl restart nxlog #重启sudo systemctl status nxlog #查看运行状态

5.4配置及日志文件

/etc/nxlog.conf#Centos6.x默认配置文件路径/etc/nxlog nxlog.conf#Centos7.x 8.x ubuntu 默认配置文件路径 /var/log/nxlog/nxlog.log #nxlog本身日志默认存放路径,用于调试和排错

5.6卸载nxlog

yum remove 'nxlog-*' -y #Centos6.x 7.x 8.xsudo apt-get remove '^nxlog*' -y #Ubuntu

六、防火墙放行nxlog服务

6.1 Centos 6.x

iptables -I INPUT -p udp --dport 514 -j ACCEPT #放行udp 514端口iptables -I OUTPUT -p udp --sport 514 -j ACCEPT #放行udp 514端口service iptables save #保存防火墙规则service iptables restart #重启防火墙

6.2 Centos 7.x 8x

firewall-cmd --zone=public --add-port=514/udp --permanent #放行udp 514端口firewall-cmd --reload #重新加载防火墙策略firewall-cmd --zone=public --list-ports #查看放行的端口systemctl restart firewalld #重启防火墙

6.3 Ubuntu

udo ufw allow 514 #放行udp 514端口sudo ufw status#查看放行的端口及规则sudo ufw reload#重新加载防火墙策略

七、nxlog 采集Apache错误日志示例

编辑nxlog配置文件在Modules模块 <Input apache_error_in></Input> 和 <Output Apache_error_out> 中分别填写apache错误日志文件路径和输出的日志服务器地址及端口。Routes模块添加Path参数。 (红色部分名称自定义)

######################################### Global directives#########################################User nxlogGroup nxlogLogFile /var/log/nxlog/nxlog.logLogLevel INFONocache True######################################### Modules#########################################<Extension _syslog>Modulexm_syslog</Extension><Input apache_error_in>SavePos falseReadfromlast falseModule im_fileFile "/var/log/apache/error.log"</Input><Output apache_error_out>Module om_tcpHost 10.19.21.100Port 514</Output>######################################### Routes ##########################################<Route apache_error_route>Path apache_error_in => apache_error_out</Route>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。