Ubuntu 16.04环境下如何配置ZFS ZED使用容器内Postfix邮件服务器
Got it, let's walk through getting ZFS ZED (ZFS Event Daemon) to send disk failure alerts via your Postfix server running in an LXD container. Here's a step-by-step guide tailored to your setup:
1. Ensure ZFS ZED is Installed
First, confirm the ZED package is installed on your Ubuntu 16.04 host. If not, install it with:
sudo apt update && sudo apt install zfs-zed
2. Get Your Postfix Container's IP Address
You'll need the internal IP of your LXD container to point ZED to it. Run this command to list your containers and their IPs:
lxc list
Note down the IP (e.g., 10.0.3.10) for your Postfix container.
3. Edit the ZED Configuration File
ZED's main config is located at /etc/zfs/zed.d/zed.rc. Open it in your favorite editor:
sudo nano /etc/zfs/zed.d/zed.rc
Update these key variables to match your setup:
- Set alert recipients: Replace with the email address where you want to receive ZFS alerts:
ZED_EMAIL_ADDR="your-alert-recipient@example.com" - Set the sender address: This will be the "from" address on alert emails:
ZED_EMAIL_FROM="zfs-alerts@your-domain.com" - Point to your Postfix container: Override the default email program to send directly to your container's port 1478. Use either of these options:
Option 1: Usesendmailwith a custom server/port (simple, no extra packages):
Option 2: UseZED_EMAIL_PROG="sendmail -S [YOUR_CONTAINER_IP]:1478"ssmtp(more configurable, requires installing the package first):- Install
ssmtp:sudo apt install ssmtp - Edit
/etc/ssmtp/ssmtp.confto point to your container:root=zfs-alerts@your-domain.com mailhub=[YOUR_CONTAINER_IP]:1478 FromLineOverride=YES - Update ZED's email program to use
ssmtp:ZED_EMAIL_PROG="ssmtp"
- Install
- Enable verbose alerts (optional but recommended for disk failure notifications):
ZED_NOTIFY_VERBOSE=1
Save and close the file when you're done.
4. Start and Enable the ZED Service
Make sure ZED runs on boot and starts immediately:
sudo systemctl enable zed sudo systemctl start zed
5. Test the Setup
To verify everything works, trigger a ZFS event (like starting a scrub on a pool) and check if you receive an alert email:
zpool scrub [YOUR_ZFS_POOL_NAME]
You can also check ZED's logs for any errors:
tail -f /var/log/zfs/zed.log
Important Notes
- Network Access: Ensure your Ubuntu host can reach the Postfix container's 1478 port. Check LXD's network settings (e.g., container profile firewall rules) if you run into connectivity issues.
- Postfix Configuration: Double-check your container's Postfix setup allows incoming mail from the host IP, and that it's configured to relay emails to your external recipient if needed.
内容的提问来源于stack exchange,提问作者OmerSakar

