大网数据广告活动
服务器运维问答

How to run DNF without going OOM on GCP e2-micro

· 52CE 我爱测

I'm trying to run Fedora Cloud Base 36 on an e2-micro in the US central region of Google Cloud Platform (GCP). I haven't upgraded packages in a couple months so I tried to do that today. When I run: $ sudo dnf upgrade the OS runs…

问题原文

原帖链接 · jrefior · CC BY-SA 4.0

I'm trying to run Fedora Cloud Base 36 on an e2-micro in the US central region of Google Cloud Platform (GCP). I haven't upgraded packages in a couple months so I tried to do that today. When I run:

$ sudo dnf upgrade

the OS runs out of memory, kills my command, and terminates my SSH session. From journalctl logs:

sudo[917]:  jrefior : TTY=pts/0 ; PWD=/home/jrefior ; USER=root ; COMMAND=/usr/bin/dnf upgrade
sudo[917]: pam_unix(sudo:session): session opened for user root(uid=0) by jrefior(uid=1000)
systemd-oomd[613]: Killed /user.slice/user-1000.slice/session-3.scope due to memory used (955539456) / total (1007927296) and swap used (945311744) / total (1007>
systemd-oomd[613]: Killed /user.slice/user-1000.slice/session-3.scope due to memory used (956289024) / total (1007927296) and swap used (981708800) / total (1007>
systemd[1]: session-3.scope: systemd-oomd killed 6 process(es) in this unit.
systemd-logind[798]: Session 3 logged out. Waiting for processes to exit.
systemd[1]: session-3.scope: Deactivated successfully.
systemd[1]: session-3.scope: Consumed 10.737s CPU time.
systemd-logind[798]: Removed session 3.

An e2-micro has 1 GB memory, and the instance was created with 1 GB swap as well:

$ free -m
            total       used        free    shared  buff/cache   available
Mem:            961         146     558         0       256         680
Swap:           960         27      933

Can Fedora Cloud Base be managed on 2 GB of memory (including swap)? GCP e2-micro specs are here. Is there a way to upgrade kernel and packages without using so much memory?

Would I run into a problem upgrading Fedora Cloud Base as well when the time comes?

已采纳解答

原帖链接 · John Mahowald · CC BY-SA 4.0

No, 1 GB of RAM is not enough for package management of a Fedora based system. Which in my opinion includes RHEL and rebuilds, but the extent of the problem on the size of the repos involved. Yes, a distro major version upgrade transaction is among the biggest, and could be problematic as well.

Paging out during a package transaction is a miserable experience. Slow. And even with the swap possibly oom killed in a dangerous place. I am being unfair to swap space by only calling this 1 GB, but the memory system behaves differently than if you had 2 GB of DRAM.

For recent reports of this happening, see mailing list thread dnf makecache memory usage increase, and Bugzilla "dnf update" runs out of memory on swapless machines with 1G or less of RAM. Note that the entire dnf metadata is being converted into some libsolv database in memory, on top of what it does to parse those dependencies.


If you moved your instances to image based updates, that could be done once on a bigger box. Upgrade a primary copy, make a disk image out of that, and boot new instances from the updated one. Likely a significant change of how you do updates. See also: rpm-ostree.

Commenters on the bug have noted file lists blowing up the size of metadata. Especially with the number of packages in Fedora, how often they update, and how many have still have legacy file dependencies. Consider maintaining your own custom repos of just a subset of the packages you use.

microdnf is the package manger without Python. While there might be some memory savings to switching, its authors have not laid out in detail its limitations. Possibly wait on this one, Fedora is inevitably going to change the package manager again anyway.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-01-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。