http://blog.itpub.net/28974745/viewspace-2217773/

一、Saiku的下载安装和启动

下载地址:
https://community.meteorite.bi/

下载后解压,即完成安装。

修改环境变量为安装目录下的tomcat目录:
CATALINA_HOME = D:\yizit\software\saiku-server\tomcat

执行start-saiku.bat启动saiku,启动后命令行窗口不能关闭。命令窗口中文乱码情况,需要修改start-saiku.bat文件,将UTF-8更改为GBK。

在浏览器地址栏输入http://localhost:8080/upload.html,出现以下要求上传License的页面

License获取网址:https://licensing.meteorite.bi/login

先点击sign up进行用户注册,注册后收到确认邮件,在邮件里点击进入License获取页面

先创建公司,再创建License,将生成的License保存到本地文件。

在上传License页面将License文件上传,需要帐户admin,admin。

前往localhost:8080,输入admin,admin,即可进入Saiku系统。

二、使用示例

将需要的数据库驱动jar包复制到D:\yizit\software\saiku-server\tomcat\webapps\saiku\WEB-INF\lib目录下,这里连接的是Oracle数据库。

一个最为简单的例子是直接使用Oracle数据库里自带的SCOTT用户,对员工表EMP和部门表DEPT构建模型,模式文件如下:
<Schema name="scott">
  <Cube name="Cube_scott" visible="true" cache="true" enabled="true">
    <Table name="EMP" schema="SCOTT">
    </Table>
    <Dimension type="StandardDimension" visible="true" foreignKey="DEPTNO" highCardinality="false" name="Dim_dept" caption="&#37096;&#38376;&#32500;&#24230;">
      <Hierarchy visible="true" hasAll="true" primaryKey="DEPTNO">
        <Table name="DEPT" schema="SCOTT">
        </Table>
        <Level name="Level_deptno" visible="true" table="DEPT" column="DEPTNO" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never" caption="&#37096;&#38376;&#32534;&#21495;">
        </Level>
        <Level name="Level_deptname" visible="true" column="DNAME" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never" caption="&#37096;&#38376;&#21517;&#31216;">
        </Level>
        <Level name="Level_loc" visible="true" column="LOC" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never" caption="&#25152;&#22312;&#22320;&#21306;">
        </Level>
      </Hierarchy>
    </Dimension>
    <Measure name="SalAmount" column="SAL" aggregator="sum" caption="&#24037;&#36164;&#24635;&#39069;" visible="true">
    </Measure>
    <Measure name="EmpQuantity" column="EMPNO" aggregator="count" caption="&#21592;&#24037;&#25968;&#37327;" visible="true">
    </Measure>
  </Cube>
</Schema>

在Saiku中查询展示结果


下面再搭建一个典型的测试用例:

1、数据库表准备

创建表空间
create tablespace sales_tbs datafile 'd:\oradata\mes\sales_tbs01.dbf' size 100m;

创建用户并授权
create user sales identified by sales default tablespace sales_tbs;
grant connect, resource to sales;
alter user sales quota unlimited on sales_tbs;

创建表,插入测试数据

/**产品类别表*/
create table protype(protype_id number, protype_name varchar(32));
alter table protype add constraint pk_protype primary key(protype_id);
insert into protype values(1, '硬件');
insert into protype values(2, '软件');
insert into protype values(3, '服务');
commit;

/**产品表*/
create table product(pro_id number, protype_id number, pro_name varchar(32));
alter table product add constraint pk_product primary key(pro_id);
insert into product values(101, 1, '工控机');
insert into product values(102, 1, '条码打印机');
insert into product values(103, 1, '显示器');
insert into product values(201, 2, 'MES');
insert into product values(202, 2, 'LES');
insert into product values(203, 2, 'GoodMES');
insert into product values(204, 2, 'VEDI');
insert into product values(205, 2, 'Flexsite');
insert into product values(301, 3, '电话远程服务');
insert into product values(302, 3, '现场服务');
commit;

/**用户表*/
create table customer(cus_id number, cust_name varchar2(50), gender char(1));
alter table customer add constraint pk_customer primary key(cus_id);
insert into customer values(1001, '王某某', '1');
insert into customer values(1002, '张某某', '0');
insert into customer values(1003, '李某某', '1');
insert into customer values(1004, '赵某某', '1');
commit;

/**销售表*/
create table sale(sale_id number, pro_id number, cus_id number, unit_price number, quantity number);
alter table sale add constraint pk_sale primary key(sale_id);
insert into sale values(1, 101, 1001, 5000, 10);
insert into sale values(2, 202, 1003, 80000, 3);
insert into sale values(3, 204, 1003, 45000, 3);
insert into sale values(4, 102, 1004, 8000, 5);
insert into sale values(5, 201, 1001, 120000, 2);
insert into sale values(6, 205, 1001, 7000, 4);
insert into sale values(7, 301, 1002, 30000, 1);
insert into sale values(8, 302, 1002, 2000, 10);
insert into sale values(9, 101, 1004, 5000, 2);
insert into sale values(10, 103, 1004, 2000, 2);
insert into sale values(11, 201, 1002, 2000, 1);
commit;

2、在Schema Workbench中构建多维数据的立方体模型

模式文件如下(Schema Workbench的使用可参考另一篇文章):
<Schema name="sales">
  <Cube name="Cube_sales" visible="true" cache="true" enabled="true">
    <Table name="SALE" schema="SALES">
    </Table>
    <Dimension type="StandardDimension" visible="true" foreignKey="CUS_ID" highCardinality="false" name="Dim_Cust" caption="&#23458;&#25143;&#32500;&#24230;">
      <Hierarchy visible="true" hasAll="true" allMemberName="AllCustomer" allMemberCaption="&#25152;&#26377;&#23458;&#25143;" primaryKey="CUS_ID">
        <Table name="CUSTOMER" schema="SALES">
        </Table>
        <Level name="Level_Gender" visible="true" column="GENDER" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never" caption="&#23458;&#25143;&#24615;&#21035;">
        </Level>
        <Level name="Level_Name" visible="true" column="CUST_NAME" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never" caption="&#23458;&#25143;&#22995;&#21517;">
        </Level>
      </Hierarchy>
    </Dimension>
    <Dimension type="StandardDimension" visible="true" foreignKey="PRO_ID" highCardinality="false" name="Dim_Product" caption="&#20135;&#21697;&#32500;&#24230;">
      <Hierarchy visible="true" hasAll="true" allMemberName="AllProduct" allMemberCaption="&#25152;&#26377;&#20135;&#21697;" primaryKey="PRO_ID" primaryKeyTable="PRODUCT">
        <Join leftKey="PROTYPE_ID" rightKey="PROTYPE_ID">
          <Table name="PRODUCT" schema="SALES">
          </Table>
          <Table name="PROTYPE" schema="SALES">
          </Table>
        </Join>
        <Level name="Level_ProductName" visible="true" table="PRODUCT" column="PRO_ID" nameColumn="PRO_NAME" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never" caption="&#20135;&#21697;&#21517;&#31216;">
        </Level>
        <Level name="Level_ProductType" visible="true" table="PROTYPE" column="PROTYPE_ID" nameColumn="PROTYPE_NAME" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never" caption="&#20135;&#21697;&#31867;&#21035;">
        </Level>
      </Hierarchy>
    </Dimension>
    <Measure name="SaleQuantity" column="QUANTITY" datatype="Numeric" aggregator="sum" caption="&#38144;&#21806;&#25968;&#37327;" visible="true">
    </Measure>
    <Measure name="SaleAmount" datatype="Numeric" aggregator="sum" caption="&#38144;&#21806;&#24635;&#39069;" visible="true">
      <MeasureExpression>
        <SQL dialect="generic">
          <![CDATA[(UNIT_PRICE*QUANTITY)]]>
        </SQL>
      </MeasureExpression>
    </Measure>
    <CalculatedMember name="AvgPrice" formatString="&#65509;#,##0.00" caption="&#24179;&#22343;&#21333;&#20215;" formula="[Measures].SaleAmount/[Measures].SaleQuantity" dimension="Measures" visible="true">
    </CalculatedMember>
  </Cube>
</Schema>

3、Saiku中添加模式和数据源

进入管理控制台
http://localhost:8080


添加模式文件,注意模式名最好和Schema文件中的Schema name一致,上传成功后应提示Upload Successsful!

添加数据源

4、添加完成后注销并重新登陆,如果配置和数据库连接无误,在多维数据列表里就可以看到添加的新模型

选取指标和维度,可以看到数据分析结果

直方图展示

曲线图展示

热点图展示

 

posted on 2020-07-31 17:17  一天不进步,就是退步  阅读(357)  评论(0编辑  收藏  举报