1.rsyslog ##此服务用来采集系统日志的,他不产生日志,只是起到采集作用
2 rsyslog的管理
/var/log/messages ##服务信息日志
/var/log/secure ##系统登陆日志
/var/log/cron ##定时任务日志
/var/log/maillog ##邮件日志
/var/log/boot.log ##系统启动日志
3日志的远程同步
在日志发送方:
vim /etc/rsyslog.conf
*.* @接收端ip ##"@"表示udp协议发送,“@@”表示tcp协议发送
systemctl restart rsyslog ##重启加载
在日志接受方
vim /etc/rsyslog.conf
systemctl restart rsyslog ##重启加载
然后
systemctl stop firewalld ##关闭火墙
systemctl disable firewalld ##设定火墙开机关闭
然后开始测试:
> /var/log/messages
在日志的发送方
cat /var/log/messages #查看日志已经生成
在日志接收方查看
cat /var/log/messages
4.时间同步服务
服务名称 chronyd
在服务端:
vim /etc/chrony.conf
22 allow 172.25.254.0/24 ##允许那些客户端来同步本机时间
29 local stratum 10 ##本机不同步任何主机的时间,本机作为时间源
systemctl restart chronyd ##重启服务
timedatectl set-timezone Asia/Shanghai ##更改当前时区为东8区
在客户端:
vim /etc/chrony.conf
server 172.25.254.203 iburst ##本机立即同步203主机的时间
systemctl restart chronyd
timedatectl set-timezone Asia/Shanghai ##更改当前时区为东8区
测试:
5. timedatectl 命令
timedatectl ##管理系统时间
timedatevtl status ##显示当前时间信息
set-time ##设定当前时间
set-timezone ##设定当前时区
set-local-rtc 0|1 ##设定是否使用utc时间
list-timezone ##查看支持的所有时区
journa
6. journalctl ##日志查看工具
-n 3 ##查看最近3条日志
-p err ##查看错误日志
-o verbose ##查看日志的详细参数
--since ##查看从什么时间开始的日志
--untill ##查看到什么时间为止的日志
7.如何使用 systemd-journald保存系统日志
默认systemd-journald是不保存系统日志到硬盘的 那么关机后再次开机只能看到本次开机之后的日志 上一次关机之前的日志是无法查看的
mkdir /var/log/journal
chgrp systemd-journal /var/log/journal
chmod g+s /var/log/journal
killall -1 systemd-journald
ls /var/log/journal
946cb08e817ea4ad0916183df8c4fc817