工具Scriptis的安装部署
1. 介绍
在Linkis1.0和DSS 1.1.X之后,支持将Scritpis单独部署来集成Linkis,使用Scriptis的交互式分析的功能,可以在web 页面在线写SQL、Pyspark、HiveQL等脚本,提交给Linkis执行且支持UDF、函数、资源管控和自定义变量等特性,本文将介绍如何单独部署Web组件-Scriptis,并通过Scriptis这种Web页面来使用Linkis。
前提:已经成功安装并可以正常使用了linkis服务(后端和管理台服务),linkis的部署流程可以见Linkis的快速部署
示例说明:
- linkis-gateway服务的地址为10.10.10.10 端口为9001
- linkis的管理台nginx部署在10.10.10.10 端口为8080
2.环境准备
首次使用需要
2.1 安装node.js
1. 将node.js下载,安装即可。下载地址:http://nodejs.cn/download/ (建议使用最新的稳定版本) 该步骤仅第一次使用时需要执行
2.2 安装learn
1. #等待安装完即可,安装liarn仅第一次使用时需要执行
2. npm install lerna -g
3 编译部署
3.1 获取scriptis代码
Scriptis是一个纯前端的项目,作为一个组件集成在DSS的web代码组件中,我们只需要将DSS web项目进行单独的scriptis模块编译
1. #通过git下载 dss 1.1.0官方版本发布前,建议先使用这个分支dev-1.1.4分支,来编译scriptis组件
2. git clone -b dev-1.1.4 https://github.com/WeDataSphere/DataSphereStudio
3. # 或则直接下载zip包 后解压
4. https://codeload.github.com/WeDataSphere/DataSphereStudio/zip/refs/heads/dev-1.1.4
7. #进入web目录
8. cd DataSphereStudio/web
11. #添加依赖 注意:这里不是通过npm install 而是lerna bootstrap 需先安装 learn 该步骤仅第一次使用时需要执行
12. lerna bootstrap
3.2 本地运行项目(可选)
如果不想本地运行查看,可以跳过此步
3.2.1 配置linkis-gateway服务地址配置
如果是在本地启动服务,需要在代码中配置后端linkis-gateway服务地址,在web/packages/dss/目录下的.env文件, 打包部署时不需要进行配置
1. // 后端linkis-gatway服务地址
2. VUE_APP_HOST=http://10.10.10.10:9001
3. VUE_APP_MN_CONFIG_PREFIX=http://10.10.10.10:9001/api/rest_j/v1
3.2.2 运行scriptis模块
1. cd DataSphereStudio/web
2. # 运行scriptis组件
3. npm run serve --module=scriptis
打开浏览器,通过链接http://localhost:8080(本地请求默认端口是8080)访问应用scriptis ,因为会请求到远端的linkis-gatway服务接口,这会存在跨域问题,chrome浏览器解决跨域问题可参考解决Chrome跨域问题
4 打包&部署 scriptis
4.1 打包
1. #指定scriptis模块
2. cd DataSphereStudio/web
5. #该指令成功执行后,web目录下会出现一个名叫 `dist` 的文件夹,该文件夹即为打包好scriptis的组件资源代码。我们需要将该前端资源部署到linkis-web所在的nginx服务器上
6. npm run build --module=scriptis
4.2 部署
将 3.1编译出来的静态资源 上传至 linkis 管理台所在的服务器上,存放于/data/Install/scriptis-web/dist/, 在安装 linkis 管理台的nginx服务器配置中,添加 scriptis 的静态资源访问规则,linkis 管理台部署的 nginx 配置一般位于 /etc/nginx/conf.d/linkis.conf
1. location /scriptis {
2. alias /data/Install/scriptis-web/dist/ ;
3. index index.html ;
4. }
sudo vim /etc/nginx/conf.d/linkis.conf
1. server {
2. listen 8080;# 访问端口
3. server_name localhost;
4. #charset koi8-r;
5. #access_log /var/log/nginx/host.access.log main;
8. location / {
9. root /appcom/Install/linkis-web/dist/; # 静态文件目录
10. index index.html;
11. }
14. location /scriptis { #scriptis的资源带有scriptis前缀与linkis 管理台区分开
15. alias /data/Install/scriptis-web/dist/ ; #nginx scriptis静态文件存放路径(可自定义)
16. index index.html ;
17. }
20. .......
23. location /api {
24. proxy_pass http://10.10.10.10:9001; #gatway的地址
25. proxy_set_header Host $host;
26. proxy_set_header X-Real-IP $remote_addr;
27. proxy_set_header x_real_ipP $remote_addr;
28. proxy_set_header remote_addr $remote_addr;
29. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
30. proxy_http_version 1.1;
31. proxy_connect_timeout 4s;
32. proxy_read_timeout 600s;
33. proxy_send_timeout 12s;
34. proxy_set_header Upgrade $http_upgrade;
35. proxy_set_header Connection upgrade;
36. }
39. #error_page 404 /404.html;
40. # redirect server error pages to the static page /50x.html
41. #
42. error_page 500 502 503 504 /50x.html;
43. location = /50x.html {
44. root /usr/share/nginx/html;
45. }
46. }
修改配置后 ,重新加载nginx配置
1. sudo nginx -s reload
注意nginx中,root和alias区别
- root的处理结果是:root路径+location路径.
- alias的处理结果是:使用alias路径替换location路径.
- alias是一个目录别名的定义,root则是最上层目录的定义
5 scriptis 使用步骤
5.1 正常登录linkis管理台
1. #http://10.10.10.10:8080/#/
2. http://nginxIp:port/#/
因scriptis需要进行登录验证所以需要先进行登录,拿到cookie。
5.2 登录成功后 访问 scriptis 页面
1. #http://10.10.10.10:8080/scriptis/#/home
2. http://nginxIp:port/scriptis/#/home
nginxIp:nginx服务器ip,port:linkis管理台nginx配置启动的端口号,scriptis为请求scriptis项目静态文件nginx配置的location 地址(可自定义设置)
4.3 使用 scriptis
以新建一个sql查询任务为例。
step1 新建脚本 选择脚本类型为sql类型

step2 输入要查询的语句

step3 运行

shep4 查看结果

