作者:流川瘋
同步發表於:https://season.blog.csdn.net/article/details/88071469
文章大綱
1. BI 技術選型對比
假如客戶有一堆數據要分析,沒有太多行業知識的你需要在一週之內給出基本的可視化展現怎麼辦?別擔心,有BI軟件來幫你
1.1 總體對比
除了上述提到的一些產品外,我們還有國產的一家廠商:
-
FineBI
http://www.finebi.com/ -
Google Data Studio
https://developers.google.cn/datastudio/?hl=de
1.2 硬件要求
上述BI 組件的硬件需求基本可以參考Tableau給出的
Tableau Server 的系統要求:(最高版需求)
最低系統要求
- 2 核
- 64 位處理器
- 8 GB 系統內存
- 至少 15 GB 可用磁盤空間
建議要求
- 8 個物理內核,2.0 GHz 或更高頻率的 CPU
- 64 位處理器
- 32 GB 系統內存
- 至少 50 GB 可用磁盤空間
2. docker 安裝Superset
下面我們選擇Superset 來實戰一下,看看效果到底怎麼樣。
2.1 Centos 安裝docker
參照官網的安裝簡介
git clone https://github.com/apache/incubator-superset/
cd incubator-superset/contrib/docker
# prefix with SUPERSET_LOAD_EXAMPLES=yes to load examples:
docker-compose run --rm superset ./docker-init.sh
# you can run this command everytime you need to start superset now:
docker-compose up
實在不想用windows 下面那個hyper-v 的docker 我就在virtual box 中安裝 一個CentOS7 搞一搞 docker
過程無非是:
sudo yum update
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
sudo yum install docker-ce
yum install docker-ce-18.06.2.ce
systemctl start docker
systemctl enable docker
docker version
具體可以參考
https://www.cnblogs.com/yufeng218/p/8370670.html
2.2 參照SuperSet 官網編譯官網版docker
裝好docker 後就是安裝python 主要是爲了使用python 然後docker-compose 結果直接報錯:
Step 13/21 : COPY --chown=superset:superset superset superset
ERROR: Service 'superset' failed to build: Unknown flag: chown
參考解決方案:(可能是docker 更新了,Surperset的docker file 還沒有更新?)
https://forums.docker.com/t/copy-chown-fails-in-automated-build-unknown-flag-chown/43059
修改成如下形式,繼續運行,ok
運行命令:
接着報錯,一看就是權限問題,TMD
superset_superset_1 exited with code 243
superset_1 | npm ERR! path /home/superset/superset/assets/node_modules
superset_1 | npm ERR! code EACCES
superset_1 | npm ERR! errno -13
superset_1 | npm ERR! syscall mkdir
superset_1 | npm ERR! Error: EACCES: permission denied, mkdir '/home/superset/superset/assets/node_modules'
superset_1 | npm ERR! { [Error: EACCES: permission denied, mkdir '/home/superset/superset/assets/node_modules']
superset_1 | npm ERR! cause:
superset_1 | npm ERR! { Error: EACCES: permission denied, mkdir '/home/superset/superset/assets/node_modules'
superset_1 | npm ERR! type: 'OperationalError',
superset_1 | npm ERR! '$error': '$error',
superset_1 | npm ERR! cause:
superset_1 | npm ERR! { errno: -13,
superset_1 | npm ERR! code: 'EACCES',
superset_1 | npm ERR! syscall: 'mkdir',
superset_1 | npm ERR! path: '/home/superset/superset/assets/node_modules' },
superset_1 | npm ERR! isOperational: true,
superset_1 | npm ERR! errno: -13,
superset_1 | npm ERR! code: 'EACCES',
superset_1 | npm ERR! syscall: 'mkdir',
superset_1 | npm ERR! path: '/home/superset/superset/assets/node_modules' },
superset_1 | npm ERR! isOperational: true,
superset_1 | npm ERR! stack:
superset_1 | npm ERR! 'Error: EACCES: permission denied, mkdir \'/home/superset/superset/assets/node_modules\'',
superset_1 | npm ERR! type: 'OperationalError',
superset_1 | npm ERR! '$error': '$error',
superset_1 | npm ERR! errno: -13,
superset_1 | npm ERR! code: 'EACCES',
superset_1 | npm ERR! syscall: 'mkdir',
superset_1 | npm ERR! path: '/home/superset/superset/assets/node_modules' }
superset_1 | npm ERR!
superset_1 | npm ERR! The operation was rejected by your operating system.
superset_1 | npm ERR! It is likely you do not have the permissions to access this file as the current user
superset_1 | npm ERR!
superset_1 | npm ERR! If you believe this might be a permissions issue, please double-check the
superset_1 | npm ERR! permissions of the file and its containing directories, or try running
superset_1 | npm ERR! the command again as root/Administrator (though this is not recommended).
superset_1 |
superset_1 | npm ERR! A complete log of this run can be found in:
superset_1 | npm ERR! /home/superset/.npm/_logs/2019-02-22T04_42_13_898Z-debug.log
superset_superset_1 exited with code 243
解決方案:
https://stackoverflow.com/questions/54049266/superset-npm-eacces-permission-denied-mkdir
結果沒好,暴力加個權限:
chmod 777 (superset的當前目錄及上一級目錄)
其實主要是docker 裏面沒有操作他掛載目錄中的權限,提升一下權限就好了。
結果頁面成這樣了
調試一下,304 錯誤,我前端沒什麼儲備,等高手來救場了。
2.3 使用其他人製作好的docker
還是用別人搞好的吧,參考:
https://www.jianshu.com/p/d5978b439080
命令如下
# 0e9131be7e49 爲docker ps 中的id
# 先建一個/data文件夾方便映射
docker run -d -p 8088:8088 -v /data:/home/superset amancevice/superset:0.28.1
docker exec -it 0e9131be7e49 fabmanager create-admin --app superset
docker exec -it 0e9131be7e49 superset db upgrade
# 加載例子,這一步我看日誌還要數據庫建立索引啥的,時間較長,不需要可以不用
docker exec -it 0e9131be7e49 superset load_examples
docker exec -it 0e9131be7e49 superset init
docker exec -it 0e9131be7e49 superset runserver
自帶世界銀行數據的BI看板,效果爆炸有木有
2.4 使用自己的sqllite 數據源分析
假如客戶給了一個數據庫,或者一堆csv怎麼辦,別擔心,我們的superset 對外接數據源支持還是非常出色的,對於中小型關注成本的企業來說,BI無壓力。csv ,sqllite,mysql 通通連上來。
下面我們用sqllite來小試牛刀。
由於sqllite不支持遠程鏈接,我們的docker 之前掛載到宿主機的一個目錄上面
這個數據庫是我在NLP系列裏面用爬蟲爬的我自己的博客,主要包括標籤,發表時間,點贊數,評論數等內容。
鏈接字符串如下
sqlite:////home/superset/NLP_demo.db
記得點擊可以在 SQL 工具箱中公開,這樣我們纔可以在SQL工具箱中加載並找到這個數據庫。
點擊測試,seems ok 說明正常。
打開sql工具箱,寫完sql 就可以用這個子數據集進行一些BI分析了,但是由於我之前的數據庫很多列的格式沒有統計,所以畫圖會有一些問題,這一點superset 在導入數據庫數據時候似乎不能很友好的再次修改。
我選擇餅圖,統計一下博客中那一個標籤下面發的文章最多,毫無疑問 OpenCV,儘管最近都基本沒有再發過了。