部署supset在mini2上
supset源码:
~ ⌚ 3:04:31
$ tar zcf incubator-superset.tar.gz incubator-superset
~ ⌚ 3:05:48
$ scp incubator-superset.tar.gz mini2:~
安装nodejs:
~ ⌚ 17:11:24
$ wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz
~ ⌚ 17:12:50
$ yum install -y xz-libs.x86_64
~ ⌚ 17:45:22
$ xz -d node-v10.15.3-linux-x64.tar.xz
~ ⌚ 17:45:42
$ tar -xf node-v10.15.3-linux-x64.tar
~/node-v10.15.3-linux-x64 ⌚ 17:46:23
$ bin/node -v
v10.15.3
~/node-v10.15.3-linux-x64 ⌚ 17:46:37
$ ln -s /root/node-v10.15.3-linux-x64/bin/node /usr/local/bin/node
~/node-v10.15.3-linux-x64 ⌚ 17:46:54
$ ln -s /root/node-v10.15.3-linux-x64/bin/npm /usr/local/bin/npm
~/node-v10.15.3-linux-x64 ⌚ 17:47:10
$ node -v
v10.15.3
~ ⌚ 17:47:34
$ tar zxf incubator-superset.tar.gz
配置python环境变量:
~ ⌚ 17:51:21
$ scp [email protected]:/home/sqoop/sal/python-3.6.5.tar.gz /opt/
/opt ⌚ 17:55:19
$ tar zxf python-3.6.5.tar.gz
/opt/python-3.6.5/bin ⌚ 17:55:57
$ ./virtualenv /opt/py3_env
/opt ⌚ 17:56:33
$ source py3_env/bin/activate
编译supset:
读取目录下的package.json文件来安装
~/incubator-superset/superset/assets on master ⌚ 17:57:20
$ npm install
~/incubator-superset/superset/assets on master! ⌚ 17:58:32
$ npm run build
~/incubator-superset on master! ⌚ 18:00:03
$ pip install pyYAML==3.13
~/incubator-superset on master! ⌚ 18:00:51
$ vim ./superset/config.py
79 #SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(DATA_DIR, 'superset.db')
80 SQLALCHEMY_DATABASE_URI = 'mysql://mini:Sal_123345@mini2/tttt?charset=UTF8'
81 # SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp'
469 SMTP_HOST = 'mini2'
~/incubator-superset on ceb86df! ⌚ 18:45:52
$ python setup.py install
81 SQLALCHEMY_DATABASE_URI = 'mysql://supset_mysql:Sal_123456@flink-slave2/supersetdb?charset=UTF8’
mysql> alter user 'root'@'localhost' identified by '.ki87ujm_Mysql';
Query OK, 0 rows affected (0.02 sec)
mysql> create USER 'mini2'@'%' IDENTIFIED BY 'Sal_123456' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on *.* to 'mini2'@'%';
Query OK, 0 rows affected (0.01 sec)
mysql> create USER 'supset_mysql'@'%' IDENTIFIED BY 'Sal_123456' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.02 sec)
mysql> grant all on *.* to 'supset_mysql'@'%';
Query OK, 0 rows affected (0.01 sec)
配置mysql用户mini可远程登录mini2:
~ ⌚ 18:07:17
$ mysql -uroot -p
Enter password:
mysql> create database tttt
-> ;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on *.* To 'mini'@'%' identified by 'Sal_123345' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> select Host,User from user;
+-----------+---------------+
| Host | User |
+-----------+---------------+
| % | mini |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
4 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
~ ⌚ 10:44:46
$ ssh root@mini1
root@mini1's password:
Last login: Fri Mar 29 02:37:21 2019 from sunalongmbp
~ ⌚ 4:01:33
$ mysql -umini -hmini2 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
...
mysql>
修改虚拟环境中mysql为pymysql:
~/incubator-superset on master! ⌚ 18:24:20
$ fabmanager create-admin --app superset
Username [admin]: admin
User first name [admin]: admin
User last name [user]: admin
Email [[email protected]]: admin
Password:
Repeat for confirmation:
Was unable to import superset Error: No module named 'MySQLdb'
~/incubator-superset on master! ⌚ 18:26:20
$ pip install PyMySQL
/opt/py3_env/lib/python3.6/site-packages/SQLAlchemy-1.3.1-py3.6-linux-x86_64.egg/sqlalchemy/dialects/mysql ⌚ 0:53:35
$ vim __init__.py
【有变化的是12、13、14】
11 from . import mysqlconnector # noqa
12 #from . import mysqldb # noqa
13 import pymysql
14 pymysql.install_as_MySQLdb()
15 from . import oursql # noqa
(py3_env) [root@flink-slave2 superset]# pwd
/opt/py3_env/lib/python3.6/site-packages/apache_superset-0.999.0.dev0-py3.6.egg/superset
(py3_env) [root@flink-slave2 superset]# cp -r ~/superset-web/superset/securityfile/ .
然后再创建用户
~/incubator-superset on master! ⌚ 18:37:12
$ fabmanager create-admin --app superset
Username [admin]: sun
User first name [admin]: sun
User last name [user]: sun
Email [[email protected]]: [email protected]
Password:
Repeat for confirmation:
Recognized Database Authentications.
Admin User sun created.
(py3_env)
~/incubator-superset on master! ⌚ 18:31:18
$ superset db upgrade
~/incubator-superset on master! ⌚ 19:00:02
$ superset load_examples
~/incubator-superset on master! ⌚ 19:00:41
$ superset init
http://mini2:8080/
flask.cli.NoAppException
flask.cli.NoAppException: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.