环境:
-
OS:sles11sp2
-
Server IP : 192.168.1.1
-
sysadmin邮箱:sysadmin@abc.com
目标:
-
1台log server,其他的都是log client。
-
log cliens会将它的所有log发送给log server。
-
log server会将需要发送给root的邮件转发到sysadmin的邮箱中。
解决方案:
log client 端
-
修改 /etc/syslog-ng/syslog-ng.conf
-
# vi /etc/syslog-ng/syslog-ng.conf
-
-
+# Setup the remote logging destination
-
-
+destination loghost {
-
+udp ( "192.168.1.1" port(514)); #输入server的ip和端口
-
+};
-
-
+# Send everything to the remote loghost
-
+log {
-
+source(src); destination(loghost);
-
+};
2. 然后重启syslog, rcsyslog restart
log server 端
-
修改 /etc/syslog-ng/syslog-ng.conf
-
source src {
-
#
-
# include internal syslog-ng messages
-
# note: the internal() soure is required!
-
#
-
internal();
-
-
#
-
# the following line will be replaced by the
-
# socket list generated by SuSEconfig using
-
# variables from /etc/sysconfig/syslog:
-
#
-
unix-dgram("/dev/log");
-
-
#
-
# uncomment to process log messages from network:
-
#
-
+udp(ip("0.0.0.0") port(514));
-
-
+tcp(port(514)
-
+max-connections(500) );
-
};
-
重启syslog, rcsyslog restart
-
修改 /etc/aliases文件使发到root的邮件还会发送到sysadmin的邮箱中
-
#vi /etc/aliases
-
+root: sysadmin@abc.com, \root # "\root"表示原本发给root的邮件除了发给sysadmin,还是要发给root。
-
具体的邮件配置文件为/etc/postfix/main.cf,可以配置host_relay,一些配置文件的路径。
阅读(951) | 评论(0) | 转发(0) |