Ubuntu 16.04升级后Bacula-dir无法启动求助
Hey Aron, let's dig into this Bacula issue you're facing after upgrading to Ubuntu 16.04. I've gone through your details and here's what I think might be going on, plus actionable steps to fix it:
Key Context to Highlight
Your switch from MySQL to PostgreSQL during the upgrade is a critical detail—this transition often leaves subtle configuration or schema gaps that cause hangs like you're seeing. Also, the truncated debug log cutting off at postgresql.c:1117-0 db_init_database first time tells us the director is getting stuck initializing the PostgreSQL connection, not just failing auth.
Likely Root Causes & Fixes
1. Incomplete PostgreSQL Schema Setup
Even though you can connect via psql, Bacula might be missing required database permissions or schema objects. Let's re-run the official packaged scripts (avoid source scripts unless you compiled Bacula yourself):
# Drop and recreate the Bacula DB from scratch sudo -u postgres dropdb bacula sudo -u postgres createdb -O bacula bacula # Apply Ubuntu's packaged Bacula PostgreSQL schema sudo -u postgres psql -d bacula -f /usr/share/bacula-director-pgsql/create_postgresql_tables.sql sudo -u postgres psql -d bacula -f /usr/share/bacula-director-pgsql/grant_postgresql_privileges.sql
2. PostgreSQL Socket Permissions
Bacula might be having trouble accessing the PostgreSQL local socket. Verify the bacula user has access:
# Check socket directory permissions ls -ld /var/run/postgresql/ # Add bacula user to postgres group for socket access sudo usermod -aG postgres bacula
3. Subtle Configuration Mismatches
Ubuntu's default configs can have tiny differences between test and production machines. Double-check these:
bacula-dir.confCatalog settings: Ensure the DB credentials match exactly what works inpsql, and confirm the connection method (local socket vs TCP):Catalog { Name = MyCatalog dbname = "bacula" dbuser = "bacula" dbpassword = "your-db-password" # Match what you used in psql dbaddress = "" # Leave empty for local socket; use "localhost" for TCP }bconsole.confvsbacula-dir.conf: TheDirectorblock inbconsole.confmust use the exact sameNameandPasswordas theDirectorsection inbacula-dir.conf—even a single typo triggers the auth error.
4. Capture Full Debug Logs
The truncated log you shared cuts off right when the DB init starts. Get a complete debug trace:
sudo systemctl stop bacula-director sudo bacula-dir -c /etc/bacula/bacula-dir.conf -d 400 > /tmp/bacula-full-debug.log 2>&1
Look for lines after db_init_database—it will likely show a specific error like missing extensions, permission denied, or socket connection failures.
5. Fix Permissions for Critical Bacula Paths
Even if you checked permissions, ensure all core directories are owned by the bacula user:
sudo chown -R bacula:bacula /var/lib/bacula /var/log/bacula /var/run/bacula sudo chmod 750 /var/lib/bacula /var/log/bacula /var/run/bacula
6. Rule Out TLS Conflicts
The auth error mentions TLS—Ubuntu's default config might have TLS enabled accidentally. Check:
- In
bacula-dir.conf, look forTLS Enable = yesin theDirectororCatalogsections. If you don't use TLS, set it tono. - Match TLS settings in
bconsole.confto the director's config.
How to Narrow Down the Issue Further
- Test DB connection as the bacula user: Run
sudo -u bacula psql -d bacula -U bacula—if this works, the problem isn't the password itself, but how Bacula is handling the connection. - Compare test vs production configs: Use
diffto spot differences between your working test machine and the problematic server:# Copy test configs to your server first scp user@test-server:/etc/bacula/* /tmp/test-bacula-configs/ diff -r /etc/bacula/ /tmp/test-bacula-configs/ - Check systemd logs: Use
journalctl -u bacula-director.service -fto see real-time logs when starting the service—this often reveals errors missing in truncated debug output.
Final Notes on MySQL → PostgreSQL Switch
Ensure no residual MySQL configs or packages are left:
# Check for leftover MySQL Bacula packages dpkg -l | grep bacula | grep mysql # Purge them if present sudo apt purge bacula-common-mysql bacula-director-mysql
内容的提问来源于stack exchange,提问作者Aron

