Saiku缓存处理(七)

Saiku缓存处理方案

Saiku默认是从缓存中读取数据的(如果缓存中有数据的话),所以用户看到的数据不一定是最新的,如果需要看到最新的的数据需要手动刷新数据或者更改配置信息。

Saiku获取实时数据的方案有以下三种。

>>>获取saiku实时数据方案一:通过admin点击刷新按钮刷新缓存

以管理员 admin的身份登录saiku,点击新建查询进入页面后会看到一个刷新按钮,点击这个按钮就能刷新缓存了。(这种方案不推荐,因为会比较麻烦,每次都用管理员去登录系统操作。)

>>>获取saiku实时数据方案二:通过更改配置文件mondrian.properties不使用缓存

修改配置文件 mondrian.properties  (文件路径:saiku-server\tomcat\webapps\saiku\WEB-INF\classes\mondrian.properties )

将注释打开,并修改 mondrian.rolap.star.disableCaching的值为true,表示不使用缓存(这种方案不推荐,因为数据量大的时候会导致saiku使用性能没那么好。)

###############################################################################
# Boolean property that controls whether a RolapStar's
# aggregate data cache is cleared after each query.
# If true, no RolapStar will cache aggregate data from one
# query to the next (the cache is cleared after each query).
#
#mondrian.rolap.star.disableCaching=false  

修改之后的mondrian.properties关于缓存的配置

###############################################################################
# Boolean property that controls whether a RolapStar's
# aggregate data cache is cleared after each query.
# If true, no RolapStar will cache aggregate data from one
# query to the next (the cache is cleared after each query).
#
mondrian.rolap.star.disableCaching=true

  

>>> 获取saiku实时数据方案三:通过编写脚本指定saiku刷新缓存

定时手动刷新saiku缓存信息,也就是通过编写脚本让saiku在指定时间执行刷新(这个脚本的来源 主要参考方案一点击刷新时发送的请求) (推荐使用)

建议可以在数据库中数据有变化是时,执行此脚本(例如在[ETL]抽完数之后执行)

新建脚本内容如下:  saiku_refresh.sh

#!/bin/bash

curl -c ./cookie.txt -d "language=zh&password=admin&username=admin" http://10.6.70.78:8080/saiku/rest/saiku/session
curl -b ./cookie.txt "http://10.6.70.78:8080/saiku/rest/saiku/admin/discover/refresh"      

其中  10.6.70.78:8080  #是我安装的saiku的访问地址

curl -c ./cookie.txt -d "language=zh&password=admin&username=admin"  http://10.6.70.78:8080/saiku/rest/saiku/session   #获取cookies信息,没有指定saiku可以无密码登录的时候需要执行password与username

curl -b ./cookie.txt "http://10.6.70.78:8080/saiku/rest/saiku/admin/discover/refresh"    #这是主要的执行刷新操作的语句啦

最后通过 sh saiku_refresh.sh  执行此脚本,便能实现刷新换缓存中的数据啦!!!

猜你喜欢

转载自www.cnblogs.com/DFX339/p/10417790.html