SuperSet安裝

惊世智慧發表於2024-10-19

安裝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視覺化介面直接連線即可

相關文章