Integração Pentaho BA 5.2 CE com PostgreSQL 9.3
Autor: cjrocha | Publicado: 2014-11-15T22:59:00-02:00




Veja aqui como integrar o Pentaho Business Analytics (BA) 5.2 Comminity Edition (CE) ao Sistema Gerenciador de Banco de Dados (SGBD) PostgreSQL 9.3. Acredito que esta instalação não seja mais novidade, no entanto, vários profissionais preferem consultar uma documentação mais atualizada. E como estou precisando realizar esta integração agora, apenas vou descrever aqui os passos à medida em que eu for realizando os procedimentos.

Como já é sabido, a partir da versão 5.0 a Pentaho optou por utilizar um gerenciador de conteúdos para armazenar o repositório da soluções, contrário às versões anteriores que utilizavam diretamente o sistema de arquivos. Este gerenciador de conteúdos é o Apache Jackrrabit, que por padrão vem pré configurado na versão CE, utilizando o SGBD H2. Então vamos precisar migrar o banco chamado "jackrabbit", que recebe o mesmo nome do gerenciador de conteúdos, assim como, os tradicionalmente utilizados pela Pentaho, o hibernate e o quartz que utilizam o SGBD HSQLDB.

Antes de iniciar a integração, é necessário que você providencie a instalação do Pentaho BA 5.2 CE e do SGBD PostgreSQL. Consulte os links citados abaixo para realizar estas tarefas.

- Instalação Pentaho Business Analytics 5.2 Community Edition

- Instalação do PostgreSQL 9.3 em distro Debian/Ubuntu



1 -&nbsp; Criação da estrutura básica de bancos de dados do PostgreSQL

Agora que estamos com o Pentaho BA 5.2 e o PostgreSQL funcionais, podemos iniciar a migração. 

Então, inicialmente, vamos preparar os bancos de dados, utilizando os scripts disponibilizados na própria instalação do biserver-ce.

Tendo como referência a instalação do Pentaho BA 5.2, copie a pasta dos scripts do PostgreSQL para outra pasta, ou se for o caso de utilizar um servidor dedicado para o SGBD, copie para uma pasta neste servidor.



~# cp -rv ./biserver-ce/data/postgresql /tmp



Utilizando o usuário "postgres" ou "superuser" do PostgreSQL, execute os scripts para criação da estrutura básica, ou seja, bancos de dados e/ou tabelas.



~# su - postgres

~$ psql -p 5432 -f /tmp/postgresql/create_repository_postgresql.sql

~$ psql -p 5432 -f /tmp/postgresql/create_quartz_postgresql.sql

~$ psql -p 5432 -f /tmp/postgresql/create_jcr_postgresql.sql 



No PostgreSQL, utilizando o "psql", crie a tabela "QRTZ" no banco do "quartz".

~$ psql
postgres=# \c quartz;

&nbsp;CREATE TABLE "QRTZ"(NAME VARCHAR(200) NOT NULL,PRIMARY KEY (NAME)); 



Observe que os bancos foram criados.

~$ psql

postgres=# \l

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List of databases&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; Owner&nbsp;&nbsp;&nbsp;&nbsp; | Encoding |&nbsp;&nbsp; Collate&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; Ctype&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Access privileges&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -----------------+--------------+----------+-------------+-------------+-------------------------------&nbsp;hibernate&nbsp;&nbsp; | hibuser | UTF8&nbsp;&nbsp;&nbsp;&nbsp; | pt_BR.UTF-8 | pt_BR.UTF-8 | =Tc/hibuser + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | hibuser=CTc/hibuser&nbsp;jackrabbit&nbsp; | jcr_user&nbsp; | UTF8&nbsp;&nbsp;&nbsp;&nbsp; | pt_BR.UTF-8 | pt_BR.UTF-8 | =Tc/jcr_user&nbsp; + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | jcr_user=CTc/jcr_user&nbsp;quartz &nbsp; &nbsp; &nbsp; | pentaho_user | UTF8&nbsp;&nbsp;&nbsp;&nbsp; | pt_BR.UTF-8 | pt_BR.UTF-8 | =Tc/pentaho_user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +







Não esquecer de habilitar o acesso a estes bancos, para o Pentaho BA, no "pg_hba.conf". Na dúvida, veja este post "Configurações adicionais para PostgreSQL 9.1", que serve também para a versão 9.3 do PostgreSQL.



2 - Configuração do PostgreSQL no Pentaho BA 5.2 CE

Pare o serviço do Pentaho BA / PUC.

Faça um backup do Pentaho BA 5.2. Veja um exemplo a seguir.

~# mkdir /opt/backups

~# tar -vzcf /opt/backups/biserver-ce-aaaammdd.tar.gz ./biserver-ce



Vamos configurar os principais parâmetros dos arquivos, utilizando as configurações padrões utilizadas nos scripts, sendo:

Banco de Dados&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Usuário&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Senha

hibernate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hibuser&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; password

quartz&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pentaho_user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; password

jackrabbit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jcr_user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; password



Altere somente as informações que estão em destaque.



Arquivo: "./tomcat/webapps/pentaho/META-INF/context.xml".



&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;Context path="/pentaho" docbase="webapps/pentaho/"&gt;&lt;Resource name="jdbc/Hibernate"

&nbsp;&nbsp;&nbsp;&nbsp; auth="Container" type="javax.sql.DataSource"

&nbsp;&nbsp;&nbsp;&nbsp; factory="org.apache.commons.dbcp.BasicDataSourceFactory"

&nbsp;&nbsp;&nbsp;&nbsp; maxActive="20" maxIdle="5"

&nbsp;&nbsp;&nbsp;&nbsp; maxWait="10000"

&nbsp;&nbsp;&nbsp;&nbsp; username="hibuser"

&nbsp;&nbsp;&nbsp;&nbsp; password="password"

&nbsp;&nbsp;&nbsp;&nbsp; driverClassName="org.postgresql.Driver"

&nbsp;&nbsp;&nbsp;&nbsp; url="jdbc:postgresql://localhost:5432/hibernate"

&nbsp;&nbsp;&nbsp;&nbsp; validationQuery="select 1"/&gt;&lt;Resource name="jdbc/Quartz"

&nbsp;&nbsp;&nbsp;&nbsp; auth="Container"

&nbsp;&nbsp;&nbsp;&nbsp; type="javax.sql.DataSource"&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp; factory="org.apache.commons.dbcp.BasicDataSourceFactory"

&nbsp;&nbsp;&nbsp;&nbsp; maxActive="20"

&nbsp;&nbsp;&nbsp;&nbsp; maxIdle="5"

&nbsp;&nbsp;&nbsp;&nbsp; maxWait="10000"

&nbsp;&nbsp;&nbsp;&nbsp; username="pentaho_user"

&nbsp;&nbsp;&nbsp;&nbsp; password="password"

&nbsp;&nbsp;&nbsp;&nbsp; driverClassName="org.postgresql.Driver"

&nbsp;&nbsp;&nbsp;&nbsp; url="jdbc:postgresql://localhost:5432/quartz"

&nbsp;&nbsp;&nbsp;&nbsp; validationQuery="select 1"/&gt;&lt;/Context&gt;&nbsp;

Exclua este Arquivo: "./tomcat/conf/Catalina/localhost/pentaho.xml".

~# sudo rm -rf ./tomcat/conf/Catalina/localhost/pentaho.xml



Arquivo: "./pentaho-solutions/system/dialects/postgresql/applicationContext-spring-security-hibernate.properties".

 jdbc.driver=org.postgresql.Driverjdbc.url=jdbc:postgresql://localhost:5432/hibernatejdbc.username=hibuserjdbc.password=passwordhibernate.dialect=org.hibernate.dialect.PostgreSQLDialect



Arquivo: "./pentaho-solutions/system/applicationContext-spring-security-hibernate.properties".



 jdbc.driver=org.postgresql.Driverjdbc.url=jdbc:postgresql://localhost:5432/hibernatejdbc.username=hibuserjdbc.password=passwordhibernate.dialect=org.hibernate.dialect.PostgreSQLDialect&nbsp;

Arquivo: "./pentaho-solutions/system/hibernate/hibernate-settings.xml".

&lt;config-file&gt;system/hibernate/postgresql.hibernate.cfg.xml&lt;/config-file&gt;



Arquivo: "./pentaho-solutions/system/hibernate/postgresql.hibernate.cfg.xml".

&lt;property name="connection.driver_class"&gt;org.postgresql.Driver&lt;/property&gt;&lt;property name="connection.url"&gt;jdbc:postgresql://localhost:5432/hibernate&lt;/property&gt;&lt;property name="dialect"&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/property&gt;&lt;property name="connection.username"&gt;hibuser&lt;/property&gt;&lt;property name="connection.password"&gt;password&lt;/property&gt;



Arquivo: "./pentaho-solutions/system/jackrabbit/repository.xml".

Neste arquivo, é necessário a correção em vários parâmetros. Utilize o nome da classe como referência, para certificar que todas as modificações foram realizadas. Observe que as configurações referentes ao banco h2 são comentadas e as do PostgreSQL descomn



Classe: "org.apache.jackrabbit.core.fs.local.LocalFileSystem".

--&gt; 

&lt;FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem"&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="driver" value="org.postgresql.Driver"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="url" value="jdbc:postgresql://localhost:5432/jackrabbit"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="user" value="jcr_user"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="password" value="password"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schema" value="postgresql"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schemaObjectPrefix" value="fs_repos_"/&gt;&lt;/FileSystem&gt;



&lt;!-- 

&lt;FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="path" value="${rep.home}/repository"/&gt;&lt;/FileSystem&gt;

--&gt;



Classe: "org.apache.jackrabbit.core.data.db.DbDataStore".

--&gt; 



&lt;DataStore class="org.apache.jackrabbit.core.data.db.DbDataStore"&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="url" value="jdbc:postgresql://localhost:5432/jackrabbit"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="driver" value="org.postgresql.Driver"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="user" value="jcr_user"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="password" value="password"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="databaseType" value="postgresql"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="minRecordLength" value="1024"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="maxConnections" value="3"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="copyWhenReading" value="true"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="tablePrefix" value=""/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schemaObjectPrefix" value="ds_repos_"/&gt;&lt;/DataStore&gt;&lt;!--&lt;DataStore class="org.apache.jackrabbit.core.data.FileDataStore"/&gt;--&gt;&nbsp;

Classe: "org.apache.jackrabbit.core.fs.db.DbFileSystem".

--&gt; 

&lt;FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem"&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="driver" value="org.postgresql.Driver"/&gt;&nbsp; &nbsp;&nbsp; &lt;param name="url" value="jdbc:postgresql://localhost:5432/jackrabbit"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="user" value="jcr_user"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="password" value="password"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schema" value="postgresql"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schemaObjectPrefix" value="fs_ws_"/&gt;&lt;/FileSystem&gt;&lt;!--&lt;FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"&gt;&nbsp; &nbsp;&nbsp; &lt;param name="path" value="${wsp.home}"/&gt;&lt;/FileSystem&gt;--&gt;



Classe: "org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager".

--&gt;

&lt;PersistenceManager

&nbsp;&nbsp;&nbsp;&nbsp; class="org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager"&gt;

&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="url" value="jdbc:postgresql://localhost:5432/jackrabbit"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="driver" value="org.postgresql.Driver"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="user" value="jcr_user"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="password" value="password"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schema" value="postgresql"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schemaObjectPrefix" value="${wsp.name}_pm_ws_"/&gt;&lt;/PersistenceManager&gt;&lt;!--

&lt;PersistenceManager&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp; class="org.apache.jackrabbit.core.persistence.pool.H2PersistenceManager"&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="url" value="jdbc:h2:${wsp.home}/db"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schemaObjectPrefix" value="${wsp.name}_"/&gt;&lt;/PersistenceManager&gt;--&gt;



Classe: "org.apache.jackrabbit.core.fs.db.DbFileSystem".

--&gt; 

&nbsp;&nbsp;&nbsp; &lt;FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="driver" value="org.postgresql.Driver"/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="url" value="jdbc:postgresql://localhost:5432/jackrabbit"/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="user" value="jcr_user"/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="password" value="password"/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schema" value="postgresql"/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schemaObjectPrefix" value="fs_ver_"/&gt;&nbsp;&nbsp;&nbsp; &lt;/FileSystem&gt;&lt;!--&nbsp;&nbsp;&nbsp; &lt;FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="path" value="${rep.home}/version" /&gt;&nbsp;&nbsp;&nbsp; &lt;/FileSystem&gt;--&gt;















Classe: "org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager".--&gt;&lt;PersistenceManager

&nbsp;&nbsp;&nbsp;&nbsp; class="org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager"&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="url" value="jdbc:postgresql://localhost:5432/jackrabbit"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="driver" value="org.postgresql.Driver"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="user" value="jcr_user"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="password" value="password"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schema" value="postgresql"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schemaObjectPrefix" value="pm_ver_"/&gt;&lt;/PersistenceManager&gt;&lt;!--&lt;PersistenceManager

&nbsp;&nbsp;&nbsp;&nbsp; class="org.apache.jackrabbit.core.persistence.pool.H2PersistenceManager"&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="url" value="jdbc:h2:${rep.home}/version/db"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="schemaObjectPrefix" value="version_"/&gt;&lt;/PersistenceManager&gt;--&gt;

Arquivo: "./tomcat/webapps/pentaho/WEB-INF/web.xml".
Comente as linhas referentes à inicialização do SGBD HSQLDB, uma vez que este serviço não mais será utilizado.
&lt;!-- [BEGIN HSQLDB DATABASES]
&lt;context-param&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param-name&gt;hsqldb-databases&lt;/param-name&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param-value&gt;sampledata@../../data/hsqldb/sampledata,hibernate@../../data/hsqldb/hibernate,quartz@../../data/hsqldb/quartz&lt;/param-value&gt;&lt;/context-param&gt;[END HSQLDB DATABASES] --&gt;

&lt;!-- [BEGIN HSQLDB STARTER]&lt;listener&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;listener-class&gt;org.pentaho.platform.web.http.context.HsqldbStartupListener&lt;/listener-class&gt;&lt;/listener&gt;[END HSQLDB STARTER] --&gt;


Arquivo: "./pentaho-solutions/system/pentaho-spring-beans.xml".
Comente a linha referente à inicialização do SGBD H2, uma vez que este serviço não mais será utilizado.
&lt;!-- &lt;import resource="GettingStartedDB-spring.xml" /&gt; Remove this line to unhook the Getting Started DB --&gt;


Com atenção, exclua os arquivos conforme o exemplo a seguir:

~# rm -rf ./tomcat/work/*

~# rm -rf ./tomcat/temp/* 

~# rm -rf ./pentaho-solutions/system/jackrabbit/repository/repository

~# rm -rf ./pentaho-solutions/system/jackrabbit/repository/workspaces



Concluído as configurações, Inicie o serviço do PUC.



Em caso de problemas na inicialização, reveja as configurações, observando a bertura e fechamento de tags, nomes de usuários, senhas, drivers configurados nos arquivos, ip's e portas dos bancos, que são os principais problema ocorridos.

Utilize o log do tomcat como suporte para esta tarefa, em "./tomcat/logs/catalina.out".


Veja também:
- Inicializar o HSQLDB independente do Pentaho BA