Superset的安装部署
1.1、安装Python3的环境
前置条件:安装Python3环境准备的包:
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
由于CentOS系统下本身就有python2.7的环境,我们安装了Python3.X版本后如何把python使用版本替换为Python3呢?
cd /usr/local/src #进⼊源码⽂件夹
wget www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz #下载python⽂件
tar -xf Python-3.6.6.tgz #解压缩
cd Python-3.6.6 #进⼊python ⽂件夹
./configure #配置
make && make install #安装
安装完成后,我们此时输入python还是跳转到的是Python2.X版本,在/etc/profile中做一个别名即可跳转到python3的运行环境:
1、编辑这个文件:
vi /etc/profile
2、做一个别名:
alias python='/usr/local/bin/python3'
3、生效别名:
source /etc/profile
注意点:需要在root用户下执行别名,/etc/profile表示的是全局生效。
4、如下表示成功生效:
[root@sz5i5j-01 bin]# python
Python 3.6.6 (default, Apr 27 2020, 21:13:05)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
[root@sz5i5j-01 bin]#
1.2、安装EPEL源并安装superset必备的包
yum install epel-release #安装epel源
yum install mysql-devel #安装MySQL开发包,属于pymysqlclient依赖
yum install gcc gcc-c++ libffi-devel python-devel python-wheel openssl-devel libsasl2-devel openldap-devel #安装依赖包
1.3、安装Python3的virtualenv并建立superset的env
pip3 install virtualenv -i http://pypi.douban.com/simple --trusted-host pypi.douban.com #安装virtualenv
cd /usr/local/src
python3 -m venv superset-py3 #建⽴superset的venv
source superset-py3/bin/activate #激活superset的venv
1.4、在env中安装superset
pip3 install --upgrade pip -i http://pypi.douban.com/simple --trusted-host pypi.douban.com #升级pip
pip3 install --upgrade setuptools -i http://pypi.douban.com/simple --trusted-host pypi.douban.com #升级setuptools
pip3 install apache-superset-i http://pypi.douban.com/simple --trusted-host pypi.douban.com #安装superset
1.5、安装superset的数据包
pip3 install mysqlclient -i http://pypi.douban.com/simple --trusted-host pypi.douban.com #安装mysql连接包
pip3 install "pymssql<3.0" -i http://pypi.douban.com/simple --trusted-host pypi.douban.com #安装mssql连接包
1.6、配置superset
1、注意mysql的链接后面跟的是:数据库用户名+密码+数据库IP
vi superset-py3/lib/python3.6/site-packages/superset/config.py
修改superset配置⽂件,将默认的sqlite3数据库改为MySQL找到:
SQLALCHEMY_DATABASE_URI = 'mysql://root:960210@sz5i5j-01/superset?charset=ut
f8'
1.7、mysql创建superset数据库
CREATE DATABASE `superset` /*!40100 DEFAULT CHARACTER SET utf8 */;
1.8、初始化
fabmanager create-admin --app superset #建⽴管理员账号 jepson,密码ruozedata
遇到的问题:
1.如果fabmanager不好用则删除之前/usr/bin/fabmanager
配置fabmanager环境变量:
ln -s /home/software/python3/bin/fabmanager /usr/bin/fabmanager
2.
Was unable to import superset Error: No module named 'markdown'
则安装该依赖 : pip install markdown
3. File "/usr/local/lib/python3.6.5/lib/python3.6/bz2.py", line 23, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
该错误是缺失_bz2.cpython-36m-x86_64-linux-gnu.so这个os文件,处理步骤如下:
1)下载该文件https://pan.baidu.com/s/19EuNjLWIGPxc1R5C2ntUwg 提取码:q9ki
2)将下载后的文件放到python3.6文件夹里…/python36/lib/python3.6/lib-dynload/目录下;
使用"chmod +x _bz2.cpython-36m-x86_64-linux-gnu.so"增加该文件的可执行权限
3)再次运行程序可能还会报错:ImportError: libbz2.so.1.0: cannot open shared object file: No such file or directory
1.首先需要使用sudo yum install -y bzip2* 确保系统已经安装了相关的库;
2.此时会发现在/usr/lib64目录下会发现其实有libbz2.so.1.0.6这样一个文件,我们只需要在该目录下使用命令
"sudo ln -s libbz2.so.1.0.6 libbz2.so.1.0"创建一个该文件的软连接。
superset db upgrade
superset init #初始化superset数据库
mysql:
alter table superset.table_columns modify type varchar(255);
注意此处输入fabmanager提示-bash command not found,意识其实还是缺少东西;需要安装这个命令: pip install flask-appbuilder;不然你使用全局搜索都是没有找不到fab相关的文件的:find / -name ‘fabmanager’
[root@sz5i5j-01 src]# fabmanager create-admin --app superset
1.8、在这个目录下后台执行启动
运行目录的命令:/usr/local/src/superset-py3/bin
后台启动的命令:
nohup superset run -h server06 -p 8890 --with-threads --reload --debugger >> /usr/local/src/superset-py3/lib/python3.6/site-packages/superset/supersetStart.log 2>&1 &
注意:sz5i5j-01是用户的机器名,需要在linux下的/etc/hosts下做好映射,以及C盘下的hosts文件中也做好映射;8890表示机器上未经使用的端口,使用前需要netstat命令监听下是否确实没被占用,云主机下还要在安全组配置中放开端口入方向的配置规则。
如下图表示安装成功:
启动的日志信息如下:
[root@sz5i5j-01 bin]# superset run -h sz5i5j-01 -p 8890
INFO:root:logging was configured successfully
/usr/local/lib/python3.6/site-packages/flask_caching/__init__.py:189: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
"Flask-Caching: CACHE_TYPE is set to null, "
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
INFO:werkzeug: * Running on http://sz5i5j-01:8890/ (Press CTRL+C to quit)
依赖:
databasepypi packageSQLAlchemy URI prefix
Amazon Athenapip install "PyAthenaJDBC>1.0.9"awsathena+jdbc://
Amazon Athenapip install "PyAthena>1.2.0"awsathena+rest://
Amazon Redshiftpip install sqlalchemy-redshiftredshift+psycopg2://
Apache Drillpip install sqlalchemy-drillFor the REST API:`` drill+sadrill:// For JDBC drill+jdbc://
Apache Druidpip install pydruiddruid://
Apache Hivepip install pyhivehive://
Apache Impalapip install impylaimpala://
Apache Kylinpip install kylinpykylin://
Apache Pinotpip install pinotdbpinot+http://CONTROLLER:5436/ query?server=http://CONTROLLER:5983/
Apache Spark SQLpip install pyhivejdbc+hive://
BigQuerypip install pybigquerybigquery://
ClickHousepip install sqlalchemy-clickhouse
CockroachDBpip install cockroachdbcockroachdb://
Dremiopip install sqlalchemy_dremiodremio://user:pwd@host:31010/
Elasticsearchpip install elasticsearch-dbapielasticsearch+http://
Exasolpip install sqlalchemy-exasolexa+pyodbc://
Google Sheetspip install gsheetsdbgsheets://
IBM Db2pip install ibm_db_sadb2+ibm_db://
MySQLpip install mysqlclientmysql://
Oraclepip install cx_Oracleoracle://
PostgreSQLpip install psycopg2postgresql+psycopg2://
Prestopip install pyhivepresto://
Snowflakepip install snowflake-sqlalchemysnowflake://
SQLitesqlite://
SQL Serverpip install pymssqlmssql://
Teradatapip install sqlalchemy-teradatateradata://
Verticapip install sqlalchemy-vertica-pythonvertica+vertica_python://
Hanapip install hdbcli sqlalchemy-hana or pip install apache-superset[hana]
示例:
连接druid:
The native Druid connector (behind the DRUID_IS_ACTIVE feature flag) is slowly getting deprecated in favor of the SQLAlchemy/DBAPI connector made available in the pydruid library.
原生Druid连接器(在DRUID_IS_ACTIVE特性标志后面)正在慢慢被抛弃,转而支持pydruid库中提供的SQLAlchemy/DBAPI连接器。
退出虚拟环境:
deactivate
site-packages