Pentaho Architecture
- Presentation Layerเทคโนโลยี หลักที่ใช้คือ GWT แต่ ในส่วนของ dashboard โดยเฉพาะ CDF (community dashboard framework) จะใช้ Jquery จะเข้ามาร่วมด้วยในการแสดงผล
- Business Logic Layerตัวหลักในการทำงานของ Pentaho BI Server คือ ตัว work flow ของ pentaho ที่ จะทำการจัด sequence ของ งานที่เกิดขึ้น เช่น การ ดึงข้อมูล จัดระเบียบข้อมูล จนถึง การส่ง output ไปให้ report engine หรือ web engine ทำการ render output ออกมาในรูปแบบ ต่างๆ (HTML, pdf, excel, wsdl)
- Data Layerแบ่ง ได้เป็น 2 กลุ่มใหญ่ๆ คือ ส่วนที่จัดการ user และ role ซึ่งจะทำการ config ผ่านไฟล์ (xml และ properties) และสุดท้ายส่วนที่ใช้ในการจัดการข้อมูลที่จะนำมา ประมวลผล(ออก reportทำ cube) Pentaho จะใช้ JNDI ในการ lookup ตัว DB ต่างๆที่ใช้งานซึ่งสามารถจัดการ data source ทั้งการเพิ่มและลบผ่านทาง web interface
- Cachedehcahed คือ engine ที่ใช้ใน Pentaho ที่จะทำการ cache data จาก การสร้าง cube หรือการดึงข้อมูลจาก DBลักษณะการทำงานก็จะใช้ key กับ value ในการเก็บข้อมูล และสามารถที่จะกำหนดได้ว่า จะเก็บกี่ instance ใน memory หรือเมื่อมีข้อมูลมากกว่าที่กำหนดจะ เก็บเป็นไฟล์ ที่ Directory ไหนขนาดเท่าไหร่
ในเบื้อง ต้นการทำงานจะทำในเครื่องเดียว แต่ถ้ามีงานที่มากขึ้นหรือ ข้อมูลมีขนาดใหญ่ขึ้น เราสามารถที่จะกระจายการประมวลผลหรือกระจายการเก็บข้อมูลไปที่เครื่องอื่น โดยการปรับ flow การทำงานในชั้น Business Logic Layer และการเพิ่มหรือเปลี่ยน data source
ความต้องการพื้นฐาน
- Hardware : cpu(recommend 64 bits) ขั้นต่ำ 2 GHz , RAM ขั้นต่ำ 2 GB, HD ขั้นต่ำ 2 GB
- OS: any
- Software : ขั้นต่ำ java 1.5 (recommend 64 bits version ถ้า cpu เป็น รุ่น64 bits)
- Database : !MySQL, Postgresql, !MsSQL, Oracle หรืออื่นๆที่มี jdbc driver
การติดตั้ง (pre-config)
- 1.download Pentaho BI server (http://sourceforge.net/projects/pentaho/files/)
- 2.unpack file ไปไว้ยัง directory ที่ต้องการ ซึ่งภายใต้ fileที่ทำ การ unpack จะมี 2 directories คือ biserver-ce และ administration-console
- 3.ทำการ start Pentaho BI Server โดยสั่ง run start-pentaho.sh (หรือ start-pentaho.bat กรณีที่ install บน windows)ที่อยู่ภายใต้ biserver-ce
- 4.ทดสอบ pentaho โดยพิมพ์ url : http://localhost:8080/pentaho ที่ web browser
- 5.ทำการ เพิ่ม password เพื่อที่จะทำให้ pentaho server สามารถที่จะ publish file จาก report designer tool และ Schema Workbench ได้โดยทำการแก้ไขที่
PentahoPath/biserver-ce/pentaho-solutions/system/publisher_config.xml
<publisher-config>
<publisher-password>password</publisher-password>
</publisher-config>
(กำหนด password ตามต้องการ)
การติดตั้งแบบ manual
- 1.download tomcat (version 5.x.x ขึ้นไป) หรือ tcserver
- 2.install container ให้ upzip file ไปไว้ยัง directory ที่ต้องการ
- 3.ทดลอง start
ถ้าเป็น tomcat ให้ไปยัง tomcat.xxx/bin แล้วเรียก startup.bat
ส่วน tcserver ให้ทำการ install instance spring-insight-instance ก่อน โดยใช้คำสั่ง tcruntime-instance.bat install spring-insight-instance instance
จากนั้น สั่ง run โดย tcruntime-ctl.bat instance spring-insight-instance start
- 4. ไปที่ browser แล้วพิมพ์ url localhost:8080
- 5. deploy pentaho ทำได้ 2 กรณีใหญ่ๆคือ deploy จาก war หรือ นำ file ไปวางที่ webapp ของ tomcat หรือ instance ของ tcserver
ถ้าใช้ war file ให้ download sourcecode ที่ชื่อว่า biserver-manual-ce จาก http://sourceforge.net/projects/pentaho/files แล้วทำการ build ซึ่งจะได้ war file มา 3 files คือ pentaho.war, pentaho-style.war และ sw-style.war เมื่อทำการ start container ตัว war file จะถูก deploy โดย อัตโนมัติ
กรณีที่ใช้ file ไปวาง วิธีที่ง่ายที่สุดให้ทำการ copy file pentaho, pentaho-style และ sw-style จาก PentahoPath/biserver-ce/pentaho-solutions/tomcat/webapps แล้วนำไปวางที่ webapps directory ของ tomcat หรือ spring-insight-instance/webapps/ (tcserver)
- 6. จากนั้นทำการ copy file จาก biserver-ce-x.x.x/biserver-ce/pentaho-solutions ไปไว้ยัง directory ที่ต้องการ
- 7. เพิ่ม pentaho-solution path เข้าไปที่ file web.xml (file จะอยู่ที่ webapps/pentaho/WEB-INF/)
<context-param>
<param-name>solution-path</param-name>
<param-value>add here path to solution file</param-value>
</context-param>
- 8. copy jdbc driver ที่ใช้ติดต่อกับ DB ชนิดต่างๆ ไปไว้ที่ tomcat/common/lib (version 5.x.x), tomcat/lib (version 6.x.x) และ instance-name/lib (tcserver)
- 9. ส่วน authentication และ authorization ถ้าจะใช้ hsql ให้ทำการ start hsql ก่อน start pentaho แต่ถ้า จะใช้ ตัวอื่นนอกเหนือจากนี้ ให้ ทำการตั้งค่าตามหัวข้อถัดไป
การจัดการในเรื่อง authentication และ authorization
- จากค่าเริ่มต้น pentaho จะใช้ database (hsql) ในการ เก็บ user & role และอื่นๆที่เกี่ยวข้อง ซึ่งเราสามารถเปลี่ยนให้ใช้ LDAP หรือ database ตัวอื่นๆ โดยเปลี่ยนค่า config ใน xml file ที่อยู่ภายใต้
- PentahoPath/biserver-ce/pentaho-solutions/system
- PentahoPath/biserver-ce/tomcat/webapps/pentaho/META-INF
การ authentication ผ่าน LDAP และ authorize ผ่าน DB
- เนื่องจาก pentaho ใช้ spring-framework เป็น coreในการ Implememt ทำให้เราสามารถไล่ได้ว่าจังหวะที่ทำการ start Application จะมี bean ไหน บ้างที่จะถูกสร้างขึ้นมาแล้วเก็บไว้ใน Application Context โดย context แรกที่ container ทำการอ่านขึ้นมาคือ pentaho-spring-beans.xml ดังนั้นการแก้ไขการจัดการ user ก็จะมีขั้นตอนดังนี้
- 1.แก้ไฟล์ pentaho-spring-beans.xml จาก
<beans>
<import resource=”pentahoSystemConfig.xml” />
<import resource=”adminPlugins.xml” />
<import resource=”systemListeners.xml” />
<import resource=”sessionStartupActions.xml” />
<import resource=”applicationContext-spring-security.xml” />
<import resource=”applicationContext-common-authorization.xml” />
<import resource=”applicationContext-spring-security-hibernate.xml” /> (อ้างถึงค่า ที่ใช้ในการกำหนดการ authentication)
<import resource=”applicationContext-pentaho-security-hibernate.xml” /> (อ้างถึงค่า ที่ใช้ในการกำหนดการ authorization)
<import resource=”pentahoObjects.spring.xml” />
</beans>
ไปเป็น
<beans>
<import resource=”pentahoSystemConfig.xml” />
<import resource=”adminPlugins.xml” />
<import resource=”systemListeners.xml” />
<import resource=”sessionStartupActions.xml” />
<import resource=”applicationContext-spring-security.xml” />
<import resource=”applicationContext-common-authorization.xml” />
<import resource=”applicationContext-spring-security-ldap.xml” />
<import resource=”applicationContext-pentaho-security-jdbc.xml” />
<import resource=”pentahoObjects.spring.xml” />
</beans>
- 2.แก้ไฟล์ applicationContext-spring-security-ldap.xml แก้ทิ่ populator bean
<bean id=”populator” class=”org.springframework.security.ldap.populator.UserDetailsServiceLdapAuthoritiesPopulator”>
<constructor-arg ref=”userDetailsService” />
</bean>
หลังจากนั้นลบ userDetailsService bean
- 3.แก้ไฟล์ applicationContext-pentaho-security-jdbc.xml โดยเพิ่ม bean ไปอีกสอง ตัว data
Source และ userDetailsService
<bean id=”dataSource” class=”org.springframework.jdbc.datasource.DriverManagerDataSource”>
<property name=”driverClassName” value=”org.hsqldb.jdbcDriver” />
<property name=”url” value=”jdbc:hsqldb:hsql://localhost:9001/hibernate” />
<property name=”username” value=”sa” />
<property name=”password” value=”" />
</bean>
(dataSource bean ใช้ในการกำหนดค่าของ driverClassName ที่ใช้งาน url, username และ password ที่ใช้ในการติดต่อ DB)
<bean id=”userDetailsService” class=”org.springframework.security.userdetails.jdbc.JdbcDaoImpl”>
<property name=”dataSource”>
<ref local=”dataSource” />
</property>
<property name=”authoritiesByUsernameQuery”>
<value>
<![CDATA[SELECT username, authority FROM granted_authorities WHERE username = ?]]>
</value>
</property>
<property name=”usersByUsernameQuery”>
<value>
<![CDATA[SELECT username, password, enabled FROM users WHERE username = ?]]>
</value>
</property>
</bean>
- 4.หลังจากแก้ไข เสร็จเรียบร้อยแล้ว pentaho จะทำการ authentication ที่ LDAP และ authorisation โดยใช้ hsql ซึ่งถ้าต้องการเปลี่ยนไปใช้ database ตัวอื่น
ให้ไปแก้ไขที่ PentahoPath/biserver-ce/tomcat/webapps/pentaho/META-INF/context.xml
เปลี่ยนจาก
<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=”org.hsqldb.jdbcDriver” url=”jdbc:hsqldb:hsql://localhost/hibernate”
validationQuery=”select count(*) from INFORMATION_SCHEMA.SYSTEM_SEQUENCES” />
<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=”org.hsqldb.jdbcDriver” url=”jdbc:hsqldb:hsql://localhost/quartz”
validationQuery=”select count(*) from INFORMATION_SCHEMA.SYSTEM_SEQUENCES”/>
</Context>
ไปเป็น
<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>
- ในที่นี้เปลี่ยนไปใช้ mysql สำหรับ schema ของ pentaho-mysql สามารถ download ได้ที่นี่ download
แล้วไปแก้ไข driverClassName, url, username และ password ในข้อ 3 อีกครั้งหนึ่งให้ไปใช้ Mysql
การเปลี่ยน Login ไม่ให้โชว์ users
- ทำการ แก้ไขที่ biserver-ce\tomcat\webapps\pentaho\mantleLogin\loginsetting s.properties
- โดยเปลี่ยนจาก : #showUsersList=true
- ไปเป็น : showUsersList=false
กำหนดให้เครื่องอื่นสามารถ access เข้ามาได้
- ทำการ แก้ไขที่ : biserver-ce/tomcat/webapps/pentaho/WEB_INF/web.xml
- โดย เปลี่ยนจาก
<context-param>
<param-name>TrustedIpAddrs</param-name>
<param-value>127.0.0.1</param-value>
</context-param>
<context-param>
<param-name>base-url</param-name>
<param-value>http://localhost/pentaho/</param-value>
</context-param>
- ไปเป็น
<context-param>
<param-name>TrustedIpAddrs</param-name>
<param-value>local IP,127.0.0.1</param-value>
</context-param>
<context-param>
<param-name>base-url</param-name>
<param-value>http://local IP/pentaho/</param-value>
</context-param>
- จากนั้นให้ไป เพิ่ม local IP ใน host file เพื่อ map กับชื่อเครื่อง หรือ url
( IP ที่เพิ่มเข้าไปใน context param ที่ชื่อ !TrustedIpAddrs ให้ใส่เพิ่มเข้าไปโดยใช้ comma ขั้นไม่ต้องเว้นวรรค)
การปรับ ขนาด momory ในการใช้งาน
- windows :
- 1. tomcat ใน catalina.bat ให้เพิ่ม CATALINA_OPTS=”-Xms256m -Xmx768m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000″
- 2. tcserver ใน tcserver/instance-name/conf/wrapper.conf ให้เพิ่มค่าใน wrapper.java.additional.8 ตัวอย่าง wrapper.java.additional.8=-Xms256m -Xmx768m -XX:MaxPermSize=256m
- linux :
- 1. tomcat ใน catalina.sh ให้เพิ่ม CATALINA_OPTS=”-Xms256m -Xmx768m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000″ หลังจาก บรรทัดที่ set CATALINA_PATH
- 2. tcserver ให้เพิ่ม JVM_OPTS variable ใน tcserver/instance-name/bin/setenv.sh file ตัวอย่าง JVM_OPTION=”-Xms256m -Xmx768m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000″
ref: tcserver, tomcat, prashantraju.com, wiki pentaho