Ubuntu安装Ambari 2.4时PostgreSQL相关问题求助
Hey there! I’ve helped folks work through this exact issue before—since you’ve already got PostgreSQL up and running on your Ubuntu system, we just need to get Ambari configured to use it instead of relying on its default database setup. Here’s how to do it step by step:
Step 1: Create a Dedicated Database & User for Ambari
First, we need to set up a PostgreSQL database and user that Ambari can use exclusively. Run these commands:
- Access the PostgreSQL shell:
sudo -u postgres psql - Inside the shell, create the database, user, and grant full permissions:
CREATE DATABASE ambari; CREATE USER ambari WITH PASSWORD 'your_secure_password_here'; GRANT ALL PRIVILEGES ON DATABASE ambari TO ambari; - Exit the shell with:
\q
Step 2: Install & Configure PostgreSQL JDBC Driver for Ambari
Ambari needs the JDBC driver to connect to your PostgreSQL instance. Install it via apt and copy it to Ambari’s resource directory:
sudo apt-get update && sudo apt-get install -y libpq-java sudo cp /usr/share/java/postgresql.jar /var/lib/ambari-server/resources/
Step 3: Configure Ambari Server to Use External PostgreSQL
Now tell Ambari to use your PostgreSQL database instead of its default setup:
- First, link the JDBC driver to Ambari:
sudo ambari-server setup --jdbc-db=postgres --jdbc-driver=/var/lib/ambari-server/resources/postgresql.jar - Run the main Ambari setup command:
When prompted, select Advanced Database Configuration, then fill in these details:sudo ambari-server setup- Database Type:
PostgreSQL - Database Host:
localhost(use your remote server IP if PostgreSQL is on another machine) - Database Name:
ambari - Database User:
ambari - Database Password: The secure password you set in Step 1
- Database Type:
Step 4: Initialize Ambari’s Database Schema
We need to populate the ambari database with all the tables and data Ambari requires:
- Reset Ambari’s database configuration:
sudo ambari-server reset --database - Import Ambari’s PostgreSQL schema into your database:
sudo -u postgres psql -d ambari -f /var/lib/ambari-server/resources/Ambari-DDL-Postgres-CREATE.sql
Step 5: Start Ambari Server & Verify
Finally, start the Ambari server and check if it loads correctly:
sudo ambari-server start
Head over to http://your-server-ip:8080 in your browser—you should see the Ambari setup wizard load without any database-related errors.
Quick Troubleshooting Tips
- Make sure PostgreSQL is running:
sudo systemctl status postgresql(start it withsudo systemctl start postgresqlif it’s stopped) - Double-check that the
ambariuser has full permissions on theambaridatabase - Ensure the default PostgreSQL port (5432) is open locally if you’re using localhost
内容的提问来源于stack exchange,提问作者Ishan Kumar

