0%

TablueaServer安装与体验

Tableau是市场上一个比较受欢迎的BI工具产品,传播比较广的是Tableau Desktop桌面软件,用户常常会将其与微软的Excel做对比,作为一个数据平台开发者,我认为Tabluea与Excel完全不是一个类型的产品,这种区别在企业的数据自动化处理环境中,得到明显的放大,Tableau的优势被突出的展现出来。我倾向于认为Tableau生成的是一个作用于数据模型生成可视化报表的操作脚本,数据与脚本彼此独立,数据模型是彼此关联的依据,基于这种分离,Tableau可以对数据源和可视化进行独立扩展,因此Tableau可以支持40余(开发人员可以基于其接口进行扩展)种数据源,支持实时及预抽取两种模式的数据获取,支持如Excel那样形式多样的报表,支持对数据的各种数据分析模型及机器学习分析。Tableau Desktop用户经常会将其编辑内容和数据对外进行展示共享,共享的方式可能会以工作文件的方式通过物理存储相互传播,在云存储时代,显得很低效,且数据本身再也无法得到保护,用户可能会通过Tableau Online进行工作内容托管、分享及数据分发权限控制。那么,如果涉及机密数据,或者数据来自于内网呢?
Tableau Server是一个类似于Tableau Online的本地托管中心服务,由于部署于内网,数据在内网墙内可自由共享,前提是有必要的权限。此文将对部署这样一个具有域内服务能力的组件进行过程介绍。

环境及版本

硬件要求:

  • 最低8核CPU,主频不低于2.0GHz,64位宽
  • 最低32GB内存
  • 最低50GB空闲磁盘

安装环境:

  • Ubuntu 16.04.04 tls (不同版本的Tableau Server有不同的最低系统版本要求)

安装版本:

  • Tableau Server 10.5.1 (Tableau Server最好与Tableau Desktop具有相同版本,否则保存内容会根据工作环境进行版本降级)
  • 下载连接

安装过程

软件安装

需要注意,软件安装必须由具有root权限的用户进行,但不得直接使用root用户直接安装。

1
2
3
sudo apt-get update
sudo apt-get -y install gdebi-core
sudo gdebi -n tableau-server-10-5-1_amd64.deb

启动TSM (Tableau Service Manager)

1
2
3
4
5
cd /opt/tableau/tableau_server/packages/scripts.10500.18.0210.2209/
sudo ./initialize-tsm --accepteula
// The TSM administrative REST API endpoint is available on 8850
// 同时下载Tablueau server协议到 /opt/tableau/tableau_server/packages/docs.10500.18.0210.2209/Commercial_EULA.txt
// TSM将使用/var/opt/tableau/tableau_server作为工作目录。

默认情况下,会创建tabluea、tabadmin用户组及tableau用户,同时会将当前用户添加到tabadmin组,tabadmin用户组用户用于登陆tsm进行tableau server的管理。
注销命令行,重新登入,以使Tableau环境生效(或者,调用 $ source /etc/profile.d/tableau_server.sh 使配置生效)。

激活Tableau Server

如Tableau Desktop也需要激活,这里以试用license为例,过程类似。

1
2
3
4
5
6
7
// 使用tsmadmin组用户登陆tsm,用于激活Tableau Server,通过 $ grep tsmadmin /etc/group 查看所有tsmadmin用户。
tsm login -u test
// 激活Tableau Server
tsm licenses activate -k <KEY> // 这里使用试用许可 $ tsm licenses activate -t
// Trial activated.
// 注册Tableau Server
tsm register --template > registration_file.json // 生成注册模版

编辑模版

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"zip" : "10000",
"country" : "China",
"city" : "Shenzhen",
"last_name" : "xxxx",
"industry" : "Internet",
"eula" : "yes",
"title" : "Software Engineer",
"phone" : "xxxxxxxx",
"company" : "Sp",
"state" : "NH",
"department" : "Engineering",
"first_name" : "jeff",
"email" : "xxxx@xxx.com"
}

注册

1
2
tsm register --file registration_file.json
// Registration complete.

关于Tableau Server激活

Tableau Server提供在线激活及离线激活两种方式,在线激活需要使用购买许可证的账户在Tableau Customer Account Center中获取产品密钥。同时,也可以使用离线激活,相关过程参考Activate Tableau Server Offline
如果需要对许可的范围进行扩展,以支持更多用户,可以参考Add Capacity to Tableau Server

启动Tableau Server

配置防火墙并打开Tableau Server服务端口(跳过)

用户鉴权配置

可以使用用户LDAP鉴权或者本地鉴权,公司环境中一般使用LDAP鉴权来与公司现有系统进行整合,这里使用本地鉴权,由Tableau Server提供用户注册管理功能。

1
2
3
4
5
6
7
8
9
10
// 生成鉴权配置
// local_file.json
{
"configEntities":{
"identityStore": {
"_type": "identityStoreType",
"type": "local"
}
}
}

其他配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// local_file.json
{
"configEntities": {
"gatewaySettings": {
"_type": "gatewaySettingsType",
"port":5267, // 80端口被占用,按照文档说明,可以通过 tsm configuration set -k gateway.public.port -v 5267 更改,实际操作发现,并未生效
"firewallOpeningEnabled": true,
"sslRedirectEnabled": true,
"publicHost": "<host|ip>", // server的端口是绑定到ip的
"publicPort":5267
},
"identityStore": {
"_type": "identityStoreType",
"type": "local"
}
},
"configKeys": {
"gateway.timeout": "900"
}
}
tsm settings import -f local_file.json

启动

1
2
3
4
5
6
7
// 使配置生效
tsm pending-changes apply
// 初始化,并启动Server
tsm initialize --start-server --request-timeout 1800
// --start-server用于启动Server,当使用此参数时,可使用 $ tsm start 启动服务器。
// 当需要更改Tablueau server配置,需要使用 $ tsm pending-changes apply|discard|list
// 当Server启动失败时,可查阅~/.tableau/tsm/tsm.log,查看详细日志。

成功输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Initializing the server...
3% - Validating that there are no pending changes.
6% - Generating passwords.
10% - Generating search server ssl certificate.
13% - Promoting configuration.
17% - Initializing the topology.
20% - Checking if required database services are present.
24% - Disabling database services.
27% - Installing the maintenance app.
31% - Connecting to the database maintenance app at host: 'localhost', port: '8623'.
34% - Initializing the temporary database instance.
37% - Starting the temporary database instance.
41% - Creating roles and databases.
44% - Running migrations.
48% - Localizing the default projects.
51% - Stopping the temporary database instance.
55% - Making the temporary database default.
58% - Enabling the database services.
62% - Removing the database maintenance app.
65% - Generating new asset key.
68% - Saving asset key.
72% - Finalizing the topology.
75% - Reconfiguring services.
79% - Waiting for services to reconfigure and start.
82% - Initializing the next active repository.
86% - Enabling the services required for indexing.
89% - Rebuilding the search index.
93% - Finalizing the initialization.
96% - Enabling all services.
100% - Waiting for the services to start.

Server was initialized successfully.

添加administrative账户

1
2
3
// 初始化administrative账户
tabcmd initialuser --server 'localhost:5267' --username 'admin' --password 'admin123'
// 这里在初始化用户完成前,绑定到的ip无法访问的,必须通过localhost进行用户初始化。

一些故障问题

Permission denied类问题

在执行过程中,产生Permission denied相关输出,一般为命令的执行权限问题,Tableau Server启动过程中的所有命令都需要root组用户权限(但是为了安全,Tableau Server不允许root用户直接操作相关命令)。

执行Tableau Server启动命令失败

1
2
3
4
tsm initialize --start-server --request-timeout 1800
Initializing the server...
3% - You must apply or discard any pending changes before this operation.
Server initialization was unsuccessful.

tsm在启动Server时会检查配置信息,如果配置未写入,拒绝配置生效并停止启动或重启Server,应使用$ tsm pending-changes apply 或 $ tsm pending-changes discard 写入配置或丢弃未写入配置。

Tableau Server卸载

1
sudo /opt/tableau/tableau_server/packages/scripts.10500.18.0210.2209/tableau-server-obliterate -y -y -y -l

Tableau Server扩展

TabPy

TabPy是Tableau Server扩展部分,可以为Tableau Server提供一个在线的python执行环境,用于数据和参数的处理。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
git clone https://github.com/tableau/TabPy.git
chmod +x setup.sh
// 安装启动
./setup.sh
// tabpy_server/common/config.py.template文件中包含tabpy的默认配置,可以将此文件拷贝到同级目录下的config.py中进行编辑,以修改配置。
// 更改Tableau Server的ExtraService Connection配置
tsm configuration set -k vizqlserver.extsvc.host -v 10.12.77.109
tsm configuration set -k vizqlserver.extsvc.port -v 9004
tsm pending-changes apply
// 如果需要在python环境中添加新的组件
source ~/anaconda/bin/activate Tableau-Python-Server
pip install _names_of_packages_here_
// 甚至可以启动ipython notebook,从网页上提交代码
ipython notebook --ip=10.12.77.109

Building advanced analytics applications with TabPy

扩展数据连接

通过Web Data Connector(WDC),TableauServer可读取任何JSON、XML或者XHTML格式的数据,因此理论上,可以将TableauServer的数据源扩展到所有可访问的数据中。
WDC文档

Tableau VS Excel?

在报表表现力上,Tableau并不优于Excel,不过Excel的数据与报表是联系紧密的,倾向于处理一次性数据,常规工作流程是将数据导出为表,在表上进行报表操作,而Tableau是数据与报表分离的,是基于数据模型进行报表构建的,只要数据满足数据模型,即可在上面套用报表,在企业数据流中,可定期或实时的将数据自动输出为报表。