# Prepare Environment

{% hint style="info" %}

#### Prepare Environment

You will need perform the following steps to prepare your Linux environment for an Archive installation of the Pentaho Server.&#x20;

This process includes:

* create a 'Pentaho installation user' with sudo privileges.
* install supported version of OpenJDK 11
* set PENTAHO\_JAVA\_HOME
* install certified version of Postgres 15
* create 'superadmin' user
* install pgAdmin4
  {% endhint %}

{% hint style="warning" %}
The supported Linux environment for Pentaho version 10.2.x: Ubuntu 22.04&#x20;

Check [Components Reference](https://docs.pentaho.com/pdia-10.2-install/components-reference)
{% endhint %}

{% tabs %}
{% tab title="1. Creating a Pentaho User" %}
{% hint style="info" %}

#### Pentaho Installation Account

Add an account that is assigned administrative privileges by performing the following steps. We'll be using this account to complete the deployment.
{% endhint %}

{% hint style="danger" %}
For production environments its best practice to create a specific 'installation user' account with the required role / permissions / privileges.
{% endhint %}

1. Run update & upgrade (optional).

```bash
sudo apt update -y && sudo apt upgrade -y
```

2. Add new user to system.

```bash
sudo adduser pentaho
```

3. Set password.

```
New password: password
Retype new password: password
passwd: password updated successfully
```

```
Follow the prompts to set the new user’s information. It is fine to accept the defaults to leave 
all this information blank:
```

4. Add new user to sudo group.

```bash
 sudo usermod -aG sudo pentaho
```

5. Test access.

```bash
su - pentaho
```

```bash
sudo ls -la /root
```

{% endtab %}

{% tab title="2. Open JDK & JRE 17" %}
{% hint style="info" %}

#### Java&#x20;

Check the components reference ..!!

Pentaho 10.2 is certified on: Oracle OpenJDK  & JRE 11 & 17
{% endhint %}

{% embed url="<https://docs.pentaho.com/pdia-10.2-install/components-reference>" %}

1. Run update & upgrade.

```bash
sudo apt update -y && sudo apt upgrade -y
```

2. Check whether Java is already installed in our system.

```bash
java -version
```

<figure><img src="/files/l1Rz6L1D16wPZ5DLhxB6" alt=""><figcaption><p>Java versions</p></figcaption></figure>

3. Install openjdk 11.

```bash
sudo apt install openjdk-17-jdk && sudo apt install openjdk-17-jre-headless
```

4. Check Java version.

```bash
java -version
```

```
openjdk 17.0.12 2024-07-16
OpenJDK Runtime Environment (build 17.0.12+7-Ubuntu-1ubuntu222.04)
OpenJDK 64-Bit Server VM (build 17.0.12+7-Ubuntu-1ubuntu222.04, mixed mode, sharing)
```

4. Tidy up.

```bash
sudo apt autoremove
```

***

{% hint style="info" %}

#### Set Java Version

You can have multiple Java installations on one server. You can configure which version is the default for use on the command line by using the update-alternatives command.
{% endhint %}

1. Run the following command to set the preferred Java version.

```bash
sudo update-alternatives --config java
```

```
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-17-openjdk-amd64/bin/java
Nothing to configure.
```

{% endtab %}

{% tab title="3. PENTAHO\_JAVA\_HOME" %}
{% hint style="info" %}

#### Set PENTAHO\_JAVA\_HOME

Perform the following steps to set the PENTAHO\_JAVA\_HOME environment variable. This will ensure that if there are multiple versions of Java the correct version is associated with PENTAHO\_JAVA\_HOME.
{% endhint %}

1. Run update & upgrade.

```bash
sudo apt update -y && sudo apt upgrade -y
```

2. Verify java version.

```bash
java -version
```

3. Determine path to OpenJDK.

```bash
update-alternatives --list java
```

***

{% hint style="info" %}

#### Set PENTAHO\_JAVA\_HOME - Global

As Pentaho is being installed under root to /opt/ then set PENTAHO\_JAVA\_HOME for all users.
{% endhint %}

1. Edit /etc/environment.

```bash
sudo nano /etc/environment
```

2. Add the following.

```bash
# set PENTAHO_JAVA_HOME
PENTAHO_JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
```

3. Save.

```bash
CTRL + o
Enter
CTRL + x
```

4. Check path.

```bash
echo $PENTAHO_JAVA_HOME
```

5. Restart the server.

```
reboot
```

***

{% hint style="info" %}

#### Set PENTAHO\_JAVA\_HOME - Local

For just the specific user.
{% endhint %}

1. Set the path to OpenJDK.

```bash
sudo nano .bashrc
```

2. Add the following to the bottom.

```
# set PENTAHO_JAVA_HOME
export PENTAHO_JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
```

3. Save.

```bash
CTRL + o
Enter
CTRL + x
```

4. Reload .bashrc.

```bash
. ~/.bashrc
```

5. Check path.

```bash
echo $PENTAHO_JAVA_HOME
```

6. Restart the server.

```
reboot
```

{% endtab %}

{% tab title="4. PostgreSQL 14 & 15" %}
{% hint style="info" %}

#### Pentaho Repository

The following databases are supported types as your Pentaho Repository 10.2.
{% endhint %}

<table><thead><tr><th width="261">Certified</th><th>Supported</th></tr></thead><tbody><tr><td>PostgreSQL 15</td><td>PostgreSQL 14 &#x26; 15</td></tr><tr><td>MySQL 8.026</td><td>MySQL 8.026</td></tr><tr><td>Oracle 23c</td><td>Oracle 19c &#x26; 23c (including patched versions)</td></tr><tr><td>MS SQL Server 2019</td><td>Microsoft SQL Server 2017 &#x26; 2019 (including patched versions)</td></tr><tr><td>Maria DB 11.1.2</td><td>Maria DB 11.1.2</td></tr></tbody></table>

{% tabs %}
{% tab title="4.1 Supported  Version" %}
{% hint style="info" %}

#### Supported Pentaho Database - PostgreSQL

Ensure you have a 'clean' PostgeSQL environment to avoid any potential conflicts - usually port.
{% endhint %}

1. Run update & upgrade.

```bash
sudo apt update -y && sudo apt upgrade -y
```

2. Check Postgresql version.

```bash
apt show postgresql -a
```

```
Package: postgresql
Version: 14+238
Priority: optional
Section: database
Source: postgresql-common (238)
Origin: Ubuntu
```

***

{% hint style="warning" %}
If PostgreSQL is installed, check its a supported version:&#x20;

PDI v10.2 == Postgres 14 & 15&#x20;
{% endhint %}

1. If not purge current Postgresql instance.

{% hint style="warning" %}
Execute each command separately ..

sudo apt autoremove to tidy up ..
{% endhint %}

```bash
sudo apt-get --purge remove postgresql
sudo apt-get purge postgresql*
sudo apt-get --purge remove postgresql postgresql-doc postgresql-common
```

2. Check for packages.

```bash
dpkg -l |grep postgres;PostgreSQL
```

{% endtab %}

{% tab title="4.2 Install PostgreSQL 14 & 15" %}
{% hint style="info" %}

#### Install PostgreSQL 14

PostgreSQL 14 is a default in the Unbuntu 22.04 apt repository.
{% endhint %}

1. Update Repository list.

```bash
sudo apt update -y && sudo apt upgrade -y
```

2. Install PostgreSQL 14.

```bash
sudo apt-get -y install postgresql-14 
```

```
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libcommon-sense-perl libjson-perl libjson-xs-perl libllvm14 libpq5
  libtypes-serialiser-perl postgresql-client-14 postgresql-client-common
  postgresql-common sysstat
Suggested packages:
  postgresql-doc-14 isag
The following NEW packages will be installed
  libcommon-sense-perl libjson-perl libjson-xs-perl libllvm14 libpq5
  libtypes-serialiser-perl postgresql-14 postgresql-client-14
  postgresql-client-common postgresql-common sysstat
0 to upgrade, 11 to newly install, 0 to remove and 0 not to upgrade.
Need to get 42.4 MB of archives.
...
```

3. Check the PostgreSQL version.

```bash
psql --version
```

```
psql (PostgreSQL) 14.12 (Ubuntu 14.12-0ubuntu0.22.04.1)
```

***

{% hint style="info" %}

#### PostgreSQL 15 - Add APT Repository

If you decide to go the PostgreSQL 15, the package is not available in the default package repository, so needs to be added to the official package repository using following commands.
{% endhint %}

1. Add APT Repository.

```bash
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
```

2. Import GPG key.

```bash
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
```

3. Update Repository list.

```bash
sudo apt update -y && sudo apt upgrade -y
```

4. Reboot server.

```bash
reboot
```

***

{% hint style="info" %}

#### Install PostgreSQL 15

Once package repository is updated, then ..
{% endhint %}

1. Install postgresql 15.

```bash
sudo apt install postgresql-client-15 postgresql-15
```

```
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libcommon-sense-perl libjson-perl libjson-xs-perl libpq5
  libtypes-serialiser-perl postgresql-client-common postgresql-common sysstat
Suggested packages:
  postgresql-doc-15 isag
The following NEW packages will be installed
  libcommon-sense-perl libjson-perl libjson-xs-perl libpq5
  libtypes-serialiser-perl postgresql-15 postgresql-client-15
  postgresql-client-common postgresql-common sysstat
0 to upgrade, 10 to newly install, 0 to remove and 0 not to upgrade.
Need to get 20.0 MB of archives.
After this operation, 66.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
...
```

2. Check postgresql 15 status.

```bash
sudo systemctl status postgresql
```

```
pentaho@pentaho:~$ sudo systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor pr>
     Active: active (exited) since Fri 2024-08-16 00:38:15 BST; 2min 27s ago
   Main PID: 5687 (code=exited, status=0/SUCCESS)
        CPU: 1ms

Aug 16 00:38:15 pentaho systemd[1]: Starting PostgreSQL RDBMS...
Aug 16 00:38:15 pentaho systemd[1]: Finished PostgreSQL RDBMS.
```

```
sudo service postgresql stop // Stop the service
sudo service postgresql start // Start the service
sudo service postgresql restart // Stop and restart the service
sudo service postgresql reload // Reload the configuration without 
stopping the service
```

3. Check the PostgreSQL version.

```bash
psql --version
```

4. Tidy up installation.

```bash
sudo apt autoremove
```

{% endtab %}

{% tab title="4.3 Superuser" %}
{% hint style="info" %}

#### Grant privileges to a SuperUser

During installation, a 'postgres' user is created automatically. This user has full **superadmin** access to your entire PostgreSQL instance. Before you switch to this account, your logged in system user should have sudo privileges.
{% endhint %}

1. Log in as 'postgres' user.

```bash
sudo su -l postgres
```

2. Change password.

```plsql
psql -c "ALTER USER postgres WITH PASSWORD 'Welcome123'";
```

3. Exit

```
CTRL + d
```

***

{% hint style="info" %}

#### Pentaho Superuser

Grant access & privileges to Pentaho superuser.
{% endhint %}

1. Switch to 'postgres' user.

```bash
sudo -u postgres psql
```

2. Create 'pentaho' user.

```bash
CREATE USER pentaho WITH PASSWORD 'Welcome123';
```

3. Upgrade 'pentaho' to superuser.

```bash
ALTER USER pentaho WITH SUPERUSER;
```

4. Exit.

```
CTRL + d
```

5. Switch to 'pentaho' user:

```bash
 sudo -u pentaho psql postgres
```

6. Check connection details.

```bash
\conninfo
```

```
postgres=# \conninfo
You are connected to database "postgres" as user "pentaho" via socket in "/var/run/postgresql" at port "5432".
```

7. Exit.

```bash
CTRL + d
```

***

{% hint style="info" %}

#### Allow Remote Connections

<mark style="color:green;">For reference only as connecting to Postgresql via localhost</mark>

By default, PostgreSQL accepts connections from the localhost only. However, we can easily modify the configuration to allow connection from remote clients.

PostgreSQL reads its configuration from the postgresql.conf file which is located: /etc/postgresql/\<version>/main/ directory
{% endhint %}

1. Edit the postgresql.conf file.

```bash
cd
cd /etc/postgresql/15/main/
sudo nano postgresql.conf
```

2. Uncomment the line that starts with the listen\_addresses, and replace ‘localhost’ with ‘\*’.

{% hint style="info" %}
Alternatively, you can specify a specific IP address or a range of IP addresses that are allowed to connect to the server.
{% endhint %}

3. Modify the pg\_hba.conf file.

```bash
sudo nano /etc/postgresql/15/main/pg_hba.conf
```

4. Locate the following section and modify

```
# IPv4 local connections: 
host    all             all             127.0.0.1/32         md5 
```

```
# IPv4 local connections:
host    all             all             0.0.0.0/0            md5 
```

5. Allow port 5432 through the firewall.

```bash
sudo ufw allow 5432/tcp
```

6. Restart Postgres.

```bash
sudo service postgresql restart
```

{% endtab %}

{% tab title="4.4 pgAdmin" %}
{% hint style="info" %}

#### pgAdmin4 Desktop

The **pgadmin4** package contains both:

• **pgadmin4-desktop** – Provides desktop application for Ubuntu system.

• **pgadmin4-web** – Provides the web interface accessible in a web browser
{% endhint %}

1. Update Repository list.

```bash
sudo apt update -y && sudo apt upgrade -y
```

2. Install Public Key.

```bash
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg
```

3. Create Repository config file.

```bash
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
```

4. Install pgAdmin4 for both desktop - see below for Web version.

```bash
sudo apt install pgadmin4-desktop
```

5. Check contents APT Repository.

```bash
cat /etc/apt/sources.list.d/pgadmin4.list
```

***

{% hint style="info" %}

#### Pentaho Server Group

In pgAdmin, a server group is a way to organize and categorize your PostgreSQL server connections. It's essentially a logical grouping mechanism that helps you manage multiple database server connections more efficiently.
{% endhint %}

1. Click on: 'Add New Server'.

<figure><img src="/files/vKPwcEgMN4uVDjPsdBvP" alt=""><figcaption><p>create server group</p></figcaption></figure>

2. Enter: Pentaho for server name.

<figure><img src="/files/L0xfEBZnf8zm7JzXtXNo" alt=""><figcaption><p>server group</p></figcaption></figure>

3. Click on 'Connection'.

<figure><img src="/files/6YybXscGxg5OPTXTIjpY" alt=""><figcaption><p>Connection details</p></figcaption></figure>

```
Welcome123
```

{% hint style="danger" %}
Don't save the password in Production environments.
{% endhint %}

4. Save.

<figure><img src="/files/c9HuvcEZni3GT9xj9Qvd" alt=""><figcaption><p>pgAdmin4 UI</p></figcaption></figure>
{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://academy.pentaho.com/pentaho-10-installation/installation/archive-installation/prepare-environment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
