How to configure remote logging with rsyslog
Environment
- Red Hat Enterprise Linux 5 (RHEL5)
- Red Hat Enterprise Linux 6 (RHEL6) or later
- rsyslog
Issue
- How to configure remote logging with
rsyslog - How to configure system to accept remote log messages in Red Hat Enterprise Linux
- How to send remote log messages to another server with
rsyslog - How to configure RHEV Hypervisor for remote logging using
rsyslog
Resolution
In RHEL6 rsyslog is default logging daemon, in RHEL5 rsyslog is available but not installed by default.
-
Install
rsyslog# yum -y install rsyslog -
Configure
rsyslogusing TCP-
Configure the remote server to accept remote log messages using TCP.
Uncomment the following lines in the MODULES section of
/etc/rsyslog.conf, In RHEL5 you have to add the lines to beginning of/etc/rsyslog.conf:$ModLoad imtcp $InputTCPServerRun 514Restart rsyslog.
[root@server ~]# service rsyslog restartIn RHEL5 first stop the default
syslogdeamon and after that restartrsyslog.[root@server ~]# service syslog stop [root@server ~]# service rsyslog restart -
Configure the
rsyslogto sendrsyslogevents to another server using TCP.Add the following line to the RULES section of
/etc/rsyslog.confor in RHEL5 at the end of the/etc/rsyslog.conf:# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional $ActionQueueFileName fwdRule1 # unique name prefix for spool files $ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible) $ActionQueueSaveOnShutdown on # save messages to disk on shutdown $ActionQueueType LinkedList # run asynchronously $ActionResumeRetryCount -1 # infinite retries if host is down *.* @@10.10.10.1:514You can also specify the severity to send, for example info messages:
*.info @@10.10.10.1:514Restart rsyslog.
[root@client ~]# service rsyslog restartIn RHEL5 first stop the default
syslogdeamon and after that restartrsyslog.[root@client ~]# service syslog stop [root@client ~]# service rsyslog restart
-
-
Configure the remote server to accept remote log messages using UDP.
-
Configure the server to accept remote log messages using UDP.
Uncomment the following lines in the MODULES section of
/etc/rsyslog.conf, In RHEL5 you have to add the lines to beginning of/etc/rsyslog.conf:# Provides UDP syslog reception $ModLoad imudp $UDPServerRun 514Restart rsyslog.
[root@server ~]# service rsyslog restartIn RHEL-5 first stop the default
syslogdeamon and after that restart thersyslog.[root@server ~]# service syslog stop [root@server ~]# service rsyslog restart -
Configure the
rsyslogserver to sendrsyslogevents to another server using UDP.Add the following line to the RULES section of
/etc/rsyslog.confor in RHEL5 at the end of the/etc/rsyslog.conf:# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional #*.* @remote-host:514 *.* @10.10.10.1:514You can also specify the severity to send, for example info messages:
*.info @10.10.10.1:514Restart rsyslog.
[root@client ~]# service rsyslog restartIn RHEL5 first stop the default
syslogdeamon and after that restart thersyslog.[root@client ~]# service syslog stop [root@client ~]# service rsyslog restart
-
-
Test the configuration:
On client (
rsyslogsending out the messages):[root@client ~]# logger Test from system [root@client ~]# tail /var/log/messages Dec 25 00:00:01 client root: Test from systemOn server (
rsyslogreceiving the messages)[root@server ~]# tail /var/log/messages Dec 25 00:00:01 client root: Test from system -
While not specifically rsyslog related, additional selinux changes are required if you would like to run rsyslog on a non-standard port. this additional configuration is not necessary under normal usage. In place of 'tcp 514', use the alternate protocol and port you wish to use.
# semanage port -l| grep syslog
syslogd_port_t udp 514
# semanage port -a -t syslogd_port_t -p tcp 514
Note: when configuring remote logging, please make sure to also review and configure action queues in order to avoid potential issues when the remote rsyslog server is unreachable.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
