Manjaro开机报错failed to start rotate log files

问题背景

系统启动时经常会报一个错“failed to start rotate log files ”,然后可能会卡死,卡死后需要强制重启,重启后又正常进入系统。
此问题的解决思路和另一个问题一模一样。

分析问题
  1. logrotate是什么
    按照老套路分析,先百度了一下logrotate是什么,参考,说白了就是个日志切割,和java里面的差不多。就是防止单文件日志过大,按照一定的规则切割成多个日志,或者删除,比如设置超过一个月直接删除,或者超过10M直接删除等等。
  2. 查看logrotate是什么时候启动,以及启动后的状态。首先我们知道它是一个systemctl启动的service服务。那就到/lib/systemd/system下看一下ll |grep rotate
$ ll|grep rota
-rw-r--r-- 1 root root  870  1月  8  2021 logrotate.service
-rw-r--r-- 1 root root  191  1月  8  2021 logrotate.timer

可以看到和这个问题一模一样的套路。
3. 到 logrotate.service查看它实际上执行的是什么命令

$ cat logrotate.service     
[Unit]
Description=Rotate log files
Documentation=man:logrotate(8) man:logrotate.conf(5)
RequiresMountsFor=/var/log
ConditionACPower=true

[Service]
Type=oneshot
ExecStart=/usr/sbin/logrotate /etc/logrotate.conf

# performance options
Nice=19
IOSchedulingClass=best-effort
IOSchedulingPriority=7

# hardening options
#  details: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
#  no ProtectHome for userdir logs
#  no PrivateNetwork for mail deliviery
#  no NoNewPrivileges for third party rotate scripts
#  no RestrictSUIDSGID for creating setgid directories
LockPersonality=true
MemoryDenyWriteExecute=true
PrivateDevices=true
PrivateTmp=true
ProtectClock=true
ProtectControlGroups=true
ProtectHostname=true
ProtectKernelLogs=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectSystem=full
RestrictNamespaces=true
RestrictRealtime=true

可以看到ExecStart=/usr/sbin/logrotate /etc/logrotate.conf
执行的是这个命令,那就好办了,手动以debug模式执行一下此命令
4. 查看执行结果

$ sudo logrotate --debug /etc/logrotate.conf                              
[sudo] chenkun 的密码:
WARNING: logrotate in debug mode does nothing except printing debug messages!  Consider using verbose mode (-v) instead if this is not what you want.

reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file cups
reading config file lirc
reading config file mysqlrouter
error: mysqlrouter:31 unknown option 'var' -- ignoring line
error: mysqlrouter:45 unexpected }
error: found error in file mysqlrouter, skipping
reading config file nginx
reading config file samba
warning: 'monthly' overrides previously specified 'weekly'
Reading state from file: /var/lib/logrotate.status
Allocating hash table for state file, size 64 entries
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state

Handling 6 logs

rotating pattern: /var/log/cups/*_log  weekly (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/cups/access_log
  Now: 2021-07-15 09:24
  Last rotated at 2021-07-11 16:22
  log does not need rotating (log has been rotated at 2021-07-11 16:22, which is less than a week ago)
considering log /var/log/cups/error_log
  Now: 2021-07-15 09:24
  Last rotated at 2021-07-11 16:22
  log does not need rotating (log has been rotated at 2021-07-11 16:22, which is less than a week ago)

rotating pattern: /var/log/lircd  weekly (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/lircd
  log /var/log/lircd does not exist -- skipping

rotating pattern: /var/log/nginx/*log  weekly (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/nginx/access.log
  Now: 2021-07-15 09:24
  Last rotated at 2021-06-02 08:34
  log does not need rotating (log is empty)
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/samba/log.smbd /var/log/samba/log.nmbd /var/log/samba/*.log  weekly (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/samba/log.smbd
  log /var/log/samba/log.smbd does not exist -- skipping
considering log /var/log/samba/log.nmbd
  log /var/log/samba/log.nmbd does not exist -- skipping
considering log /var/log/samba/*.log
  log /var/log/samba/*.log does not exist -- skipping

rotating pattern: /var/log/wtmp  monthly (1 rotations)
empty log files are rotated, only log files >= 1048576 bytes are rotated, old logs are removed
considering log /var/log/wtmp
  Now: 2021-07-15 09:24
  Last rotated at 2021-03-20 18:00
  log does not need rotating ('minsize' directive is used and the log size is smaller than the minsize value)

rotating pattern: /var/log/btmp  monthly (1 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/btmp
  Now: 2021-07-15 09:24
  Last rotated at 2021-07-01 19:33
  log does not need rotating (log has been rotated at 2021-07-01 19:33, which is less than a month ago)

  1. 在日志中找error
    在这里插入图片描述

  2. 报错很明显了是mysqlroute的日志切割失败了。

  3. logrotate其实是被很多程序都使用了,其配置文件在/etc/logrotate.d下。
    在这里插入图片描述
    可以看到nginx ,mysqlrouter,Samba等都用了logrotate,并且他们都有自己的配置,根据上面我们已经知道了是mysqlrouter配置有问题,我们只需要打开nginx的配置和mysqlrouter对比就知道了。经过比我我的mysqlrouter的配置文件在var前面少了一个/ 加上就好了
    在这里插入图片描述

"failed to mount /boot/efi"错误通常是由于未正确挂载EFI分区引起的。解决此问题的步骤如下: 1. 首先,使用命令`lsblk`查看可用的挂载位置。确保EFI分区已经存在并正确识别。 2. 使用以下命令挂载EFI分区:`sudo mount /dev/sda1 /boot/efi`。请注意,这里的`/dev/sda1`是你用来挂载EFI分区的实际设备和分区号,可能会因系统而异。 3. 为了在启动时自动挂载EFI分区,需要编辑`/etc/fstab`文件。使用文本编辑器打开该文件,并将其中的内容修改为与上述挂载命令中的设备和分区号一致。保存并退出文件。 4. 最后,使用命令`systemctl reboot`重启系统,使更改生效。 引用\[1\]提供了解决未挂载EFI分区的问题的步骤。引用\[2\]提供了解决"ntfsfix: command not found"错误的方法,即安装ntfsprogs工具。引用\[3\]提供了可能导致磁盘挂载错误的原因,以及在Linux下使用ntfsfix修复和在Windows下使用chkdsk修复的方法。 #### 引用[.reference_title] - *1* [记一次manjaro linux failed to mount /boot/efi解决过程](https://blog.csdn.net/qq_39053085/article/details/113372664)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [硬盘挂载报错 $MFTMirr does not match $MFT (record 0).Failed to mount](https://blog.csdn.net/ayychiguoguo/article/details/125967874)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值