pentaho7.0將資料庫移植成mysql

zyj8170發表於2020-04-04

Pentaho 內建資料是 hsql. 資料庫。那我們如何換掉移植成 mysql ?

思想:

移植的條件:

1. 首先要有一個 mysql 資料。

2. 將 pentaho 的啟動配置連線到 mysql 上。

我現在做一個將 pentaho7.0 資料庫移植的例子。

1.       首先在 pentaho-server/data/mysql5 資料夾下將裡面 3 個 sql 檔案,在 mysql 下面執行。

          步驟是:登陸 mysql  –u –p

          將 sql 檔案匯入: Source 加檔案路徑

2.       然後就是將 pentaho 的啟動配置連線到 mysql 。

修改配置檔案(修改預設資料庫為mysql,如不需要可以不做)
編輯
\biserver-ce\pentaho-solutions\system\applicationContext-spring-security-jdbc.properties
 # The fully qualified Java class name of the JDBC driver to be used
datasource.driver.classname=com.mysql.jdbc.Driver
 # The connection URL to be passed to our JDBC driver to establish a connection
datasource.url=jdbc:mysql://localhost:3306/hibernate
 # The connection username to be passed to our JDBC driver to establish a connection
datasource.username=root
 # The connection password to be passed to our JDBC driver to establish a connection
datasource.password=root
 # The SQL query that will be used to validate connections from this pool before returning them to the caller.# This query must be an SELECT statement that returns at least one row.
 # HSQLDB: SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS
 # MySQL, H2, MS-SQL, POSTGRESQL, SQLite: SELECT 1
 # Oracle: SELECT 1 FROM DUAL
datasource.validation.query=SELECT USER()
編輯
\biserver-ce\pentaho-solutions\system\applicationContext-spring-security-hibernate.properties
 jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/hibernate
jdbc.username=root
jdbc.password=root
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
編輯
\biserver-ce\pentaho-solutions\system\hibernate\hibernate-settings.xml
 system/hibernate/mysql5.hibernate.cfg.xml
編輯
\biserver-ce\pentaho-solutions\system\quartz\quartz.properties
刪除註釋
 org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
編輯
\biserver-ce\pentaho-solutions\system\simple-jndi\jdbc.properties
 SampleData/type=javax.sql.DataSource
SampleData/driver=com.mysql.jdbc.Driver
SampleData/url=jdbc:mysql://localhost:3306/sampledata
SampleData/user=pentaho_user
SampleData/password=password
Hibernate/type=javax.sql.DataSource
Hibernate/driver=com.mysql.jdbc.Driver
Hibernate/url=jdbc:mysql://localhost:3306/hibernate
Hibernate/user=root
Hibernate/password=root
Quartz/type=javax.sql.DataSource
Quartz/driver=com.mysql.jdbc.Driver
Quartz/url=jdbc:mysql://localhost:3306/quartz
Quartz/user=pentaho_user
Quartz/password=password
Shark/type=javax.sql.DataSource
Shark/driver=com.mysql.jdbc.Driver
Shark/url=jdbc:mysql://localhost:3306/shark
Shark/user=root
Shark/password=root
SampleDataAdmin/type=javax.sql.DataSource
SampleDataAdmin/driver=com.mysql.jdbc.Driver
SampleDataAdmin/url=jdbc:mysql://localhost:3306/sampledata
SampleDataAdmin/user=pentaho_admin
SampleDataAdmin/password=password
編輯
\biserver-ce\tomcat\webapps\pentaho\META-INF\context.xml
  
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/pentaho">
  <Resource name="jdbc/Hibernate" auth="Container" type="javax.sql.DataSource"
    factory="org.apache.commons.dbcp.BasicDataSourceFactory" maxActive="20" maxIdle="5"
    maxWait="10000" username="root" password="root"
    driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/hibernate"
    validationQuery="select user()" />
   
    <Resource name="jdbc/Quartz" auth="Container" type="javax.sql.DataSource"
      factory="org.apache.commons.dbcp.BasicDataSourceFactory" maxActive="20" maxIdle="5"
      maxWait="10000" username="pentaho_user" password="password"
      driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/quartz"
      validationQuery="select user()"/>
</Context>
停用預設的HSqlDB
\biserver-ce\tomcat\webapps\pentaho\WEB-INF\web.xml
註釋掉
   
  <!-- [BEGIN HSQLDB DATABASES] -->
  <context-param>
    <param-name>hsqldb-databases</param-name>
    <param-value>sampledata@../../data/hsqldb/sampledata,hibernate@../../data/hsqldb/hibernate,quartz@../../data/hsqldb/quartz</param-value>
  </context-param>
  <!-- [END HSQLDB DATABASES] -->
  <!-- [BEGIN HSQLDB STARTER] -->
  <listener>
    <listener-class>org.pentaho.platform.web.http.context.HsqldbStartupListener</listener-class>
  </listener>
  <!-- [END HSQLDB STARTER] -->
編輯
這裡的IP,可以開放允許外部訪問
  <context-param>
    <param-name>fully-qualified-server-url</param-name>
    <param-value>http://localhost:8080/pentaho/</param-value>
  </context-param>
 複製mysql的驅動包到
\biserver-ce\tomcat\webapps\pentaho\WEB-INF\lib
3.啟動bi Server,開啟瀏覽器,新建資料來源

相關文章