首页 > 其他分享 >Apache Superset 安装

Apache Superset 安装

时间:2024-05-24 18:11:17浏览次数:23  
标签:Superset name py AUTH flag LDAP Apache superset 安装

Apache Superset 安装

一、版本选择

软件名称 版本
Anaconda3 Anaconda3-5.3.0-Linux-x86_64.sh
Python python3.9
Superset 2.1.1

二、软件安装

Anaconda3

# 下载链接:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh

Python

conda create -n superset_env python==3.9

Superset

(1)安装依赖
# CentOS7

yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel python-setuptools openssl-devel cyrus-sasl-devel openldap-devel

(2)第一步:切换 superset_env 环境
[root@master bin]$ pwd
/opt/anaconda3/bin
[root@master bin]$
(base) [root@master bin]# source activate superset
(superset) [root@master bin]#
(superset) [root@master bin]# python -V
Python 3.9.0
(3)第二步:安装 superset包
pip install apache-superset==2.1.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/
(4)第三步:安装|替换一些 python包
pip install Werkzeug==2.0.3
pip install typing_extensions==4.2.0
pip install pymysql
pip install Flask-LDAP
pip install marshmallow_enum
pip install pillow
pip install gunicorn
(5)创建配置文件
vim /opt/anaconda3/superset_config.py
from flask_appbuilder.security.manager import AUTH_DB, AUTH_LDAP

# 此参数必须设置,通过命令:【openssl rand -base64 42 】 获取
SECRET_KEY = 'NcTVZLnTIm0lVTYYIG17F41T66D+eShZTfNS2C9bLht2Fnyia2aMwuWZ'

# 默认数据是存在 sqlite里面,正式环境需要存在 mysql 里面,在这里配置
SQLALCHEMY_DATABASE_URI = 'mysql://superset:[email protected]/superset'


# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = False
# Add endpoints that need to be exempt from CSRF protection
WTF_CSRF_EXEMPT_LIST = []
# A CSRF token that expires in 1 year
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365

# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = ''

# 这里配置页面菜单设置为中文
BABEL_DEFAULT_LOCALE = "zh"
# Your application default translation path
BABEL_DEFAULT_FOLDER = "superset/translations"
# The allowed translation for you app
LANGUAGES = {
    "en": {"flag": "us", "name": "English"},
    "es": {"flag": "es", "name": "Spanish"},
    "it": {"flag": "it", "name": "Italian"},
    "fr": {"flag": "fr", "name": "French"},
    "zh": {"flag": "cn", "name": "Chinese"},
    "ja": {"flag": "jp", "name": "Japanese"},
    "de": {"flag": "de", "name": "German"},
    "pt": {"flag": "pt", "name": "Portuguese"},
    "pt_BR": {"flag": "br", "name": "Brazilian Portuguese"},
    "ru": {"flag": "ru", "name": "Russian"},
    "ko": {"flag": "kr", "name": "Korean"},
    "sk": {"flag": "sk", "name": "Slovak"},
    "sl": {"flag": "si", "name": "Slovenian"},
    "nl": {"flag": "nl", "name": "Dutch"},
}
# Turning off i18n by default as translation in most languages are
# incomplete and not well maintained.


# Uncomment to setup Your App name
APP_NAME = "Superset"

# 这里自定义logo图标
# Specify the App icon
APP_ICON = "/static/assets/images/superset-logo-horiz_yszx.png"



# ----------------------------------------------------
# AUTHENTICATION CONFIG
# ----------------------------------------------------
# The authentication type
# AUTH_OID : Is for OpenID
# AUTH_DB : Is for database (username/password)
# AUTH_LDAP : Is for LDAP
# AUTH_REMOTE_USER : Is for using REMOTE_USER from web server
AUTH_TYPE = AUTH_LDAP

# Uncomment to setup Full admin role name
AUTH_ROLE_ADMIN = "Admin"

# Uncomment to setup Public role name, no authentication needed
AUTH_ROLE_PUBLIC = 'Public'

# Will allow user self registration
AUTH_USER_REGISTRATION = True

# The default user self registration role
AUTH_USER_REGISTRATION_ROLE = "Gamma"

# 接入ldap, 这里需要运维配合,提供这些参数
# When using LDAP Auth, setup the LDAP server
AUTH_LDAP_SERVER = "ldap://172.16.204.**:389"
AUTH_LDAP_BIND_USER = "uid=yunwei,ou=People,dc=elements,dc=org,dc=cn"
AUTH_LDAP_BIND_PASSWORD = "****"
AUTH_LDAP_SEARCH = "dc=elements,dc=org,dc=cn"
AUTH_LDAP_UID_FIELD="cn"
AUTH_LDAP_FIRSTNAME_FIELD="givenName"
AUTH_LDAP_LASTTNAME_FIELD="sn"
AUTH_LDAP_USE_TLS = False

# 配置,可以减少一些警告输出
CONTENT_SECURITY_POLICY_WARNING=False
(6)修改文件 sql_parse.py
vim /opt/anaconda3/envs/superset/lib/python3.9/site-packages/superset/sql_parse.py
# 注释掉67行,新增68行

 64 sqlparse.keywords.SQL_REGEX.insert(
 65     0,
 66     (
 67         # re.compile(r"'(''|\\\\|\\|[^'])*'", sqlparse.keywords.FLAGS).match,
 68         re.compile(r"'(''|\\\\\\\\\\\\\\\\|\\\\\\\\|[^'])*'", (re.IGNORECASE | re.UNICODE)).match,
 69         sqlparse.tokens.String.Single,
 70     ),
 71 )
 72
(7)修改文件 mysql.py
vim /opt/anaconda3/envs/superset/lib/python3.9/site-packages/superset/db_engine_specs/mysql.py
# 修改 218 行 MySQLdb 为 pymysql
# 修改 220 行 MySQLdb 为 pymysql

213     @classmethod
214     def get_datatype(cls, type_code: Any) -> Optional[str]:
215         if not cls.type_code_map:
216             # only import and store if needed at least once
217             # pylint: disable=import-outside-toplevel
218             import pymysql	# import MySQLdb          
219
220             ft = pymysql.constants.FIELD_TYPE # ft = MySQLdb.constants.FIELD_TYPE
221             cls.type_code_map = {
222                 getattr(ft, k): k for k in dir(ft) if not k.startswith("_")
223             }
224         datatype = type_code
225         if isinstance(type_code, int):
226             datatype = cls.type_code_map.get(type_code)
227         if datatype and isinstance(datatype, str) and datatype:
228             return datatype
229         return None
(8)修改文件 sql_lab.py
vim /opt/anaconda3/envs/superset/lib/python3.9/site-packages/superset/sql_lab.py
# 修改 363 行: 注释掉363行
# 修改 364 行: 如下

348 def _serialize_and_expand_data(
349     result_set: SupersetResultSet,
350     db_engine_spec: BaseEngineSpec,
351     use_msgpack: Optional[bool] = False,
352     expand_data: bool = False,
353 ) -> Tuple[Union[bytes, str], List[Any], List[Any], List[Any]]:
354     selected_columns = result_set.columns
355     all_columns: List[Any]
356     expanded_columns: List[Any]
357
358     if use_msgpack:
359         with stats_timing(
360             "sqllab.query.results_backend_pa_serialization", stats_logger
361         ):
362             data = (
363                 #pa.default_serialization_context()
364                 pa.serialize(result_set.pa_table)
365                 .to_buffer()
366                 .to_pybytes()
367             )
(9)修改文件 mysqldb.py
vim /opt/anaconda3/envs/superset/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/mysqldb.py
# 修改 150 行 MySQLdb 改为 pymysql

148     @classmethod
149     def dbapi(cls):
150         return __import__("pymysql")   # return __import__("MySQLdb")
(10)修改文件 lexer.py
vim /opt/anaconda3/envs/superset/lib/python3.9/site-packages/sqlparse/lexer.py
 # 修改 79行 rx 改为 str(rx)
  
 75     def set_SQL_REGEX(self, SQL_REGEX):
 76         """Set the list of regex that will parse the SQL."""
 77         FLAGS = re.IGNORECASE | re.UNICODE
 78         self._SQL_REGEX = [
 79             (re.compile(str(rx), FLAGS).match, tt)
 80             for rx, tt in SQL_REGEX
 81         ]
(11)设置环境变量
export PYTHONPATH="/opt/anaconda3/superset_config.py:$PYTHONPATH"

export FLASK_APP=superset
(12)生成mysql数据表
superset db upgrade
(13)创建管理员用户
superset fab create-admin
(14)初始化 Superset
superset init
(15)启动 Superset
gunicorn --workers 5 --timeout 120 --bind ip:8787  "superset.app:create_app()" --daemon
(16)浏览器登录
http://ip:8787/

标签:Superset,name,py,AUTH,flag,LDAP,Apache,superset,安装
From: https://www.cnblogs.com/yzyang/p/18211460

相关文章

  • Apache DorisDB 线上部署
    ApacheDorisDB线上部署一、机器资源(初始)机器IPHostname内存CPU磁盘172.16.203.151dorisdb203-15116g4核500G172.16.203.152dorisdb203-15216g4核500G172.16.203.153dorisdb203-15316g4核500G二、角色分配机器IP角色172.16.203.15......
  • Griffin编译安装
    ApacheGriffin编译安装1.环境准备Maven(ApacheMaven3.6.3)Mysql数据库(可以是PostgreSQL,mysql版本5.7)npm(版本6.14.6)(version6.0.0+,用于编译ui模块)(推荐此版本)Scala(版本2.11.8)Hadoop(版本3.0.0或更高版本)(本地:2.6.0)Hive(版本2.1.1)(本地:1.1.0......
  • 安装 Windows Server 2022
    将WindowsServer安装介质插入计算机的光盘驱动器,然后重新启动计算机,然后,显示以下屏幕,继续点击【下一步】按钮。单击【立即安装】开始安装。选择要安装的WindowsServer版本。在此示例中,使用【DatacenterwithGraphical***】版本进行处理。仔细阅读许可条款并选中一个框......
  • 升级openssh前安装zlib报异常configure aborting
    事情是这样的,因为系统漏洞问题,需要升级openssh,从OpenSSH_9.3p1升级到OpenSSH_9.3p2系统版本:CentOS7升级OpenSSH_9.3p2之前需要先升级zlib从官网下载wgethttps://www.zlib.net/zlib-1.3.1.tar.gz解压tar-zxvfzlib-1.3.1.tar.gzcdzlib-1.3.1./configure--prefix=/u......
  • centos7安装weblogic14
    Centos7安装weblogic 1、配置java环境weblogic运行依赖java环境,所以第一步先配置java环境上传、解压jdk安装包[root@bogon~]#rz-be[root@bogon~]#tar-zxvfjdk1.8.tar.gz配置java环境变量[root@bogon~]#vim/etc/profile exportJAVA_HOME=/opt/jdk1.8 exportCLASSPA......
  • Docker安装Portainer(docker容器管理工具)
    1.拉取镜像dockerpullportainer/portainer-ce:latest2. 启动portainer(默认端口9000)dockerrun-d\--nameportainer\-p9000:9000\--restart=always\-v/var/run/docker.sock:/var/run/docker.sock\-vportainer_data:/data\--privileged=true\portaine......
  • 【K8s】专题八:Kubernetes 安装方法之 RKE
    以下内容均来自个人笔记并重新梳理,如有错误欢迎指正!如果对您有帮助,烦请点赞、关注、转发!欢迎扫码关注个人公众号!一、RKE简介RKE即 RancherKubernetesEngine,是由Rancher发布的一个极其简单、快速的Kubernetes安装程序,简化了Kubernetes集群的部署过程。RKE经过......
  • zabbix - [03] 安装部署
    题记部分 一、准备工作1.1、服务器角色规划主机名IP地址角色备注ctos79-01192.168.2.121zabbix-server开启监控功能ctos79-02192.168.2.122zabbix-agent ctos79-03192.168.2.133zabbix-agent 1.2、关闭防火墙和SELinuxsetenforce0sed-i......
  • nodejs安装及环境配置
    Node.js的安装及环境配置可以遵循以下步骤:一、Node.js的安装访问Node.js的官方网站(https://nodejs.org/en/),下载对应你操作系统的Node.js安装包。找到下载的安装包目录,双击进行安装。在安装过程中,接受用户协议,选择安装的位置(最好是英文路径,不要有空格)。选择安装项,一般选择......
  • VMware下载安装使用
    LVM磁盘扩缩容技术下载各版本软件下载直链以及密钥参考:https://www.xitmi.com/2417.html点击运行后开始安装添加许可证完成安装点击图标启动网络配置配置VMware虚拟网络编辑器(编辑->虚拟网络编辑器)修改完成后点击确定->确定打开网络......