升級包導致資料庫崩潰

升級包導致資料庫崩潰

一種非常奇怪的依賴關係融合導致了奇怪的資料庫崩潰。情境:

  • CentOS 7.9
  • LVM2-2.02
  • Postgresql 12,資料磁碟區位於 LVM 磁碟區上,XFS 格式
  • 系統
  • 總線

當系統啟動並穩定且資料庫正常運作時,我執行了yum update.在更新過程中,卸載了多個卷,包括裝載資料庫的捲。這導致了恐慌消息:

2021-08-12 21:12:35.418 CEST  PANIC: could not open file ""/var/lib/pgsql/current/data/global/pg_control"": No such file or directory

日誌日誌顯示在這次崩潰之前的幾分鐘內已經更新了相當多的軟體包。沒有來自 postgresql 的中間日誌訊息,這可能會縮小範圍。

顯然有些東西/etc/fstab配置不正確,但在 yum 更新之前很久就可以看到以下訊息:

Aug 12 18:27:32 git.uibk.ac.at systemd-fstab-generator[19273]: Checking was requested for "none", but it is not a device.

並且在更新期間經常出現。所以我認為這是一個轉移注意力的事情。

Systemd 已更新並重新啟動:

Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Reexecuting.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: systemd 219 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN)

那是事故發生前 45 秒。緊接著,我們看到:

Aug 12 21:11:46 git.uibk.ac.at systemd[1]: [/etc/systemd/system/rsyslog.service.d/partof-journald.conf:2] Assignment outside of section. Ignoring.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Stopped target Remote File Systems.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Stopping Remote File Systems.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Unset automount mnt-git\x2drepodata.automount.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Stopping mnt-git\x2drepodata.automount.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Set up automount mnt-git\x2drepodata.automount.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Reached target Remote File Systems.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Unset automount Arbitrary Executable File Formats File System Automount Point.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Stopping Arbitrary Executable File Formats File System Automount Point.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Set up automount Arbitrary Executable File Formats File System Automount Point.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Stopped target Local File Systems.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Stopping Local File Systems.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Unset automount var-lib-pgsql.automount.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Stopping var-lib-pgsql.automount.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: var-lib-pgsql.automount: Directory /var/lib/pgsql to mount over is not empty, mounting anyway.

為什麼為什麼? ....為什麼YYYYYYYYY! !無論如何,它似乎沒有正常工作。

Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Set up automount var-lib-pgsql.automount.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Mounting /var/lib/pgsql/current/pg_stat_tmp...
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Mounted /var/lib/pgsql/current/pg_stat_tmp.
Aug 12 21:11:46 git.uibk.ac.at systemd[1]: Reached target Local File Systems.

該卷也沒有很快安裝,並且必須在恢復過程中手動重新安裝。

在出現 PANIC 之前還會出現一些其他訊息:

Aug 12 21:12:32 git.uibk.ac.at yum[12642]: Installed: kernel-3.10.0-1160.36.2.el7.x86_64
Aug 12 21:12:33 git.uibk.ac.at yum[12642]: Updated: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
Aug 12 21:12:33 git.uibk.ac.at systemd[1]: Reloading.
Aug 12 21:12:34 git.uibk.ac.at yum[12642]: Updated: 7:lvm2-2.02.187-6.el7_9.5.x86_64
Aug 12 21:12:34 git.uibk.ac.at yum[12642]: Updated: 1:nfs-utils-1.3.0-0.68.el7.1.x86_64

然後這兩個,奇怪的是,順序不正確:

Aug 12 21:12:35 git.uibk.ac.at systemd[1]: postgresql-12.service: main process exited, code=exited, status=1/FAILURE
Aug 12 21:12:35 git.uibk.ac.at kernel: XFS (dm-6): Unmounting Filesystem

dm-6 是現在(重新啟動後)交換卷,所以......?

以下是卷的列表,不包括常見的嫌疑犯:

/dev/mapper/vgdata-git--db on /var/lib/pgsql type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/mapper/vgroot-lvroot on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/mapper/vgroot-lvtmp on /tmp type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/mapper/vgroot-lvvar on /var type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/vda1 on /boot type ext4 (rw,relatime,seclabel,data=ordered)
nfsshare:/git/qt-gitlab on /mnt/git-repodata type nfs (rw,relatime,rsize=65536,wsize=65536,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountport=635,mountproto=udp,local_lock=none)
none on /var/lib/pgsql/12/pg_stat_tmp type tmpfs (rw,relatime,seclabel,size=16384k,mode=770,uid=102,gid=26)
systemd-1 on /mnt/git-repodata type autofs (rw,relatime,fd=37,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13188)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=31,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13146)
systemd-1 on /var/lib/pgsql type autofs (rw,relatime,fd=41,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13753)

我以前從未在任何現代 Linux 系統上見過這種情況發生。這是 systemd 更新或重新執行時的「預期行為」嗎?

相關內容