SuperSet安装

安装Python环境

mkdir /opt/soft

curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

bash Miniconda3-latest-Linux-x86_64.sh

回车之后,一直按空格,提示Please answer 'yes' or 'no':' 输入yes。

指定安装路径/opt/soft/conda,回车默认

/opt/soft/conda

PREFIX=/opt/soft/conda

初始化conda3,输入yes

Do you wish the installer to initialize Miniconda3

[no] >>> yes

  1. 配置系统环境变量

vim /etc/profile

export CONDA_HOME=/opt/soft/conda

export PATH=PATH:CONDA_HOME/bin

source /etc/profile

source ~/.bashrc

可以发现前面多了(base),python版本是3.11

取消激活base环境

conda config --set auto_activate_base false

bash

查看conda版本

复制成功

conda --version

conda 24.3.0

配置conda国内镜像

复制成功

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

conda config --set show_channel_urls yes

conda config --show channels

7)创建python3.9环境

conda create --name superset python=3.9

y

8)激活superset环境

conda activate superset

若要退出环境使用以下命令:

conda deactivate

安装

1)安装准备依赖

复制成功

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

2)安装setuptools和pip

pip install --upgrade setuptools pip

3)安装supetest

pip install apache-superset --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple

4)初始化数据库

superset db upgrade

遇到密匙安全性弱的报错

pip show apache-superset

进入superset安装路径

生成paste_your_generated_secret_key_her

openssl rand -base64 42

vi superset_config.py

SECRET_KEY = 'paste_your_generated_secret_key_here'

SECRET_KEY = 'ocuiR5/s93tYYrIjuGhMFkWrM00tt7Kd3lt2tJ07rAnxgp+cg4jKFmHF'

vi /etc/profile

export SUPERSET_CONFIG_PATH=/opt/soft/conda/envs/superset/superset_config.py

source /etc/profile

5)创建管理员用户

export FLASK_APP=superset

superset fab create-admin

Username [admin]:

User first name [admin]:

User last name [user]:

Email [admin@fab.org]:

Password:

Repeat for confirmation:

Recognized Database Authentications.

root 12345678

6)Superset初始化

superset init

7)安装gunicorn

pip install gunicorn -i https://pypi.douban.com/simple/

8)启动superset

superset run -h linux122 -p 8080 --with-threads --reload --debugger

gunicorn --workers 5 --timeout 120 --bind [ip]:[port] "superset.app:create_app()" --daemon

若要停止superset使用以下命令:

ps -ef | awk '/superset/ && !/awk/{print $2}' | xargs kill -9

9)登录 Superset

linux122:8080

用户名:root

密码:12345678

访问 ip:[port],并使用前面创建的管理员账号进行登录。

连接数据库:

先安装环境:

conda activate superset

yum install python-devel -y

pip install gevent

sudo yum install groupinstall 'development tools'

yum install mysql-devel -y

yum install gcc -y

pip install mysqlclient

报错

  writing top-level names to src/mysqlclient.egg-info/top_level.txt
  reading manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  adding license file 'LICENSE'
  writing manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
  copying src/MySQLdb/_mysql.c -> build/lib.linux-x86_64-cpython-39/MySQLdb
  running build_ext
  building 'MySQLdb._mysql' extension
  creating build/temp.linux-x86_64-cpython-39/src/MySQLdb
  gcc -pthread -B /opt/soft/conda/envs/superset/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/soft/conda/envs/superset/include -fPIC -O2 -isystem /opt/soft/conda/envs/superset/include -fPIC "-Dversion_info=(2, 2, 4, 'final', 0)" -D__version__=2.2.4 -I/opt/soft/conda/envs/superset/include/python3.9 -c src/MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-39/src/MySQLdb/_mysql.o -I/usr/include/mysql -std=c99
  src/MySQLdb/_mysql.c: 在函数'_mysql_ConnectionObject_Initialize'中:
  src/MySQLdb/_mysql.c:539:44: 错误:'MYSQL_OPT_SSL_KEY'未声明(在此函数内第一次使用)
           mysql_options(&(self->connection), MYSQL_OPT_SSL_KEY, key);
                                              ^
  src/MySQLdb/_mysql.c:539:44: 附注:每个未声明的标识符在其出现的函数内只报告一次
  src/MySQLdb/_mysql.c:540:44: 错误:'MYSQL_OPT_SSL_CERT'未声明(在此函数内第一次使用)
           mysql_options(&(self->connection), MYSQL_OPT_SSL_CERT, cert);
                                              ^
  src/MySQLdb/_mysql.c:541:44: 错误:'MYSQL_OPT_SSL_CA'未声明(在此函数内第一次使用)
           mysql_options(&(self->connection), MYSQL_OPT_SSL_CA, ca);
                                              ^
  src/MySQLdb/_mysql.c:542:44: 错误:'MYSQL_OPT_SSL_CAPATH'未声明(在此函数内第一次使用)
           mysql_options(&(self->connection), MYSQL_OPT_SSL_CAPATH, capath);
                                              ^
  src/MySQLdb/_mysql.c:543:44: 错误:'MYSQL_OPT_SSL_CIPHER'未声明(在此函数内第一次使用)
           mysql_options(&(self->connection), MYSQL_OPT_SSL_CIPHER, cipher);
                                              ^
  src/MySQLdb/_mysql.c:556:13: 警告:隐式声明函数'mysql_optionsv' [-Wimplicit-function-declaration]
               mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);
               ^
  src/MySQLdb/_mysql.c:556:49: 错误:'MYSQL_OPT_SSL_ENFORCE'未声明(在此函数内第一次使用)
               mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);
                                                   ^
  error: command '/usr/bin/gcc' failed with exit code 1
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

ERROR: Failed building wheel for mysqlclient

Failed to build mysqlclient

ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (mysqlclient)

解决

pip install mysqlclient==1.4.4

成功,在superSet可视化界面直接连接即可