Files
2026-05-19 14:28:44 +08:00

56 lines
1.8 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

1 storage-1 X86/Intel Ubuntu Server 20.04 64bit 8 16 192.168.186.15 10.215.0.79 22022 SSD 50 SAS 20000 root RC1ezjGuK2
2 worker-2 X86/Intel Ubuntu Server 20.04 64bit 16 32 192.168.186.13 10.215.0.77 22022 SSD 50 SAS 200 root RC1ezjGuK2
3 worker-1 X86/Intel Ubuntu Server 20.04 64bit 16 32 192.168.186.12 39.129.174.92(公网) 22022 SSD 50 SAS 200 root RC1ezjGuK2 雷视
4 worker-3 X86/Intel Ubuntu Server 20.04 64bit 16 32 192.168.186.14 10.215.0.78 22022 SSD 50 SAS 200 root RC1ezjGuK2 mysql
5 master-node X86/Intel Ubuntu Server 20.04 64bit 8 16 192.168.186.11 39.129.174.66(公网共享100M) 22022 SSD 50 SAS 300 root RC1ezjGuK2 harbor
master
192.168.186.98
host_list=(
192.168.186.11
192.168.186.15
192.168.186.13
192.168.186.12
192.168.186.14
)
for server in "${host_list[@]}"; do
echo "===== current ip is $server ====="
ssh -p 22022 root@${server} '
CONF_FILE="/etc/rsyslog.conf"
TARGET="*.*\t@192.168.186.98"
# 判断是否已存在
grep -q "@192.168.186.98" $CONF_FILE
if [ $? -eq 0 ]; then
echo "配置已存在,跳过"
else
echo "开始写入配置..."
# 在最后一行前插入
sed -i "\$i *.*\t@192.168.186.98" $CONF_FILE
echo "重启 rsyslog..."
systemctl restart rsyslog.service
fi
'
echo ""
done
执行vi /etc/rsyslog.conf
在最后一行上面添加*.* @192.168.186.98。添加完成后保存退出。注:*.*与@之间按tab键生成空格@后面跟的IP为日志审计IP
执行systemctl restart rsyslog.service重启日志服务如第一次添加需要联系云运维人员登陆到日志审计中添加日志源。
for server in "${host_list[@]}"; do
echo "===== check config on $server ====="
ssh -p 22022 root@${server} "grep '@192.168.186.98' /etc/rsyslog.conf"
echo ""
done