Setup Centralized Rsyslog Server On CentOS 7
Setup Centralized Rsyslog Server On CentOS 7
This tutorial describes how to setup centralized Rsyslog server on CentOS 7 to manage the logs of your client systems from a common place. You don’t have to visit the client systems when you want to check the log files of your client systems. This can be useful if you have large number of systems on your network and want to do the log management from a centralized dedicated log server.
For the purpose of this guide, I will be using two systems, one acts as rsyslog server, and other acts as client. The following are the details of my test boxes.
Rsyslog Server:
- OS: CentOS 7 minimal edition
- IP address: 192.168.43.150/24
- Hostname: logserver.ostechnix.local
Client system:
- OS: CentOS 7 minimal edition
- IP Address: 192.168.43.151
First, let us setup Ryslog server.
Setup Centralized Rsyslog Server On CentOS 7
This guide was tested with CentOS 7 minimal server edition. However, it should work on all RPM based distributions like RHEL, Fedora, Scientific Linux.
All commands given below should run as root user.
Install rsyslog package if it is not installed already.
Then, edit rsyslog config file:
Find and uncomment the following to make your server to listen on the udp and tcp ports.
Save and close the file.
Allow Rsyslog default port 514 on your firewall/router. The following commands will open this port via firewalld.
Restart firewalld service to take effect the changes.
Finally, enable and start rsyslog service:
Check if the resyslog service is running or not with command:
If you see an output something lik below, congrats! Rsyslog server is up and working!
You can check log details of the server itself using command:
This command will display the last ten lines of your log messages.
Client configuration
Install rsyslog using command:
Then, edit rsyslog config file:
Under ##RULES## directive section, add the following line:
Or, just place this line at the end. This will log everything and send the log files to your Rsyslog server. You can also log particular items. Say for example, to log only cron stuffs, add the following line:
To log all the mail messages, add:
I want to log everything, so I added the following line.
You can also mention the FQDN of your Rsyslog server instead of IP address.
Save and close the rsyslog config file.
Finally, enable and start rsyslog service:
Similarly, you can configure as many as clients you want. to monitor the logs.
Testing log messages
Run anything on your client system.
I am going to run this:
Now, go to the Rsyslog server machine and check if this log is found.
Now, you will the logs of your client systems from the server.
And. that’s all. Rsyslog server and client configuration is done. As you can see in this guide, setting up a basic Rsyslog server is very easy.
Comments
Post a Comment