前面文章 http://jianchen.iteye.com/blog/1108446 讲到如何清除biee的缓存
写道
在linux下了,没有界面的话,就只能用命令的方式了:
nqcmd -d tsa -u jianchen -pjianchen -s testCleanCache.sql
testCleanCache.sql该文件的内容如下:
call SAPurgeCacheByTable('tsamysql','tsa','','tsa_dim_hour')};--表示清除某一张表的缓存
nqcmd -d tsa -u jianchen -pjianchen -s testCleanCache.sql
testCleanCache.sql该文件的内容如下:
call SAPurgeCacheByTable('tsamysql','tsa','','tsa_dim_hour')};--表示清除某一张表的缓存
之前清除缓存,都是手动去改testCleanCache文件,这样处理起来比较麻烦,每次要用vi去编辑,要清除的表比较多的话,然后就要不断的复制粘贴。晚上写了个shell脚本,将其自动化一点。
主要思路是,将手动生成odbc调用的命令,由程序去动态生成保存到cmd.sql文件中去。同时支持参数指定,方便操作。
具体shell脚本如下:
if [ $# == 0 ]
then
echo "请指定更新缓存的参数,-a表示清除整个缓存,-t指定清除某张表,后面可以跟多张表名,以空格分隔,-s表示清除整个主题,详情请查看help"
exit 1
fi
cmd=''
if [ "$1" == "-a" ]
then
cmd="Call SAPurgeAllCache();"
echo $cmd > cmd.sql
elif [ "$1" == "-t" ]
then
if [ $# -eq 1 ]
then
echo "请指定需要清除缓存的物理表名"
exit 1
fi
while [ $# -gt 1 ]
do
shift
cmd=$cmd"call SAPurgeCacheByTable('tsamysql','tsa','','"$1"')};\n"
done
echo -e "$cmd" > cmd.sql
elif [ "$1" == "-s" ]
then
if [$# -gt 2 ]
then
echo "每次只能清除一个主题"
exit 1
fi
if [ "$2" == "refund" ]
then
echo "清除退款主题的所有事实表"
exit 0
elif [ "$2" == "phone" ]
then
echo "清除电话主题的所有事实表"
exit 0
else
echo "没有该主题,请检查拼写是否有误,目前支持的主题有refund,phone"
exit 1
fi
else
echo "请检查命令是否使用正确"
exit 1
fi
nqcmd -d tsa -u kunshuo -ptaobao -s cmd.sql
nqcmd -d tsa2 -u kunshuo -ptaobao -s cmd.sql
支持的命令如下:
1,sh cleanCache.sh -a #全部清除
2,sh cleanCache.sh -t tsa_fact_refudn tsa_fact_phone #清除两张表
3,sh cleanCache.sh -s refund #清除指定的主题,后面会实现,指定具体的退款主题的相关物理表
A result code is returned after you issue a purge cache command.
| Result Code | Result Message |
|---|---|
| 1 | SAPurgeCacheByDatabase returns successfully |
| 59115 | Operation not performed because caching is not enabled. |
| 59116 | The database specified does not exist |
| 59117 | The table specified does not exist |
| 85025 | The physical cube specified does not exist |

3546

被折叠的 条评论
为什么被折叠?



