最近研究pentaho和saiku,在網上搜集了一些安裝和配置的方法,親測有效,在這分享總結一下方便日后使用。
Saiku主要提供兩種安裝方式,獨立運行和集成在Pentaho BI平台上,本文會簡單介紹這兩種安裝方式。
一、集成在Pentaho BI平台上
pentaho環境安裝saiku插件步驟:
1. 所需文件:
biserver-ce-4.8.0-stable
(下載地址 http://nchc.dl.sourceforge.net/project/pentaho/Business%20Intelligence%20Server/4.8.0-stable/biserver-ce-4.8.0-stable.zip)
psw-ce-3.6.1
(下載地址 http://www.mirrorservice.org/sites/dl.sourceforge.net/pub/sourceforge/m/mo/mondrian/schema%20workbench/3.6.1-stable/psw-ce-3.6.1.zip)
saiku-plugin-2.6
(下載地址 http://www.meteorite.bi/downloads/saiku-plugin-2.6)
pull-parser-2.1.10.jar
(下載地址 http://mirrors.ibiblio.org/pub/mirrors/maven2/pull-parser/pull-parser/2.1.10/pull-parser-2.1.10.jar)
2. 解壓biserver-ce-4.8.0-stable,得到biserver-ce和administration-console文件夾。
3. 將saiku-plugin-2.6解壓到biserver-ce\pentaho-solutions\system\下。
4. 解壓psw-ce-3.6.1,得到schema-workbench文件夾,修改workbench.bat文件。
找到“rem you should also put mondrian.properties on the calsspath for it to be picked up” 這一行並在下方添加 set CP=%CP%;./mondrian.properties;
找到“rem add all needed JDBC drivers to the classpath” 這一行並在下方添加 set CP=%CP%;lib/驅動jar包(如果有多個驅動JAR文件,就添加多行)
5. 如使用schema-workbench提交時報錯:
Nested exception: org.gjt.xpp.impl.tokenizer.TokenizerException: white space expected before attribute name and not 't' at line 1 and column 134 seen ...
解決方案:
下載http://mirrors.ibiblio.org/pub/mirrors/maven2/pull-parser/pull-parser/2.1.10/pull-parser-2.1.10.jar替換schema-workbench\plugins下的pull-parser.jar
6. 如使用schema-workbench提交時,提交密碼在\server\biserver-ce\pentaho-solutions\system目錄下的publisher_config.xml文件中設置
pentaho數據庫HSQLDB遷移至mysql步驟:
1. 由於pentaho自帶了mysql數據庫的初始化腳本在目錄 D:\biserver-ce\data\mysql5下面。我們通過navicat for mysql 可視化圖形工具來按如下順序依次導入mysql腳本:create_repository_mysql ,再create_quartz_mysql,最后再create_sample_datasource_mysql
簡單介紹一下各腳本文件的對應的功能: create_repository_mysql.sql 創建hibernate數據庫,建用戶hibuser,密碼為password,對庫有完全權限,建DATASOURCE表。 create_quartz_mysql.sql 創建quartz數據庫,建用戶pentaho_user,密碼為password,對庫有完全權限,建了很多QRTZ_開頭的表 create_sample_datasource_mysql.sql 向hibernate庫的DATASOURCE表里面插入一個記錄,數據源即是在這里定義,顯示在管理控制台里面的Data Sources欄目里面
2. 修 改 D:\biserver-ce\pentaho-solutions\syste 目 錄 下 的 applicationContext-spring-security-jdbc.xml文件, 此文件作用:給BI server所用的Spring Security system建立JDBC認證。 對應值修改后應為:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/hibernate" />
<property name="username" value="hibuser" />
<property name="password" value="password" />
</bean>
3. 修改同一目錄下的applicationContext-spring-security-hibernate.properties文件, 此文件作用:設置屬性參數用於Spring Security來建立數據庫與hibernate的連接。 將文件中設置修改為如下:
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/hibernate
jdbc.username=hibuser
jdbc.password=password
hibernate.dialect=org.hibernate.dialect.MySQLDialect
4. 修改目錄D:\biserver-ce\pentaho-solutions\system\hibernate下的 hibernate-settings.xml文件。 它的作用:基本的hibernate設置,例如hibernate的數據庫后台。修改成如下所示:
<config-file>system/hibernate/mysql5.hibernate.cfg.xml</config-file>
5. 確認文件目錄D:\biserver-ce\pentaho-solutions\system\hibernate下的文件mysql5.hibernate.cfg.xml 其作用:配置hibernate數據庫的mysql連接,這樣就允許BI server內部的管理連接。 應該的配置是:
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/hibernate</property>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="connection.username">hibuser</property>
<property name="connection.password">password</property>
6. 配置D:\biserver-ce\tomcat\webapps\pentaho\WEB-INF目錄下的web.xml文件 設置為:
<context-param>
<param-name>base-url</param-name>
<param-value>http://192.168.0.60:8080/pentaho/</param-value>
</context-param>
說明:如果是localhost,那么僅能從本機登錄才能打開sampledata報表,如果是實際ip。那樣就能從別的機器登錄了。
7. 修改D:\biserver-ce\tomcat\webapps\pentaho\META-INF目錄下的context.xml文件。 其作用:建立hibernate和quartz兩者的配置文件。
<Context path="/pentaho" docbase="webapps/pentaho/">
<Resource name="jdbc/Hibernate" auth="Container" type="javax.sql.DataSource"
factory="org.apache.commons.dbcp.BasicDataSourceFactory" maxActive="20" maxIdle="5"
maxWait="10000" username="hibuser" password="password"
driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/hibernate"
validationQuery="select 1"/>
<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 1"/>
</Context>
二、獨立安裝saiku(tomcat上部署)
1.所需文件:
saiku-ui-2.6.war(下載地址 http://www.meteorite.bi/downloads/saiku-ui-2.6.war)
saiku-webapp-2.6.war(下載地址 http://www.meteorite.bi/downloads/saiku-webapp-2.5.war)
mysql-connector-java-5.1.35(數據庫對應版本)
2.Saiku webapps 部署:
saiku-ui-2.6.war修改成ROOT.war; saiku-webapp-2.6.war修改成saiku.war;拷貝兩個war文件到tomcat/webapp目錄下,現在可以啟動tomcat;然后再瀏覽器中輸入:http://localhost:8080,以看到Saiku的登錄頁面,輸入admin和admin作為密碼登錄Saiku。
3.配置Saiku使用cubeSchema 和數據庫:
停止tomcat,然后拷貝數據庫對應的jdbc jar(此處為mysql-connector-java-5.1.35)到tomcat/lib文件夾中。
拷貝schema(xml格式)文件到tomcat/webapps/saiku/WEB-INF/classes/saiku-datasources/
在tomcat/webapps/saiku/WEB-INF/classes/saiku-datasources/目錄下創建一個配置文件sales.txt並寫入以下內容(每個cube對應一個配置文件,名字不限,但只能配置一個,不能共享。(在一個文件中,配置兩個,后面的會覆蓋前面的。新建一個cube,新建一個datasources配置說明。只有配置了說明文件,才能在saiku里顯示。):
#declaration of Sauce Dallas sales cube for Sakiu
#———————————————
type=OLAP
name=SauceDallas
driver=mondrian.olap4j.MondrianOlap4jDriver
location=jdbc:mondrian:Jdbc=jdbc:mysql://localhost:3306/dbtest1;Catalog=res:saiku-datasources/Schema1.xml;JdbcDrivers=com.mysql.jdbc.Driver;
username=root
password=root
配置說明:
type=OLAP指定一個 OLAP 引擎.沒有見過非OLAP的屬性值。
name : 給你的數據源命名。
driver: 指定 Mondrian driver(將二維關系表轉化為多維度表的驅動).沒有見過其他的屬性值。
location :這個屬性有幾個部分組成,使用分號分隔。
jdbc:mondrian:Jdbc=jdbc:mysql://localhost/1_tutorialSaiku :
指定數據庫對應jdbc url,前面部分不需要改動,僅僅需要修改主機和對應的數據庫名稱。這里的主機是localhost,對應數據庫是1_tutorialSaiku
Catalog=res:saiku-datasources/sales_mondrian_schema.xml
指定mondrian schema文件。res表明是文件的路徑,這里是從saiku webapp目錄開始;
JdbcDrivers=com.mysql.jdbc.Driver
指明java 類文件作為數據庫連接驅動。
4.重啟tomcat后報錯java.io.NotSerializableException解決方法:
原因是:tomcat停止時,保存session資源,然后在重啟服務后,會嘗試恢復session。
打開tomcat下/conf/context.xml文件,添加如下內容:
<Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false">
<Store className="org.apache.catalina.session.FileStore"/>
</Manager>