龙空技术网

Linux下通过PIP安装BI工具Superset

中年猿人 211

前言:

当前看官们对“目录url”大致比较注重,各位老铁们都需要剖析一些“目录url”的相关内容。那么小编同时在网摘上汇集了一些对于“目录url””的相关资讯,希望看官们能喜欢,同学们快快来了解一下吧!

操作系统:CentOS Linux release 7.5.1804 (Core)

操作系统依赖

Superset在其元数据数据库中存储数据库连接信息。为此,我们使用加密Python库来加密连接密码。但是,这个库和操作系统级别的有一定的依赖关系。

Fedora和rhel衍生的Linux发行版

使用yum包管理器安装以下包:

sudo yum install gcc gcc-c++ libffi-devel python3-setuptools python3-devel python3-pip python3-wheel openssl-devel cyrus-sasl-devel openldap-devel
Python虚拟环境

我们强烈建议在虚拟环境中安装Superset。Python随virtualenv一起开箱即用,但你可以使用以下方式安装:

ln -s /usr/bin/pip3 /usr/bin/pippip install  -i  virtualenv

您可以使用以下方式创建和激活虚拟环境:

# virtualenv is shipped in Python 3.6+ as venv instead of pyvenv.# See  -m venv venv. venv/bin/activate

一旦激活了虚拟环境,您安装或卸载的所有Python包都将被限制在此环境中。在命令行中执行deactivate命令可以退出当前环境。

安装和初始化Superset

首先,安装apache-superset:

pip install --upgrade pippip install  -i  apache-superset

然后,你需要初始化数据库:

使用Mysql 作为数据的存储,安装Mysql驱动

yum install mysql-develpip install -i  mysqlclient

修改数据库连接:

vi /root/venv/lib64/python3.6/site-packages/superset/config.py

修改内容如下:

# SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(DATA_DIR, "superset.db")SQLALCHEMY_DATABASE_URI = 'mysql://username:password@127.0.0.1:3306/superset?charset=utf8'# SQLALCHEMY_DATABASE_URI = 'postgresql://root:password@localhost/myapp'
pip install  -i  dataclasses Pillowsuperset db upgrade

通过运行以下命令完成安装:

# Create an admin user (you will be prompted to set a username, first and last name before setting a password)$ export FLASK_APP=supersetsuperset fab create-admin

初始化示例数据:

如果速度比较慢,无法完成初始化,从github下载示例数据:,然后上传到服务器上,解压到对应的目录,然后建立可以访问一个web服务即可。

unzip  examples-data-master.zip

修改superset下相关文件的配置路径:

vi /root/venv/lib64/python3.6/site-packages/superset/examples/helpers.py

修改里面的BASE_URL的值:

#BASE_URL = ";BASE_URL = ";

执行加载示例:

superset load_examples
日志logging was configured successfullyINFO:superset.utils.logging_configurator:logging was configured successfully/root/venv/lib64/python3.6/site-packages/flask_caching/__init__.py:202: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.  "Flask-Caching: CACHE_TYPE is set to null, "Loading examples metadata and related data into examplesCreating default CSS templatesLoading energy related datasetCreating table [wb_health_population] referenceLoading [World Bank's Health Nutrition and Population Stats]Creating table [wb_health_population] referenceCreating slicesCreating a World's Health Bank dashboardLoading [Birth names]Creating some slicesCreating a dashboardLoading [Unicode test data]Creating table [unicode_test] referenceCreating a sliceCreating a dashboardLoading [Random time series data]Done loading table!--------------------------------------------------------------------------------Creating table [random_time_series] referenceCreating a sliceLoading [Random long/lat data]Done loading table!--------------------------------------------------------------------------------Creating table referenceCreating a sliceLoading [Country Map data]Done loading table!--------------------------------------------------------------------------------Creating table referenceCreating a sliceLoading [Multiformat time series]Done loading table!--------------------------------------------------------------------------------Creating table [multiformat_time_series] referenceCreating Heatmap chartsLoading [Paris GeoJson]Creating table paris_iris_mapping referenceLoading [San Francisco population polygons]Creating table sf_population_polygons referenceLoading [Flights data]Done loading table!Loading [BART lines]Creating table bart_lines referenceLoading [Multi Line]Creating table [wb_health_population] referenceCreating slicesCreating a World's Health Bank dashboardCreating some slicesCreating a dashboardLoading [Misc Charts] dashboardCreating the dashboardLoading DECK.gl demoLoading deck.gl dashboardCreating Scatterplot sliceCreating Screen Grid sliceCreating Hex sliceCreating Grid sliceCreating Polygon sliceCreating Arc sliceCreating Path sliceCreating a dashboardLoading [Tabbed dashboard]Creating a dashboard with nested tabs
# Create default roles and permissionssuperset init# To start a development web server on port 8088, use -p to bind to another portsuperset run -p 8088 -h 127.0.0.1 --with-threads --relad --debugger

如果一切正常,您应该能够在浏览器中访问hostname:port(例如,默认在本地localhost:8088),并使用您创建的用户名和密码登录

访问的首页

注册为系统服务

开放相应的端口,端口取决您设置的端口

firewall-cmd --zone=public --add-port=8088/tcp --permanentfirewall-cmd --reload

创建注册服务的文件

vi /usr/lib/systemd/system/superset.service

文件内容

[Unit]Description=SupersetAfter=multi-user.target[Service]Type=simpleUser=rootExecStart=/root/venv/bin/python3 /root/venv/bin/superset run -p 8088 -h 10.0.4.134 --reload[Install]WantedBy=default.target

上面的环境变量,根据自身情况进行调整,也可以调整服务的端口相关内容。

注册为系统服务

systemctl enable superset.service

启动服务

systemctl start  superset.service

查看服务状态

 systemctl status  superset.service

效果:

标签: #目录url #pip安装basemap