基于CentOS yum的syslog-ng安装

1.有以下命令可以查看CentOS 版本:

[root@logsys0 data]# lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:    CentOS
Description:    CentOS release 6.3 (Final)
Release:    6.3
Codename:    Final

2.下载安装EPEL源

Centos 5.x

[root@logsys0 data]#  wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Centos 6.x

[root@logsys0 data]#  wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

[root@logsys0 data]# rpm -ivh epel-release-6-8.noarch.rpm3. 安装syslog-ng

[root@logsys0 data]# yum --enablerepo=epel install syslog-ng eventlog syslog-ng-libdbi

设置变更:vim /etc/syslog-ng/syslog-ng.conf[root@logsys0 data]# chkconfig rsyslog off; chkconfig syslog-ng on

[root@logsys0 data]# service rsyslog stop;service syslog-ng start

关闭系统日志记录器:                                      [确定]

启动 syslog-ng:                                          [确定]
#重新加载配置:service syslog-ng reload
安装成功

4. 开启防火墙80和514端口

vi /etc/sysconfig/iptables

添加两条规则

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 514 -j ACCEPT

配置文件如下:

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT

-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 514 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Syslog-ng 的详细介绍:请点这里
Syslog-ng 的下载地址:请点这里

相关阅读

相关推荐