CentOS7 /var/log/messages Starting Session x of user root

Logs flooded with systemd messages: Created slice & Starting Session


官方网站:


Environment

  • Red Hat Enterprise Linux 7

Issue

  • On my RHEL7 newely installed system I am seeing the following in /var/log/messages all the time

    Jul 24 08:50:01 example.com systemd: Created slice user-0.slice.
    Jul 24 08:50:01 example.com systemd: Starting Session 150 of user root.
    Jul 24 08:50:01 example.com systemd: Started Session 150 of user root.
    Jul 24 09:00:01 example.com systemd: Created slice user-0.slice.
    Jul 24 09:00:02 example.com systemd: Starting Session 151 of user root.
    Jul 24 09:00:02 example.com systemd: Started Session 151 of user root.
    
    

Resolution

  • These messages are normal and expected -- they will be seen any time a user logs in

  • To suppress these log entries in /var/log/messages, create a discard filter with rsyslog, e.g., run the following command:

    echo 'if $programname == "systemd" and ($msg contains "Starting Session" or $msg contains "Started Session" or $msg contains "Created slice" or $msg contains "Starting user-") then stop' >/etc/rsyslog.d/ignore-systemd-session-slice.conf
    
    

    Then restart the rsyslog service

    systemctl restart rsyslog
    

转载于:https://www.cnblogs.com/lixuebin/p/10814087.html

[root@VM-16-12-centos ~]# sudo systemctl status mysql # 或 service mysql status ● mysqld.service - LSB: start and stop MySQL Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled) Active: active (running) since Sat 2025-05-31 14:48:33 CST; 3min 39s ago Docs: man:systemd-sysv-generator(8) Process: 30799 ExecStop=/etc/rc.d/init.d/mysqld stop (code=exited, status=0/SUCCESS) Process: 30827 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS) CGroup: /system.slice/mysqld.service ├─30835 /bin/sh /www/server/mysql/bin/mysqld_safe --datadir=/www/server/data --pid-file=/www/server/data/V... └─31462 /www/server/mysql/bin/mysqld --basedir=/www/server/mysql --datadir=/www/server/data --plugin-dir=/... May 31 14:48:32 VM-16-12-centos systemd[1]: Stopped LSB: start and stop MySQL. May 31 14:48:32 VM-16-12-centos systemd[1]: Starting LSB: start and stop MySQL... May 31 14:48:33 VM-16-12-centos mysqld[30827]: Starting MySQL. SUCCESS! May 31 14:48:33 VM-16-12-centos systemd[1]: Started LSB: start and stop MySQL. [root@VM-16-12-centos ~]# cd /var/log/mysql/error.log -bash: cd: /var/log/mysql/error.log: No such file or directory [root@VM-16-12-centos ~]# cat /var/log/mysql/error.log cat: /var/log/mysql/error.log: No such file or directory [root@VM-16-12-centos ~]# cat /var/lo local/ lock/ log/ [root@VM-16-12-centos ~]# cat /var/lo local/ lock/ log/ [root@VM-16-12-centos ~]# cat /var/log/m maillog messages [root@VM-16-12-centos ~]# cd /var/log/ [root@VM-16-12-centos log]# ls audit btmp dmesg lastlog rhsm yum.log boot.log btmp-20250524 dmesg.old maillog secure yum.log-20250524 boot.log-20250524 chrony firewalld messages spooler boot.log-20250527 cloud-init.log grubby ntpstats tallylog boot.log-20250529 cloud-init-output.log grubby_prune_debug qcloud_action.log tuned boot.log-20250531 cron journal qemu-ga wtmp [root@VM-16-12-centos log]# sudo netstat -tuln | grep 3333 tcp 0 0 0.0.0.0:3333 0.0.0.0:* LISTEN [root@VM-16-12-centos log]# sudo lsof -i :3333 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mysqld 31462 mysql 15u IPv4 2630622 0t0 TCP *:dec-notes (LISTEN) [root@VM-16-12-centos log]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.44-log Source distribution Copyright (c) 2000, 2023, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> SELECT user, host FROM mysql.user; +---------------+--------------+ | user | host | +---------------+--------------+ | Majs | % | | root | % | | root | 111.229.56.9 | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +---------------+--------------+ 6 rows in set (0.00 sec) mysql> SHOW VARIABLES LIKE 'bind_address'; +---------------+---------+ | Variable_name | Value | +---------------+---------+ | bind_address | 0.0.0.0 | +---------------+---------+ 1 row in set (0.00 sec) mysql> SHOW VARIABLES LIKE 'port'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3333 | +---------------+-------+ 1 row in set (0.00 sec) mysql>
最新发布
06-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值