Contents

基于python

虚拟环境(其实还是有对操作系统so包之类的依赖)
export LD_LIBRARY_PATH=”/data/soft/miniconda3/envs/superset/lib/libstdc++.so.6”

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
33
install_path=~/miniconda3
mkdir -p ${install_path}
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ${install_path}/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ${install_path}
rm -rf ${install_path}/miniconda.sh

# 自动配置环境
${install_path}/bin/conda init bash
conda config --set auto_activate_base false
# 或者手动修改 `/home/manhua/.bashrc`
eval "$(/data/soft/miniconda3/bin/conda shell.bash hook)"
或直接执行 source /data/soft/miniconda3/bin/activate

# 打开新的窗口 或执行bash
conda create -n superset --copy python=3.10
conda activate superset
python -m site --help #禁用user_site,以免安装在.local
conda deactivate
conda env remove -n superset

#迁移(可避免首行bad interpreter问题)
##源机器
conda activate superset
pip install conda-pack
conda-pack
##目标机器
mkdir superset
tar -xzf superset.tar.gz -C superset
source superset/bin/activate
conda-unpack
source superset/bin/deactivate


1
2
3
4
5
6
7
8
#python2使用虚拟环境
pip install virtualenv
#安装指定python虚拟环境,需本机已有
virtualenv --python=python3.10 superset

# python3使用虚拟环境. 迁移修改 bin/activate 里的VIRTUAL_ENV
python3 -m venv --copies superset
. superset/bin/activate
1
2
3
4
5
ROW_LIMIT = 5000
# openssl rand -base64 42
SECRET_KEY = "xxx"

SQLALCHEMY_DATABASE_URI = "" #默认sqlite
1
2
3
4
5
6
7
8
9
10
yum install cyrus-sasl-devel

pip install apache-superset pillow gunicorn pyhive[hive] sqlalchemy clickhouse-connect

export FLASK_APP=superset
# 自定义覆盖lib/python3.10/site-packages/superset/config.py的参数
export SUPERSET_CONFIG_PATH=/data/soft/miniconda3/envs/superset/superset_config.py
# 该项设为环境变量,影响后续初始化元数据目录
export SUPERSET_HOME="/data/soft/miniconda3/envs/superset"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

# `export SUPERSET_SECRET_KEY="oh-so-secret"`
superset db upgrade

# Create an admin user in your metadata database (use `admin` as username to be able to load the examples)
superset fab create-admin

# Load some data to play with
superset load_examples

# Create default roles and permissions
superset init

# To start a development web server on port 8088, use -p to bind to another port
superset run -h 10.x.x.x -p 8091 --with-threads --reload --debugger

gunicorn --workers 3 --timeout 120 --bind 10.27.5.3:8091 "superset.app:create_app()" --daemon

# 后台进程停止gunicorn
ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | xargs kill -9