实验03:日志集中管理

【实验目标】

-----------A--------------B----------------

A:192.168.10.10     日志服务器

B:192.168.10.20     日志客户端

 配置需求

A作为服务端,集中保存客户机的日志

B作为测试客户端,将cron日志发送到服务端

 

【实验环境】

      开启2台Linux服务器

   设置网络为同一网段

   设置相同网段ip

   关闭防火墙

  

    【实验步骤】

    1、 liunx服务器A网络环境搭建

 [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

wKiom1PmHe_yseerAAE7d676CUQ746.jpg

 

关闭liunx服务器A防火墙

 [root@localhost ~]# iptables -F

[root@localhost ~]# service iptables save

 

测试主机之间的通信

[root@localhost ~]# ping -c 3 192.168.10.252

PING 192.168.10.252 (192.168.10.252) 56(84) bytes of data.

64 bytes from 192.168.10.252: icmp_seq=1 ttl=64 time=0.331 ms

64 bytes from 192.168.10.252: icmp_seq=2 ttl=64 time=0.229 ms

64 bytes from 192.168.10.252: icmp_seq=3 ttl=64 time=0.222 ms

 --- 192.168.10.252 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2001ms

rtt min/avg/max/mdev = 0.222/0.260/0.331/0.053 ms

 

2. 修改liunx服务器A日志文件

[root@localhost ~]# vim /etc/sysconfig/syslog

wKioL1PmIAmRktrmAAAziRPZ-YM127.jpg

   [root@localhost ~]# /etc/init.d/syslog restart

关闭内核日志记录器:                                       [确定]

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

启动系统日志记录器:                                       [确定]

启动内核日志记录器:                                       [确定]

[root@localhost ~]# chkconfig syslog on   

 

3.客户机B网络环境搭建

 [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

wKioL1PmIWvDrfRtAAFEaaaRVTA029.jpg

 [root@localhost ~]# /etc/init.d/network restart

 [root@localhost ~]# chkconfig network on

 

关闭客户机B的防火墙

[root@localhost ~]# iptables -F

[root@localhost ~]# service iptables save

 

测试主机之间通信

[root@localhost ~]# ping -c 3 192.168.10.253

PING 192.168.10.253 (192.168.10.253) 56(84) bytes of data.

64 bytes from 192.168.10.253: icmp_seq=1 ttl=64 time=0.246 ms

64 bytes from 192.168.10.253: icmp_seq=2 ttl=64 time=0.222 ms

64 bytes from 192.168.10.253: icmp_seq=3 ttl=64 time=0.216 ms

 --- 192.168.10.253 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2000ms

 rtt min/avg/max/mdev = 0.216/0.228/0.246/0.013 ms

 

4.客户机B日志主配置文件修改

[root@localhost ~]# vim /etc/syslog.confwKioL1PmIqKgGxLpAACPZzcYsXc141.jpg

 

5.结果验证

liunx服务器A

[root@localhost ~]# tail -f /var/log/cron

 Aug  9 19:19:13 192.168.10.252 crontab[4717]: (root) BEGIN EDIT (root)

Aug  9 19:20:05 192.168.10.252 crontab[4717]: (root) REPLACE (root)

Aug  9 19:20:05 192.168.10.252 crontab[4717]: (root) END EDIT (root)

[root@localhost ~]# date

2014 08 09星期六 19:21:27 CST

 

客户机B

[root@localhost ~]# crotab –e

wKiom1PmJTGTuu4IAADxKHJ3Dc0605.jpg