在Google容器优化操作系统中添加systemd-journal-upload
Great question! Your initial hunch is on the right track, but there are a few extra steps to make sure this works properly with the Container-Optimized OS build system. Let's walk through it:
Core Step: Enable Remote Support in the systemd Ebuild
Yes, adding the --enable-remote flag to the configure arguments in overlay-lakitu/sys-apps/systemd/systemd-232.ebuild is the key change here. This compile-time flag enables all remote journaling components, including systemd-journal-upload.
Look for the src_configure() function in the ebuild—you'll want to append the flag to the existing set of configure options, like this:
src_configure() { econf \ --enable-remote \ # Keep all existing configure flags here --enable-some-other-feature \ ... }
Additional Steps to Ensure Success
- Verify Dependencies: Double-check that the ebuild's
DEPENDandRDEPENDsections include any libraries required for remote journaling (luckily, most are bundled with systemd 232, but it's worth confirming to avoid build errors). - Rebuild the systemd Package: Use the Portage tools included in the Container-Optimized OS build environment to rebuild systemd:
Make sure your custom overlay is properly registered so Portage picks up your modified ebuild instead of the upstream version.emerge -av sys-apps/systemd - Validate the Built Components: After building, check that the necessary files exist in your image:
- Binary:
/usr/lib/systemd/systemd-journal-upload - Service file:
/usr/lib/systemd/systemd/systemd-journal-upload.service
- Binary:
- Configure Journal Upload: Once your image is running, you'll need to set up the target server in
/etc/systemd/journal-upload.conf(uncomment and set theURLdirective to your journal receiver endpoint). You may also need to configure TLS certificates if your receiver uses HTTPS. - Test the Service: Start the service and verify it's running without errors:
systemctl start systemd-journal-upload systemctl status systemd-journal-upload journalctl -u systemd-journal-upload
Note on Container-Optimized OS Specifics
Keep in mind that Container-Optimized OS is based on the Chromium OS Portage tree, so make sure your custom overlay follows the same conventions as the base system. Also, ensure that your modified systemd package doesn't conflict with any other OS components that rely on the default systemd build.
内容的提问来源于stack exchange,提问作者mattes

