1、搭建网络日志系统,实现多台服务器的日志都集中保存到一台服务器中。并且能够看到所以服务器的配置命令。
#在server和client安装rsyslog.x86_64
yum install -y rsyslog.x86_64
#server端配置
vi /etc/rsyslog.conf
# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514
$template RemoteLogs,"/var/log/%HOSTNAME%/%PROGRAMNAM
%.log" *
*.* ?RemoteLogs
& ~
#client 端配置
vi /etc/rsyslog.conf
*.* @@192.168.1.142:514
vi /etc/bashrc
export PROMPT_COMMAND='{ msg=$(history 1 | { read x y; echo $y; });logger "[euid=$(whoami)]":$(who am i):[`pwd`]"$msg";}'
source /etc/bashrc
重启rsyslog服务
systemctl restart rsyslog.service
#之后就可以在server端的/var/log/message中查看了。