首页 > 其他 > 详细

CentOS 7安装NXLog服务

时间:2020-05-17 16:46:55      阅读:207      评论:0      收藏:0      [点我收藏+]

NXLog是一个跨平台日志传输插件,支持linux、windows平台的大部分系统日志及常见的web日志,支持tcp、udp、http(s)等协议传输。本文介绍NXLog在CentOS 7服务器上的安装,以及运行om_dbi/im_dbi所需插件的安装。

操作系统环境:CentOS Linux release 7.6.1810 (Core)

NXLog版本:nxlog-ce-2.10.2150

 

一、安装NXLog

由于yum中没有直接提供NXLog,因此需要在https://nxlog.co/products/nxlog-community-edition/download下载对应操作系统的rpm后,上传至服务器进行安装,当然也可以直接利用wget下载安装。。

//切换到下载路径
# cd /usr/local/

//下载rpm
# wget https://nxlog.co/system/files/products/files/348/nxlog-ce-2.10.2150-1_rhel7.x86_64.rpm

NXLog安装依赖apr和libdbi,如果未安装会报错。

# rpm -ivh nxlog-ce-2.10.2150-1_rhel7.x86_64.rpm 
错误:依赖检测失败:
    apr >= 1.2 被 nxlog-ce-2.10.2150-1.x86_64 需要
    libapr-1.so.0()(64bit) 被 nxlog-ce-2.10.2150-1.x86_64 需要
    libdbi >= 0.8.1 被 nxlog-ce-2.10.2150-1.x86_64 需要
    libdbi.so.0()(64bit) 被 nxlog-ce-2.10.2150-1.x86_64 需要

通过yum安装apr和libdbi

# yum install apr
软件包 apr.x86_64.0.1.4.8-5.el7 将被 安装
...

# yum install libdbi
软件包 libdbi.x86_64.0.0.8.4-6.el7 将被 安装
...

依赖组件安装完成后,再安装NXLog就成功了

# rpm -ivh nxlog-ce-2.10.2150-1_rhel7.x86_64.rpm 
准备中...                          ################################# [100%]
正在升级/安装...
   1:nxlog-ce-2.10.2150-1             ################################# [100%]

安装完成后,查看程序安装路径位于/usr/bin/nxlog,配置文件位于/etc/nxlog.conf,至此就安装完毕了。

# whereis nxlog
nxlog: /usr/bin/nxlog /etc/nxlog.conf /usr/libexec/nxlog

 

二、libdbi及驱动的安装

本文的实际场景需要将通过syslog获取的日志同时存储到文件和数据库MySQL,同时需要转发到其他的syslog服务器,因此需要在配置文件中使用到im_udp、om_file、om_udp和om_dbi几个模块。根据官方文档说明, 在linux系统中,im_dbi和om_dbi模块依赖于libdbi库,而在windows环境下im_odbc和om_odbc模块可提供原生的数据库访问,但是只有NXLog的企业版才支持(CE版不支持)。

libdbi需要通过数据库驱动程序来访问对应的数据库,而在CentOS环境下,虽然已经安装了libdbi,但是其中并不包含有任何驱动,因此需要进行安装。

The im_dbi and om_dbi modules support GNU/Linux only because of the libdbi library. The im_odbc and om_odbc modules provide native database access on Windows (available only in NXLog Enterprise Edition).
libdbi needs drivers to access the database engines. These are in the libdbd-* packages on Debian and Ubuntu. CentOS 5.6 has a libdbi-drivers RPM package, but this package does not contain any driver binaries under /usr/lib64/dbd. The drivers for both MySQL and PostgreSQL are in libdbi-dbd-mysql. If these are not installed, NXLog will return a libdbi driver initialization error.

# yum install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

 

三、修改配置文件,启动NXLog

NXLog的配置文件位于/etc/nxlog.conf,可参考官方手册对其中的各个模块进行编辑。

配置完成后,通过以下方法启动、停止服务。

systemctl start nxlog   //启动服务
systemctl stop nxlog    //停止服务
systemctl enable nxlog  //开机启动服务
systemctl status nxlog  //查看服务状态,显示active(running)表明服务已经运行了

 

四、防火墙中加入514端口(UDP/TCP)

# firewall-cmd --permanent --add-port=514/udp
# firewall-cmd --permanent --add-port=514/tcp

 

五、关于libdbi及驱动安装的弯路

 

参考资料:

1. Centos7安装nxlog-2.9 

2. libdbi-users — General libdbi discussion and support

3. libdbi-drivers

4. Centos7安装Typecho详细教程

5. NXLog - Forwarding and Storing Logs

CentOS 7安装NXLog服务

原文:https://www.cnblogs.com/yangjisen/p/12905076.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!