linux中nxup服务,CentOS 7安装NXLog服务
NXLog是一個(gè)跨平臺(tái)日志傳輸插件,支持linux、windows平臺(tái)的大部分系統(tǒng)日志及常見的web日志,支持tcp、udp、http(s)等協(xié)議傳輸。本文介紹NXLog在CentOS 7服務(wù)器上的安裝,以及運(yùn)行om_dbi/im_dbi所需插件的安裝。
操作系統(tǒng)環(huán)境:CentOS Linux release 7.6.1810 (Core)
NXLog版本:nxlog-ce-2.10.2150
一、安裝NXLog
由于yum中沒有直接提供NXLog,因此需要在https://nxlog.co/products/nxlog-community-edition/download下載對(duì)應(yīng)操作系統(tǒng)的rpm后,上傳至服務(wù)器進(jìn)行安裝,當(dāng)然也可以直接利用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,如果未安裝會(huì)報(bào)如下錯(cuò)誤。
# rpm -ivh nxlog-ce-2.10.2150-1_rhel7.x86_64.rpm
錯(cuò)誤:依賴檢測(cè)失敗:
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
準(zhǔn)備中... ################################# [100%]
正在升級(jí)/安裝...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及驅(qū)動(dòng)的安裝
本文的實(shí)際場(chǎng)景需要將通過syslog獲取的日志同時(shí)存儲(chǔ)到文件和數(shù)據(jù)庫(kù)MySQL,同時(shí)需要轉(zhuǎn)發(fā)到其他的syslog服務(wù)器,因此需要在配置文件中使用到im_udp、om_file、om_udp和om_dbi幾個(gè)模塊。根據(jù)官方文檔說明,?在linux系統(tǒng)中,im_dbi和om_dbi模塊依賴于libdbi庫(kù),而在windows環(huán)境下im_odbc和om_odbc模塊可提供原生的數(shù)據(jù)庫(kù)訪問,但是只有NXLog的企業(yè)版才支持(CE版不支持)。
libdbi需要通過數(shù)據(jù)庫(kù)驅(qū)動(dòng)程序來訪問對(duì)應(yīng)的數(shù)據(jù)庫(kù),而在CentOS環(huán)境下,雖然已經(jīng)安裝了libdbi,但是其中并不包含有任何驅(qū)動(dòng),因此需要進(jìn)行安裝。
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
三、修改配置文件,啟動(dòng)NXLog
NXLog的配置文件位于/etc/nxlog.conf,可參考官方手冊(cè)對(duì)其中的各個(gè)模塊進(jìn)行編輯。
配置完成后,通過以下方法啟動(dòng)、停止服務(wù)。
systemctl start nxlog //啟動(dòng)服務(wù)
systemctl stop nxlog //停止服務(wù)
systemctl enable nxlog //開機(jī)啟動(dòng)服務(wù)
systemctl status nxlog //查看服務(wù)狀態(tài),顯示active(running)表明服務(wù)已經(jīng)運(yùn)行了
四、防火墻中加入514端口(UDP/TCP)
# firewall-cmd --permanent --add-port=514/udp
# firewall-cmd --permanent --add-port=514/tcp
如果用不到tcp可以不添加tcp的,添加端口后需要重啟防火墻。
五、關(guān)于libdbi及驅(qū)動(dòng)安裝的彎路
因?yàn)樾枰惭blibdbi的驅(qū)動(dòng),之前通過yum安裝的libdbi的版本為0.8.4,在sourceforge上查詢到其最新版本為0.9.0,因此想更新一下。
而將文件包下載后放到服務(wù)器上,在./configure時(shí),一直提示“Invalid libdbi directory - include files not found.”。查找了幾種可能性:
可能性1:autoconf的版本太高,libdbi只支持autoconf-2.13版本,在其官方文檔末尾?http://libdbi-drivers.sourceforge.net/docs/dbd_mysql.pdf?中有提及。
然而上述2種方法都沒有奏效,最后還是在參考資料4中找到了類似安裝libdbis mysql drivers的方法,成功解決。
參考資料:
總結(jié)
以上是生活随笔為你收集整理的linux中nxup服务,CentOS 7安装NXLog服务的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 当前最流行的Javaweb框架有哪些?
- 下一篇: Fastjson 远程命令执⾏漏洞