§2024-05-30
The replicationSet odroid-01 has a srv record of
% dig +short SRV _mongodb._tcp.inLaneCatch.yushei.com.tw
0 0 27017 n2Jammy.yushei.com.tw. --> 192.168.2.177
0 0 27017 n2Boookworm.yushei.com.tw. --> 192.168.2.239
0 0 27017 x8664Arch.yushei.com.tw. --> 192.168.2.132
0 0 27017 hc4Jammy.yushei.com.tw. --> 192.168.2.195
All the log file will be logged into @hc4Jammy.yushei.com.tw, /var/log/mongoDB-odroid-01.log .
This documents how it were done.
- for example at x8664Arch.yushei.com.tw
$ sudo pacman -S syslog-ng # sudo apt install syslog-ng
In ArchLinux
[alexlai@x8664Arch ~]$ sudo systemctl enable syslog-ng@default
Created symlink /etc/systemd/system/multi-user.target.wants/syslog-ng@default.service → /usr/lib/systemd/system/syslog-ng@.service.
[alexlai@x8664Arch ~]$ sudo systemctl status syslog-ng@default
○ syslog-ng@default.service - System Logger Daemon "default" instance
Loaded: loaded (/usr/lib/systemd/system/syslog-ng@.service; enabled; preset: disabled)
Active: inactive (dead)
Docs: man:syslog-ng(8)
[alexlai@x8664Arch ~]$ syslog-ng --version
syslog-ng 4 (4.6.0)
Config version: 4.2
Installer-Version: 4.6.0
Revision:
Compile-Date: May 24 2024 16:10:11
Module-Directory: /usr/lib/syslog-ng
Module-Path: /usr/lib/syslog-ng
Include-Path: /usr/share/syslog-ng/include
Error opening plugin module; module='geoip2-plugin', error='libmaxminddb.so.0: cannot open shared object file: No such file or directory'
Error opening plugin module; module='afsnmp', error='libnetsnmp.so.40: cannot open shared object file: No such file or directory'
Error opening plugin module; module='afsql', error='libdbi.so.1: cannot open shared object file: No such file or directory'
Error opening plugin module; module='redis', error='libhiredis.so.1.1.0: cannot open shared object file: No such file or directory'
Error opening plugin module; module='afamqp', error='librabbitmq.so.4: cannot open shared object file: No such file or directory'
Error opening plugin module; module='kafka', error='librdkafka.so.1: cannot open shared object file: No such file or directory'
Error opening plugin module; module='afsmtp', error='libesmtp.so.6.2.0: cannot open shared object file: No such file or directory'
Available-Modules: graphite,bigquery,hook-commands,sdjournal,tags-parser,afprog,otel,correlation,affile,confgen,stardate,cryptofuncs,basicfuncs,afmongodb,linux-kmsg-format,disk-buffer,kvformat,azure-auth-header,tfgetent,timestamp,syslogformat,regexp-parser,afuser,add-contextual-data,pseudofile,metrics-probe,mod-python,system-source,csvparser,appmodel,rate-limit-filter,map-value-pairs,http,afstomp,json-plugin,xml,examples,cloud_auth,afsocket,cef,secure-logging,loki
Enable-Debug: off
Enable-GProf: off
Enable-Memtrace: off
Enable-IPv6: on
Enable-Spoof-Source: on
Enable-TCP-Wrapper: off
Enable-Linux-Caps: on
Enable-Systemd: on
- setup
/etc/syslog-ng/syslog-ng.conf
$ sudo cp -v /etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf.backup
'/etc/syslog-ng/syslog-ng.conf' -> '/etc/syslog-ng/syslog-ng.conf.backup'
- /etc/syslog-ng/syslog-ng.conf, as
@version: 4.6.0
@include "scl.conf"
options {
keep-hostname(yes);
};
# Sources
source s_mongo_log {
file("/opt/package/mongoDB/log/mongod.log" flags(no-parse));
};
# Destination
destination d_mongoDB {
syslog("hc4Jammy.yushei.net" transport("udp") port(514));
};
# Log Statements
log {
source(s_mongo_log);
# parser {
# json-parser(prefix("json."));
# };
destination(d_mongoDB);
};