CentOS7 安装Superset+python3.6+MySQL5.7

版权声明:本文为博主原创文章,转载请注明出处 https://blog.csdn.net/vkingnew/article/details/86516253
由于superset默认使用sqlite数据库,在实际生产中以mysql居多。因此以MySQL作为存储来安装部署superset。

运行环境:CentOS7.5 + python3.6 + MySQL5.7.24 
1.安装数据库:
wget http://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm 
yum -y install mysql-community-server  mysql-community-devel mysql-community-common
chown -R mysql:mysql /data/mysql/
chmod -R 755 /data/mysql/
--配置文件:
# cat /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/tmp/mysql.sock
default-storage-engine          =InnoDB
character_set_server            = utf8mb4
character-set-client-handshake    = FALSE
character-set-server            = utf8mb4
collation-server                = utf8mb4_unicode_ci
init_connect                    ='SET NAMES utf8mb4'
lower_case_table_names        = 1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# #skip-grant-tables 
plugin-load=validate_password.so 
validate-password=OFF
log-error=/var/log/mysqld.log
pid-file=/tmp/mysqld.pid
explicit_defaults_for_timestamp=true

server-id                     =1
log-bin                       =/data/mysql/mysql_bin.log
binlog_format                 =ROW
expire-logs-days              =2

--启动数据库:
 systemctl start mysqld
systemctl stop mysqld
--初次启动由系统自动生成随机密码:
# cat /var/log/mysqld.log  | grep -i pass
2019-01-16T13:37:09.062845Z 1 [Note] A temporary password is generated for root@localhost: X<r,oudhj1uY
2019-01-16T14:24:15.152804Z 0 [Note] Plugin 'validate_password' is disabled.
# mysql -p -S /tmp/mysql.sock
Enter password: 
输入随机密码即可。

mysql> create database superset;
Query OK, 1 row affected (0.01 sec)

mysql> grant all privileges on superset.* to superset@'%' identified by 'superset';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)



2.安装python:
rpm -ivh https://centos7.iuscommunity.org/ius-release.rpm
rpm -ivh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

yum -y  install python36u-pip python36 python36-libs python36-devel
3.安装

yum upgrade python-setuptools
 yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel

# pip install superset  -i https://mirrors.ustc.edu.cn/pypi/web/simple
Looking in indexes: https://mirrors.ustc.edu.cn/pypi/web/simple


--安装需要的驱动:
pip3 install mysqlclient #安装mysql连接包
pip3 install pymssql #安装mssql连接包
pip install PyMySQL
-- 配置:
#vim /usr/local/lib/python3.6/site-packages/superset/config.py

# The SQLAlchemy connection string.
#SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(DATA_DIR, 'superset.db')
SQLALCHEMY_DATABASE_URI = 'mysql://superset:[email protected]/superset'
将sqlite修改为mysql.

--初始化:
# fabmanager create-admin --app superset
Username [admin]: 
User first name [admin]: 
User last name [user]: 
Email [[email protected]]: [email protected]
Password: 
Repeat for confirmation: 
Recognized Database Authentications.
Admin User admin created.


# 载入案例数据
superset load_examples
 
# 初始化角色和权限
superset init

2019-01-16 23:27:52,600:INFO:root:Creating database reference
2019-01-16 23:27:52,870:INFO:root:Syncing role definition
2019-01-16 23:27:52,904:INFO:root:Syncing Admin perms
2019-01-16 23:27:53,449:INFO:root:Syncing Alpha perms
2019-01-16 23:27:54,271:INFO:root:Syncing Gamma perms
2019-01-16 23:27:54,834:INFO:root:Syncing granter perms
2019-01-16 23:27:55,363:INFO:root:Syncing sql_lab perms
2019-01-16 23:27:55,905:INFO:root:Fetching a set of all perms to lookup which ones are missing
2019-01-16 23:27:56,439:INFO:root:Creating missing datasource permissions.
2019-01-16 23:27:56,497:INFO:root:Creating missing database permissions.
2019-01-16 23:27:56,507:INFO:root:Creating missing metrics permissions
2019-01-16 23:27:56,622:INFO:root:Cleaning faulty perms

 
# 启动服务,端口号 8088,使用 -p 更改端口号
superset runserver
或者:
superset runserver -d -p 8088

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Starting Superset server in DEBUG mode
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

2019-01-16 23:28:45,578:INFO:werkzeug: * Running on http://0.0.0.0:8088/ (Press CTRL+C to quit)
2019-01-16 23:28:45,582:INFO:werkzeug: * Restarting with stat

--登录:若有防火墙需要设置防火墙.
http://192.168.0.180:8088/login/

--加载实例的时候报错:
sqlalchemy.exc.DataError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (_mysql_exceptions.DataError) (1406, "Data too long for column 'type' at row 1") [SQL: 'INSERT INTO table_columns (created_on, changed_on, column_name, verbose_name, is_active, type, groupby, count_distinct, sum, avg, max, min, filterable, description, table_id, is_dttm, expression, python_date_format, database_expression, created_by_fk, changed_by_fk) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'] [parameters: (datetime.datetime(2019, 1, 16, 23, 14, 41, 693232), datetime.datetime(2019, 1, 16, 23, 14, 41, 693259), 'source', None, 1, 'VARCHAR(255) COLLATE UTF8MB4_UNICODE_CI', 1, 0, 0, 0, 0, 0, 1, None, 1, 0, '', None, None, None, None)] (Background on this error at: http://sqlalche.me/e/9h9h)

--登录到mysql数据库修改字段长度:
alter table superset.table_columns modify type varchar(320);

--正常的示例加载:
# superset load_examples
Loading examples into <SQLA engine=mysql://superset:***@192.168.0.180/superset?charset=utf8>
Creating default CSS templates
Loading energy related dataset
Creating table [wb_health_population] reference
2019-01-16 23:21:59,852:INFO:root:Creating database reference
2019-01-16 23:22:00,136:INFO:root:Database.get_sqla_engine(). Masked URL: mysql://superset:[email protected]/superset
Loading [World Bank's Health Nutrition and Population Stats]
Creating table [wb_health_population] reference
2019-01-16 23:23:07,304:INFO:root:Creating database reference
Creating slices
Creating a World's Health Bank dashboard
Loading [Birth names]
Done loading table!
--------------------------------------------------------------------------------
Creating table [birth_names] reference
2019-01-16 23:23:23,368:INFO:root:Creating database reference
Creating some slices
Creating a dashboard
Loading [Random time series data]
Done loading table!
--------------------------------------------------------------------------------
Creating table [random_time_series] reference
2019-01-16 23:23:27,356:INFO:root:Creating database reference
Creating a slice
Loading [Random long/lat data]
Done loading table!
--------------------------------------------------------------------------------
Creating table reference
2019-01-16 23:25:04,906:INFO:root:Creating database reference
Creating a slice
Loading [Country Map data]
Done loading table!
--------------------------------------------------------------------------------
CDone loading table!
--------------------------------------------------------------------------------
Creating table [multiformat_time_series] reference
2019-01-16 23:25:06,057:INFO:root:Creating database reference
Creating Heatmap charts
Loading [Paris GeoJson]
Creating table paris_iris_mapping reference
2019-01-16 23:25:13,294:INFO:root:Creating database reference
Loading [San Francisco population polygons]
Creating table sf_population_polygons reference
2019-01-16 23:25:13,669:INFO:root:Creating database reference
Loading [Flights data]
2019-01-16 23:25:47,456:INFO:root:Creating database reference
Done loading table!
Loading [BART lines]
Creating table bart_lines reference
2019-01-16 23:25:48,080:INFO:root:Creating database reference
Loading [Multi Line]

Creating table [wb_health_population] reference
2019-01-16 23:26:54,398:INFO:root:Creating database reference
Creating slices
Creating a World's Health Bank dashboard
Done loading table!
--------------------------------------------------------------------------------
Creating table [birth_names] reference
2019-01-16 23:27:08,023:INFO:root:Creating database reference
Creating some slices
Creating a dashboard
Loading [Misc Charts] dashboard
Creating the dashboard
Loading DECK.gl demo
Loading deck.gl dashboard
Creating Scatterplot slice
Creating Screen Grid slice
Creating Hex slice
Creating Grid slice
Creating Polygon slice
Creating Arc slice
Creating Path slice
Creating a dashboard


其它可支持的数据库列表:
http://superset.apache.org/installation.html


猜你喜欢

转载自blog.csdn.net/vkingnew/article/details/86516253
今日推荐